diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/directories.zsh | 1 | ||||
-rw-r--r-- | lib/functions.zsh | 10 | ||||
-rw-r--r-- | lib/spectrum.zsh | 6 | ||||
-rw-r--r-- | lib/termsupport.zsh | 43 |
4 files changed, 37 insertions, 23 deletions
diff --git a/lib/directories.zsh b/lib/directories.zsh index 3bffa9fd9..a50a692c8 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -8,6 +8,7 @@ alias -g ....='../../..' alias -g .....='../../../..' alias -g ......='../../../../..' +alias -- -='cd -' alias 1='cd -' alias 2='cd -2' alias 3='cd -3' diff --git a/lib/functions.zsh b/lib/functions.zsh index ec6f37214..f9d4a9717 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -16,13 +16,17 @@ function take() { } function open_command() { + emulate -L zsh + setopt shwordsplit + local open_cmd # define the open command case "$OSTYPE" in - darwin*) open_cmd="open" ;; - cygwin*) open_cmd="cygstart" ;; - linux*) open_cmd="xdg-open" ;; + darwin*) open_cmd='open' ;; + cygwin*) open_cmd='cygstart' ;; + linux*) open_cmd='xdg-open' ;; + msys*) open_cmd='start ""' ;; *) echo "Platform $OSTYPE not supported" return 1 ;; diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index b683aca29..87092d8ae 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -3,7 +3,7 @@ # P.C. Shyamshankar <sykora@lucentbeing.com> # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ -typeset -Ag FX FG BG +typeset -AHg FX FG BG FX=( reset "%{[00m%}" @@ -25,13 +25,13 @@ ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab o # Show all 256 colors with color number function spectrum_ls() { for code in {000..255}; do - print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f" + print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" done } # Show all 256 colors where the background is set to specific color function spectrum_bls() { for code in {000..255}; do - print -P -- "$BG[$code]$code: $ZSH_SPECTRUM_TEXT %{$reset_color%}" + print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" done } diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 4c5068e9b..7cf15b0a0 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -9,32 +9,42 @@ function title { emulate -L zsh setopt prompt_subst - + [[ "$EMACS" == *term* ]] && return # if $2 is unset use $1 as default # 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" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$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 |