Browse code
chore(zsh,iterm): update shell integration
Showing 1 changed files
... | ... |
@@ -1,5 +1,20 @@ |
1 | 1 |
if [[ $TERM_PROGRAM == "iTerm.app" && -o interactive ]]; then |
2 |
- if [ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != "screen" -a "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" ]; then |
|
2 |
+# This program is free software; you can redistribute it and/or |
|
3 |
+# modify it under the terms of the GNU General Public License |
|
4 |
+# as published by the Free Software Foundation; either version 2 |
|
5 |
+# of the License, or (at your option) any later version. |
|
6 |
+# |
|
7 |
+# This program is distributed in the hope that it will be useful, |
|
8 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 |
+# GNU General Public License for more details. |
|
11 |
+# |
|
12 |
+# You should have received a copy of the GNU General Public License |
|
13 |
+# along with this program; if not, write to the Free Software |
|
14 |
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
15 |
+ |
|
16 |
+if [[ -o interactive ]]; then |
|
17 |
+ if [ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "screen" -a "${ITERM_SHELL_INTEGRATION_INSTALLED-}" = "" -a "$TERM" != linux -a "$TERM" != dumb ]; then |
|
3 | 18 |
ITERM_SHELL_INTEGRATION_INSTALLED=Yes |
4 | 19 |
ITERM2_SHOULD_DECORATE_PROMPT="1" |
5 | 20 |
# Indicates start of command output. Runs just before command executes. |
... | ... |
@@ -19,11 +34,12 @@ if [[ $TERM_PROGRAM == "iTerm.app" && -o interactive ]]; then |
19 | 34 |
whence -v iterm2_print_user_vars > /dev/null 2>&1 |
20 | 35 |
if [ $? -ne 0 ]; then |
21 | 36 |
iterm2_print_user_vars() { |
37 |
+ true |
|
22 | 38 |
} |
23 | 39 |
fi |
24 | 40 |
|
25 | 41 |
iterm2_print_state_data() { |
26 |
- printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "$iterm2_hostname" |
|
42 |
+ printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "${iterm2_hostname-}" |
|
27 | 43 |
printf "\033]1337;CurrentDir=%s\007" "$PWD" |
28 | 44 |
iterm2_print_user_vars |
29 | 45 |
} |
... | ... |
@@ -89,17 +105,22 @@ if [[ $TERM_PROGRAM == "iTerm.app" && -o interactive ]]; then |
89 | 105 |
ITERM2_SHOULD_DECORATE_PROMPT="" |
90 | 106 |
|
91 | 107 |
# Add our escape sequences just before the prompt is shown. |
92 |
- if [[ $PS1 == *'$(iterm2_prompt_mark)'* ]] |
|
93 |
- then |
|
94 |
- PS1="$PS1%{$(iterm2_prompt_end)%}" |
|
108 |
+ # Use ITERM2_SQUELCH_MARK for people who can't mdoify PS1 directly, like powerlevel9k users. |
|
109 |
+ # This is gross but I had a heck of a time writing a correct if statetment for zsh 5.0.2. |
|
110 |
+ local PREFIX="" |
|
111 |
+ if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then |
|
112 |
+ PREFIX="" |
|
113 |
+ elif [[ "${ITERM2_SQUELCH_MARK-}" != "" ]]; then |
|
114 |
+ PREFIX="" |
|
95 | 115 |
else |
96 |
- PS1="%{$(iterm2_prompt_mark)%}$PS1%{$(iterm2_prompt_end)%}" |
|
116 |
+ PREFIX="%{$(iterm2_prompt_mark)%}" |
|
97 | 117 |
fi |
118 |
+ PS1="$PREFIX$PS1%{$(iterm2_prompt_end)%}" |
|
98 | 119 |
} |
99 | 120 |
|
100 | 121 |
iterm2_precmd() { |
101 | 122 |
local STATUS="$?" |
102 |
- if [ -z "$ITERM2_SHOULD_DECORATE_PROMPT" ]; then |
|
123 |
+ if [ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]; then |
|
103 | 124 |
# You pressed ^C while entering a command (iterm2_preexec did not run) |
104 | 125 |
iterm2_before_cmd_executes |
105 | 126 |
fi |
... | ... |
@@ -119,23 +140,25 @@ if [[ $TERM_PROGRAM == "iTerm.app" && -o interactive ]]; then |
119 | 140 |
iterm2_before_cmd_executes |
120 | 141 |
} |
121 | 142 |
|
122 |
- # If hostname -f is slow on your system, set iterm2_hostname prior to sourcing this script. |
|
123 |
- [[ -z "$iterm2_hostname" ]] && iterm2_hostname=`hostname -f 2>/dev/null` |
|
124 |
- # some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option |
|
125 |
- if [ $? -ne 0 ]; then |
|
126 |
- iterm2_hostname=`hostname` |
|
143 |
+ # If hostname -f is slow on your system set iterm2_hostname prior to |
|
144 |
+ # sourcing this script. |
|
145 |
+ if [ -z "${iterm2_hostname-}" ]; then |
|
146 |
+ iterm2_hostname=`hostname -f 2>/dev/null` |
|
147 |
+ # Some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option. |
|
148 |
+ if [ $? -ne 0 ]; then |
|
149 |
+ iterm2_hostname=`hostname` |
|
150 |
+ fi |
|
127 | 151 |
fi |
128 | 152 |
|
129 |
- if [[ "$TERM_PROGRAM" = "iTerm.app" ]]; then |
|
130 |
- [[ -z $precmd_functions ]] && precmd_functions=() |
|
131 |
- precmd_functions=($precmd_functions iterm2_precmd) |
|
153 |
+ [[ -z ${precmd_functions-} ]] && precmd_functions=() |
|
154 |
+ precmd_functions=($precmd_functions iterm2_precmd) |
|
132 | 155 |
|
133 |
- [[ -z $preexec_functions ]] && preexec_functions=() |
|
134 |
- preexec_functions=($preexec_functions iterm2_preexec) |
|
156 |
+ [[ -z ${preexec_functions-} ]] && preexec_functions=() |
|
157 |
+ preexec_functions=($preexec_functions iterm2_preexec) |
|
135 | 158 |
|
136 |
- iterm2_print_state_data |
|
137 |
- printf "\033]1337;ShellIntegrationVersion=6;shell=zsh\007" |
|
138 |
- fi |
|
159 |
+ iterm2_print_state_data |
|
160 |
+ printf "\033]1337;ShellIntegrationVersion=11;shell=zsh\007" |
|
139 | 161 |
fi |
140 |
- alias imgcat=~/.iterm2/imgcat;alias imgls=~/.iterm2/imgls;alias it2attention=~/.iterm2/it2attention;alias it2check=~/.iterm2/it2check;alias it2copy=~/.iterm2/it2copy;alias it2dl=~/.iterm2/it2dl;alias it2getvar=~/.iterm2/it2getvar;alias it2setcolor=~/.iterm2/it2setcolor;alias it2setkeylabel=~/.iterm2/it2setkeylabel;alias it2ul=~/.iterm2/it2ul;alias it2universion=~/.iterm2/it2universion |
|
162 |
+fi |
|
163 |
+alias imgcat=${HOME}/.iterm2/imgcat;alias imgls=${HOME}/.iterm2/imgls;alias it2api=${HOME}/.iterm2/it2api;alias it2attention=${HOME}/.iterm2/it2attention;alias it2check=${HOME}/.iterm2/it2check;alias it2copy=${HOME}/.iterm2/it2copy;alias it2dl=${HOME}/.iterm2/it2dl;alias it2getvar=${HOME}/.iterm2/it2getvar;alias it2git=${HOME}/.iterm2/it2git;alias it2setcolor=${HOME}/.iterm2/it2setcolor;alias it2setkeylabel=${HOME}/.iterm2/it2setkeylabel;alias it2ul=${HOME}/.iterm2/it2ul;alias it2universion=${HOME}/.iterm2/it2universion |
|
141 | 164 |
fi |