Commit f5c7faa5a94adfa337927b3b4cd0eb3c354bf343
1 parent
7378b55ded
Exists in
master
and in
1 other branch
Squashed 'repos/robbyrussell/oh-my-zsh/' changes from 00344f7..ee34381
ee34381 Use $HOME instead of tilde inside quotes 3841115 Merge pull request #4654 from mcornella/termsupport-cleanup c82f49e Merge pull request #4652 from psprint/master 4e30688 Cleanup update_terminalapp_cwd function eca912e Quote all variables in if statements 103eb32 Use a case structure to id terminal types d427ac1 znt: twice as fast searching ae84be7 znt: updated README.md git-subtree-dir: repos/robbyrussell/oh-my-zsh git-subtree-split: ee343814b799cc44b84d8999d5cb444159815bac
Showing 4 changed files with 39 additions and 27 deletions Side-by-side Diff
README.markdown
| ... | ... | @@ -104,7 +104,7 @@ The default location is `~/.oh-my-zsh` (hidden in your home directory) |
| 104 | 104 | If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this: |
| 105 | 105 | |
| 106 | 106 | ```shell |
| 107 | -export ZSH="~/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
| 107 | +export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
| 108 | 108 | ``` |
| 109 | 109 | |
| 110 | 110 | #### Manual Installation |
lib/termsupport.zsh
| ... | ... | @@ -16,25 +16,35 @@ function title { |
| 16 | 16 | # if it is set and empty, leave it as is |
| 17 | 17 | : ${2=$1} |
| 18 | 18 | |
| 19 | - if [[ "$TERM" == screen* ]]; then | |
| 20 | - print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars | |
| 21 | - elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == putty* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM" == cygwin ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then | |
| 22 | - print -Pn "\e]2;$2:q\a" #set window name | |
| 23 | - print -Pn "\e]1;$1:q\a" #set icon (=tab) name | |
| 24 | - fi | |
| 19 | + case "$TERM" in | |
| 20 | + cygwin|xterm*|putty*|rxvt*|ansi) | |
| 21 | + print -Pn "\e]2;$2:q\a" # set window name | |
| 22 | + print -Pn "\e]1;$1:q\a" # set tab name | |
| 23 | + ;; | |
| 24 | + screen*) | |
| 25 | + print -Pn "\ek$1:q\e\\" # set screen hardstatus | |
| 26 | + ;; | |
| 27 | + *) | |
| 28 | + if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then | |
| 29 | + print -Pn "\e]2;$2:q\a" # set window name | |
| 30 | + print -Pn "\e]1;$1:q\a" # set tab name | |
| 31 | + fi | |
| 32 | + ;; | |
| 33 | + esac | |
| 25 | 34 | } |
| 26 | 35 | |
| 27 | 36 | ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD |
| 28 | 37 | ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" |
| 29 | 38 | # Avoid duplication of directory in terminals with independent dir display |
| 30 | -if [[ $TERM_PROGRAM == Apple_Terminal ]]; then | |
| 39 | +if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then | |
| 31 | 40 | ZSH_THEME_TERM_TITLE_IDLE="%n@%m" |
| 32 | 41 | fi |
| 33 | 42 | |
| 34 | 43 | # Runs before showing the prompt |
| 35 | 44 | function omz_termsupport_precmd { |
| 36 | 45 | emulate -L zsh |
| 37 | - if [[ $DISABLE_AUTO_TITLE == true ]]; then | |
| 46 | + | |
| 47 | + if [[ "$DISABLE_AUTO_TITLE" == true ]]; then | |
| 38 | 48 | return |
| 39 | 49 | fi |
| 40 | 50 | |
| ... | ... | @@ -44,12 +54,12 @@ function omz_termsupport_precmd { |
| 44 | 54 | # Runs before executing the command |
| 45 | 55 | function omz_termsupport_preexec { |
| 46 | 56 | emulate -L zsh |
| 47 | - if [[ $DISABLE_AUTO_TITLE == true ]]; then | |
| 57 | + setopt extended_glob | |
| 58 | + | |
| 59 | + if [[ "$DISABLE_AUTO_TITLE" == true ]]; then | |
| 48 | 60 | return |
| 49 | 61 | fi |
| 50 | 62 | |
| 51 | - setopt extended_glob | |
| 52 | - | |
| 53 | 63 | # cmd name only, or if this is sudo or ssh, the next cmd |
| 54 | 64 | local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} |
| 55 | 65 | local LINE="${2:gs/%/%%}" |
| ... | ... | @@ -66,19 +76,18 @@ preexec_functions+=(omz_termsupport_preexec) |
| 66 | 76 | # With extra fixes to handle multibyte chars and non-UTF-8 locales |
| 67 | 77 | |
| 68 | 78 | if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then |
| 69 | - | |
| 70 | 79 | # Emits the control sequence to notify Terminal.app of the cwd |
| 80 | + # Identifies the directory using a file: URI scheme, including | |
| 81 | + # the host name to disambiguate local vs. remote paths. | |
| 71 | 82 | function update_terminalapp_cwd() { |
| 72 | 83 | emulate -L zsh |
| 73 | - # Identify the directory using a "file:" scheme URL, including | |
| 74 | - # the host name to disambiguate local vs. remote paths. | |
| 75 | 84 | |
| 76 | 85 | # Percent-encode the pathname. |
| 77 | 86 | local URL_PATH="$(omz_urlencode -P $PWD)" |
| 78 | 87 | [[ $? != 0 ]] && return 1 |
| 79 | - local PWD_URL="file://$HOST$URL_PATH" | |
| 88 | + | |
| 80 | 89 | # Undocumented Terminal.app-specific control sequence |
| 81 | - printf '\e]7;%s\a' $PWD_URL | |
| 90 | + printf '\e]7;%s\a' "file://$HOST$URL_PATH" | |
| 82 | 91 | } |
| 83 | 92 | |
| 84 | 93 | # Use a precmd hook instead of a chpwd hook to avoid contaminating output |
plugins/zsh-navigation-tools/README.md
| ... | ... | @@ -105,7 +105,8 @@ colorize output of the tools, via their config files (check out e.g. n-cd.conf, |
| 105 | 105 | it uses this). |
| 106 | 106 | |
| 107 | 107 | ## Performance |
| 108 | -ZNT is fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to | |
| 108 | +ZNT are fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to | |
| 109 | 109 | be released). |
| 110 | 110 | |
| 111 | -# vim:filetype=conf | |
| 111 | + | |
| 112 | +vim:filetype=conf |
plugins/zsh-navigation-tools/n-list
| ... | ... | @@ -261,18 +261,15 @@ while (( 1 )); do |
| 261 | 261 | local search_buffer="${NLIST_SEARCH_BUFFER%% ##}" |
| 262 | 262 | search_buffer="${search_buffer## ##}" |
| 263 | 263 | search_buffer="${search_buffer//(#m)[][*?|#~^()><\\]/\\$MATCH}" |
| 264 | + local search_pattern="" | |
| 265 | + local colsearch_pattern="" | |
| 264 | 266 | if [ -n "$search_buffer" ]; then |
| 265 | 267 | # Patterns will be *foo*~^*bar* and foo|bar) |
| 266 | - local search_pattern="${search_buffer// ##/*~^*}" | |
| 267 | - local colsearch_pattern="${search_buffer// ##/|}" | |
| 268 | + search_pattern="${search_buffer// ##/*~^*}" | |
| 269 | + colsearch_pattern="${search_buffer// ##/|}" | |
| 268 | 270 | |
| 269 | 271 | list=( "${(@M)list:#(#i)*$~search_pattern*}" ) |
| 270 | 272 | last_element="$#list" |
| 271 | - | |
| 272 | - local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' | |
| 273 | - col_list=( "${(@)list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
| 274 | - else | |
| 275 | - col_list=( "$list[@]" ) | |
| 276 | 273 | fi |
| 277 | 274 | |
| 278 | 275 | # Called after processing list |
| ... | ... | @@ -286,7 +283,12 @@ while (( 1 )); do |
| 286 | 283 | |
| 287 | 284 | if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then |
| 288 | 285 | prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" |
| 289 | - disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" ) | |
| 286 | + disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" ) | |
| 287 | + | |
| 288 | + if [ -n "$colsearch_pattern" ]; then | |
| 289 | + local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' | |
| 290 | + disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) | |
| 291 | + fi | |
| 290 | 292 | |
| 291 | 293 | # We have display list, lets replace newlines with "\n" when needed (1/3) |
| 292 | 294 | [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" ) |
-
mentioned in commit 9284fe