From f5c7faa5a94adfa337927b3b4cd0eb3c354bf343 Mon Sep 17 00:00:00 2001 From: mj Date: Sun, 6 Dec 2015 18:30:16 +0100 Subject: [PATCH] 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 --- README.markdown | 2 +- lib/termsupport.zsh | 41 +++++++++++++++++++++------------- plugins/zsh-navigation-tools/README.md | 5 +++-- plugins/zsh-navigation-tools/n-list | 18 ++++++++------- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/README.markdown b/README.markdown index 6007d65..9d7210f 100644 --- a/README.markdown +++ b/README.markdown @@ -104,7 +104,7 @@ The default location is `~/.oh-my-zsh` (hidden in your home directory) 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: ```shell -export ZSH="~/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" +export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" ``` #### Manual Installation diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index f11a7dd..7cf15b0 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -16,25 +16,35 @@ function title { # if it is set and empty, leave it as is : ${2=$1} - if [[ "$TERM" == screen* ]]; then - print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars - elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == putty* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM" == cygwin ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then - print -Pn "\e]2;$2:q\a" #set window name - print -Pn "\e]1;$1:q\a" #set icon (=tab) name - fi + case "$TERM" in + cygwin|xterm*|putty*|rxvt*|ansi) + print -Pn "\e]2;$2:q\a" # set window name + print -Pn "\e]1;$1:q\a" # set tab name + ;; + screen*) + print -Pn "\ek$1:q\e\\" # set screen hardstatus + ;; + *) + if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then + print -Pn "\e]2;$2:q\a" # set window name + print -Pn "\e]1;$1:q\a" # set tab name + fi + ;; + esac } ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" # Avoid duplication of directory in terminals with independent dir display -if [[ $TERM_PROGRAM == Apple_Terminal ]]; then +if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then ZSH_THEME_TERM_TITLE_IDLE="%n@%m" fi # Runs before showing the prompt function omz_termsupport_precmd { emulate -L zsh - if [[ $DISABLE_AUTO_TITLE == true ]]; then + + if [[ "$DISABLE_AUTO_TITLE" == true ]]; then return fi @@ -44,12 +54,12 @@ function omz_termsupport_precmd { # Runs before executing the command function omz_termsupport_preexec { emulate -L zsh - if [[ $DISABLE_AUTO_TITLE == true ]]; then + setopt extended_glob + + if [[ "$DISABLE_AUTO_TITLE" == true ]]; then return fi - setopt extended_glob - # cmd name only, or if this is sudo or ssh, the next cmd local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} local LINE="${2:gs/%/%%}" @@ -66,19 +76,18 @@ preexec_functions+=(omz_termsupport_preexec) # With extra fixes to handle multibyte chars and non-UTF-8 locales if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # Emits the control sequence to notify Terminal.app of the cwd + # Identifies the directory using a file: URI scheme, including + # the host name to disambiguate local vs. remote paths. function update_terminalapp_cwd() { emulate -L zsh - # Identify the directory using a "file:" scheme URL, including - # the host name to disambiguate local vs. remote paths. # Percent-encode the pathname. local URL_PATH="$(omz_urlencode -P $PWD)" [[ $? != 0 ]] && return 1 - local PWD_URL="file://$HOST$URL_PATH" + # Undocumented Terminal.app-specific control sequence - printf '\e]7;%s\a' $PWD_URL + printf '\e]7;%s\a' "file://$HOST$URL_PATH" } # Use a precmd hook instead of a chpwd hook to avoid contaminating output diff --git a/plugins/zsh-navigation-tools/README.md b/plugins/zsh-navigation-tools/README.md index 686213c..670a85e 100644 --- a/plugins/zsh-navigation-tools/README.md +++ b/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, it uses this). ## Performance -ZNT is fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to +ZNT are fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to be released). -# vim:filetype=conf + +vim:filetype=conf diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list index c706631..26431a0 100644 --- a/plugins/zsh-navigation-tools/n-list +++ b/plugins/zsh-navigation-tools/n-list @@ -261,18 +261,15 @@ while (( 1 )); do local search_buffer="${NLIST_SEARCH_BUFFER%% ##}" search_buffer="${search_buffer## ##}" search_buffer="${search_buffer//(#m)[][*?|#~^()><\\]/\\$MATCH}" + local search_pattern="" + local colsearch_pattern="" if [ -n "$search_buffer" ]; then # Patterns will be *foo*~^*bar* and foo|bar) - local search_pattern="${search_buffer// ##/*~^*}" - local colsearch_pattern="${search_buffer// ##/|}" + search_pattern="${search_buffer// ##/*~^*}" + colsearch_pattern="${search_buffer// ##/|}" list=( "${(@M)list:#(#i)*$~search_pattern*}" ) last_element="$#list" - - local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' - col_list=( "${(@)list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) - else - col_list=( "$list[@]" ) fi # Called after processing list @@ -286,7 +283,12 @@ while (( 1 )); do if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" - disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" ) + disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" ) + + if [ -n "$colsearch_pattern" ]; then + local red=$'\x1b[00;31m' reset=$'\x1b[00;00m' + disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" ) + fi # We have display list, lets replace newlines with "\n" when needed (1/3) [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" ) -- 2.0.0