Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index f11a7dd182b4b454f64ed2368f8c3ab929efa65e..7cf15b0a0ee2d09775ee03aa7d419cd81961364e 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -16,25 +16,35 @@ function title {
6 # if it is set and empty, leave it as is
7 : ${2=$1}
8
9- if [[ "$TERM" == screen* ]]; then
10- print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
11- elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == putty* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM" == cygwin ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
12- print -Pn "\e]2;$2:q\a" #set window name
13- print -Pn "\e]1;$1:q\a" #set icon (=tab) name
14- fi
15+ case "$TERM" in
16+ cygwin|xterm*|putty*|rxvt*|ansi)
17+ print -Pn "\e]2;$2:q\a" # set window name
18+ print -Pn "\e]1;$1:q\a" # set tab name
19+ ;;
20+ screen*)
21+ print -Pn "\ek$1:q\e\\" # set screen hardstatus
22+ ;;
23+ *)
24+ if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
25+ print -Pn "\e]2;$2:q\a" # set window name
26+ print -Pn "\e]1;$1:q\a" # set tab name
27+ fi
28+ ;;
29+ esac
30 }
31
32 ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
33 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
34 # Avoid duplication of directory in terminals with independent dir display
35-if [[ $TERM_PROGRAM == Apple_Terminal ]]; then
36+if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
37 ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
38 fi
39
40 # Runs before showing the prompt
41 function omz_termsupport_precmd {
42 emulate -L zsh
43- if [[ $DISABLE_AUTO_TITLE == true ]]; then
44+
45+ if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
46 return
47 fi
48
49@@ -44,12 +54,12 @@ function omz_termsupport_precmd {
50 # Runs before executing the command
51 function omz_termsupport_preexec {
52 emulate -L zsh
53- if [[ $DISABLE_AUTO_TITLE == true ]]; then
54+ setopt extended_glob
55+
56+ if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
57 return
58 fi
59
60- setopt extended_glob
61-
62 # cmd name only, or if this is sudo or ssh, the next cmd
63 local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
64 local LINE="${2:gs/%/%%}"
65@@ -66,19 +76,18 @@ preexec_functions+=(omz_termsupport_preexec)
66 # With extra fixes to handle multibyte chars and non-UTF-8 locales
67
68 if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
69-
70 # Emits the control sequence to notify Terminal.app of the cwd
71+ # Identifies the directory using a file: URI scheme, including
72+ # the host name to disambiguate local vs. remote paths.
73 function update_terminalapp_cwd() {
74 emulate -L zsh
75- # Identify the directory using a "file:" scheme URL, including
76- # the host name to disambiguate local vs. remote paths.
77
78 # Percent-encode the pathname.
79 local URL_PATH="$(omz_urlencode -P $PWD)"
80 [[ $? != 0 ]] && return 1
81- local PWD_URL="file://$HOST$URL_PATH"
82+
83 # Undocumented Terminal.app-specific control sequence
84- printf '\e]7;%s\a' $PWD_URL
85+ printf '\e]7;%s\a' "file://$HOST$URL_PATH"
86 }
87
88 # Use a precmd hook instead of a chpwd hook to avoid contaminating output