1function osc7-pwd() {
2 emulate -L zsh # also sets localoptions for us
3 setopt extendedglob
4 local LC_ALL=C
5 printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}}
6}
7
8function chpwd-osc7-pwd() {
9 (( ZSH_SUBSHELL )) || osc7-pwd
10}
11add-zsh-hook -Uz chpwd chpwd-osc7-pwd
12
13precmd() {
14 print -Pn "\e]133;A\e\\"
15}
16
17function precmd {
18 if ! builtin zle; then
19 print -n "\e]133;D\e\\"
20 fi
21}
22
23function preexec {
24 print -n "\e]133;C\e\\"
25}