From 1e7c6743a7b221cb2069a84c70890014597672d8 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Mon, 15 Sep 2014 15:36:34 +0200 Subject: [PATCH 01/46] sudo: maintain cursor position I.e. when prefixing the current command-line with 'sudo ' maintain the current cursor position instead of jumping to the end of the line. --- plugins/sudo/sudo.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index d12e06853..e3ba39918 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -13,9 +13,8 @@ # ------------------------------------------------------------------------------ sudo-command-line() { -[[ -z $BUFFER ]] && zle up-history -[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" -zle end-of-line + [[ -z $BUFFER ]] && zle up-history + [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" } zle -N sudo-command-line # Defined shortcut keys: [Esc] [Esc] From b0013ceb29e4214a76c92bfbdc0d87354c374277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Mon, 15 Sep 2014 12:13:43 -0300 Subject: [PATCH 02/46] remove path not found for linuxonly theme --- themes/linuxonly.zsh-theme | 1 - 1 file changed, 1 deletion(-) diff --git a/themes/linuxonly.zsh-theme b/themes/linuxonly.zsh-theme index a11b80d7f..f9e0aa07d 100644 --- a/themes/linuxonly.zsh-theme +++ b/themes/linuxonly.zsh-theme @@ -13,7 +13,6 @@ local c7=$(printf "\033[38;5;149m") local c8=$(printf "\033[38;5;126m") local c9=$(printf "\033[38;5;162m") -local foopath=$(perl /home/scp1/bin/foopath) if [ "$TERM" = "linux" ]; then c1=$(printf "\033[34;1m") From c6a8b2ea6d80e33716ce5590f4c4aff96776f06e Mon Sep 17 00:00:00 2001 From: mizabrik Date: Fri, 28 Nov 2014 19:40:56 +0300 Subject: [PATCH 03/46] Save ZSH path in newly created .zshrc --- tools/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index a53ac48ab..35548005a 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -23,8 +23,8 @@ fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc -sed -i -e "/^ZSH=/ c\\ -ZSH=$ZSH +sed -i -e "/^export ZSH=/ c\\ +export ZSH=$ZSH " ~/.zshrc echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" From 833e6f5958b9851d2dbcf8ae706474af4079a25e Mon Sep 17 00:00:00 2001 From: Jyrki Pulliainen Date: Wed, 7 Jan 2015 18:15:00 +0100 Subject: [PATCH 04/46] virtualenvwrapper: Deactivate only if in virtualenv If user manually deactivates the virtualenv when using this mode, zsh will produce following error: deactivate:12: command not found: virtualenv_deactivate To avoid this, check that the VIRTUAL_ENV flag is set before trying to automatically deactivate the virtual environment. Fixes #2185 --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 52e02d3e0..217ab0722 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -38,7 +38,7 @@ if (( $+commands[$virtualenvwrapper] )); then source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" fi fi - elif [ $CD_VIRTUAL_ENV ]; then + elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then # We've just left the repo, deactivate the environment # Note: this only happens if the virtualenv was activated automatically deactivate && unset CD_VIRTUAL_ENV From f997ed7ed8028e400216cfac9bee64b53017e588 Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Sat, 10 Jan 2015 15:38:49 +0100 Subject: [PATCH 05/46] Add Fedora support for command-not-found plugin --- .../command-not-found.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index f3d7ec2df..797554a13 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -7,3 +7,19 @@ # Arch Linux command-not-found support, you must have package pkgfile installed # https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook [[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh + +# Fedora command-not-found support +if [ -f /usr/libexec/pk-command-not-found ]; then + command_not_found_handler () { + runcnf=1 + retval=127 + [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0 + [ ! -x /usr/libexec/packagekitd ] && runcnf=0 + if [ $runcnf -eq 1 ] + then + /usr/libexec/pk-command-not-found $@ + retval=$? + fi + return $retval + } +fi From 5f79ab5547f51bd32dcd0a1b21fc26c8720711ba Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 27 Jan 2015 21:00:07 -0600 Subject: [PATCH 06/46] Move chpwd update output from chpwd hook to precmd to avoid contaminating script/function output --- lib/termsupport.zsh | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index d9f2b64d4..ce36f229f 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -16,12 +16,19 @@ function title { ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" -#Appears when you have the prompt +# Runs when you have the prompt function omz_termsupport_precmd { title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE + + # Notify Terminal.app of current directory using undocumented OSC sequence + # found in OS X 10.9 and 10.10's /etc/bashrc + if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then + local PWD_URL="file://$HOSTNAME${PWD// /%20}" + printf '\e]7;%s\a' "$PWD_URL" + fi } -#Appears at the beginning of (and during) of command execution +# Runs at the beginning of (and during) of command execution function omz_termsupport_preexec { emulate -L zsh setopt extended_glob @@ -33,18 +40,5 @@ function omz_termsupport_preexec { title '$CMD' '%100>...>$LINE%<<' } -#Appears each time pwd is changed -function omz_termsupport_chpwd { - #Notify Terminal.app of current directory using undocumented OSC sequence - #found in OS X 10.10's /etc/bashrc - if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then - local PWD_URL="file://$HOSTNAME${PWD// /%20}" - printf '\e]7;%s\a' "$PWD_URL" - fi -} -#Fire it once so the pwd is set properly upon shell startup -omz_termsupport_chpwd - precmd_functions+=(omz_termsupport_precmd) preexec_functions+=(omz_termsupport_preexec) -chpwd_functions+=(omz_termsupport_chpwd) From e60458793ab9703bb65adb6c326f43c6bd5fd126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 17 Dec 2014 11:11:53 +0100 Subject: [PATCH 07/46] Switch newer-than logic to get the desired behavior In the old version, the function returned true (0) if the cache file was newer than the Cakefile, which was *always* unless the Cakefile had been updated. Therefore we generated the file every time unless the Cakefile was updated, which was precisely when we needed to regenerate the cache file. Now it generates the cache file only when the Cakefile has been updated. --- plugins/cake/cake.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cake/cake.plugin.zsh b/plugins/cake/cake.plugin.zsh index 44cc47470..2370df949 100644 --- a/plugins/cake/cake.plugin.zsh +++ b/plugins/cake/cake.plugin.zsh @@ -15,7 +15,7 @@ _cake_does_target_list_need_generating () { fi [ ! -f ${_cake_task_cache_file} ] && return 0; - [ ${_cake_task_cache_file} -nt Cakefile ] && return 0; + [ Cakefile -nt ${_cake_task_cache_file} ] && return 0; return 1; } From 8ccfc3d444a36905003397083ac5ece46eda2a3b Mon Sep 17 00:00:00 2001 From: Michael Robinson Date: Fri, 9 Jan 2015 08:33:51 +1300 Subject: [PATCH 08/46] Removing 'local' usage to prevent issue when installed with antigen Error encountered when installed with antigen: "chpwd:2: no such file or directory:". Solution described in https://github.com/zsh-users/antigen/issues/75 --- plugins/last-working-dir/last-working-dir.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index e472578b0..4fa6fcc34 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -5,7 +5,7 @@ # Flag indicating if we've previously jumped to last directory. typeset -g ZSH_LAST_WORKING_DIRECTORY mkdir -p $ZSH_CACHE_DIR -local cache_file="$ZSH_CACHE_DIR/last-working-dir" +cache_file="$ZSH_CACHE_DIR/last-working-dir" # Updates the last directory once directory is changed. function chpwd() { From be7028012ecc97bf8976d5de0aed51869720be2a Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Wed, 4 Feb 2015 01:00:51 -0500 Subject: [PATCH 09/46] Reword comments on termsupport internal functions. --- lib/termsupport.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index ce36f229f..bd0cf6ffe 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -16,7 +16,7 @@ function title { ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" -# Runs when you have the prompt +# Runs before showing the prompt function omz_termsupport_precmd { title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE @@ -28,7 +28,7 @@ function omz_termsupport_precmd { fi } -# Runs at the beginning of (and during) of command execution +# Runs before executing the command function omz_termsupport_preexec { emulate -L zsh setopt extended_glob From 7de44dbdb767e52e509010b1468126259e0b8b87 Mon Sep 17 00:00:00 2001 From: Gabor Marton Date: Wed, 4 Feb 2015 12:56:58 +0100 Subject: [PATCH 10/46] Added trapwinch to vi-mode plugin. --- plugins/vi-mode/vi-mode.plugin.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 3ed32b3fb..f2745b409 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -14,6 +14,14 @@ function zle-keymap-select zle-line-init zle-line-finish { zle -R } +# Ensure that the prompt is redrawn when the terminal size changes. +TRAPWINCH() { + if [[ -o zle ]]; then + zle reset-prompt + zle -R + fi +} + zle -N zle-line-init zle -N zle-line-finish zle -N zle-keymap-select From 7f636ba5901b1abe9bb01d94b9e290bed982a873 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 17 Nov 2014 20:38:22 -0800 Subject: [PATCH 11/46] Backwards logic in newer check. Regen .ant_targets only if it's newer than build.xml? Yeah, that seems wrong. --- plugins/ant/ant.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh index 45f2b06eb..38d13f2a8 100644 --- a/plugins/ant/ant.plugin.zsh +++ b/plugins/ant/ant.plugin.zsh @@ -1,6 +1,6 @@ _ant_does_target_list_need_generating () { [ ! -f .ant_targets ] && return 0; - [ .ant_targets -nt build.xml ] && return 0; + [ build.xml -nt .ant_targets ] && return 0; return 1; } From 013b2bffcf11d0bc3ff29c96a8e6846166639c2c Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 17 Nov 2014 20:43:19 -0800 Subject: [PATCH 12/46] Change ant target enumeration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make use of ant's project help feature instead of trying to parse XML with regex (see: http://stackoverflow.com/a/1732454/740787). This is a behavioral change that does a few things: • adds support for ant imports, which were previously not recognized as possibly containing targets • supresses targets with no description, as these are conventionally for internal use only --- plugins/ant/ant.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh index 38d13f2a8..a945967d5 100644 --- a/plugins/ant/ant.plugin.zsh +++ b/plugins/ant/ant.plugin.zsh @@ -7,7 +7,7 @@ _ant_does_target_list_need_generating () { _ant () { if [ -f build.xml ]; then if _ant_does_target_list_need_generating; then - sed -n '/ .ant_targets + ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets fi compadd `cat .ant_targets` fi From 349493a0b81ae98117ea1a115a92ba509476298f Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 9 Feb 2015 12:43:51 -0800 Subject: [PATCH 13/46] Fix for ant targets with leading dash As suggested in https://github.com/robbyrussell/oh-my-zsh/pull/3329#issuecomment-72062236 --- plugins/ant/ant.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh index a945967d5..0b738c94f 100644 --- a/plugins/ant/ant.plugin.zsh +++ b/plugins/ant/ant.plugin.zsh @@ -9,7 +9,7 @@ _ant () { if _ant_does_target_list_need_generating; then ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets fi - compadd `cat .ant_targets` + compadd -- `cat .ant_targets` fi } From 5fe22fcbc6364aaacce373d71fa7d6b6f2d11a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 16 Dec 2014 00:43:01 +0100 Subject: [PATCH 14/46] Clean up and fix +1/-0 syntax to work as expected This change follows this proposed behaviour: Ctrl+Shift+Left: move to last visited directory Ctrl+Shift+Right: move to next visited directory an alternative behaviour would be: Ctrl+Shift+Left: move directory to the left in `dirs` output Ctrl+Shift+Right: move directory to the right in `dirs` output It also introduces `setopt nopushdminus` as a way to standardise pushd syntax. It's value wasn't clear before, which has been the cause of so many pull requests regarding this plugin not working in some environments. --- plugins/dircycle/dircycle.plugin.zsh | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index c6b6ba785..2064af46a 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -1,10 +1,27 @@ -## -# dircycle plugin: enables cycling through the directory -# stack using Ctrl+Shift+Left/Right +# enables cycling through the directory stack using +# Ctrl+Shift+Left/Right +# +# left/right direction follows the order in which directories +# were visited, like left/right arrows do in a browser -eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }" +# NO_PUSHD_MINUS syntax: +# pushd +N: start counting from left of `dirs' output +# pushd -N: start counting from right of `dirs' output +setopt nopushdminus + +insert-cycledleft () { + zle push-line + LBUFFER='pushd -q +1' + zle accept-line +} zle -N insert-cycledleft -bindkey "\e[1;6D" insert-cycledleft -eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }" + +insert-cycledright () { + zle push-line + LBUFFER='pushd -q -0' + zle accept-line +} zle -N insert-cycledright + +bindkey "\e[1;6D" insert-cycledleft bindkey "\e[1;6C" insert-cycledright From e93fd939adb69a498ba1296b1ce0c99786e26084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 16 Dec 2014 01:29:06 +0100 Subject: [PATCH 15/46] Run pushd command directly and trigger prompt redraw --- plugins/dircycle/dircycle.plugin.zsh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index 2064af46a..1c4a0175a 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -10,16 +10,14 @@ setopt nopushdminus insert-cycledleft () { - zle push-line - LBUFFER='pushd -q +1' - zle accept-line + builtin pushd -q +1 &>/dev/null || true + zle reset-prompt } zle -N insert-cycledleft insert-cycledright () { - zle push-line - LBUFFER='pushd -q -0' - zle accept-line + builtin pushd -q -0 &>/dev/null || true + zle reset-prompt } zle -N insert-cycledright From 999bab187c0a59301f4055fb6239a5352d3c96ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 20 Dec 2014 20:35:52 +0100 Subject: [PATCH 16/46] Emulate zsh in zlewidgets instead of static setopt command This way the user can keep their preferred pushd syntax while enabling us to use a standard syntax in our defined functions. To explain further, without a clear value on the PUSHD_MINUS option, we could be changing the +1/-0 values all we want, that some user would find that it didn't work for him. We have two options, then: - Setting a particular value, which was my first approach. - Using `emulate -L zsh` to ensure all options defined in the function's body won't be passed along to the main zsh instance. For more info see: http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html#index-emulate --- plugins/dircycle/dircycle.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index 1c4a0175a..12b20ab04 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -7,15 +7,20 @@ # NO_PUSHD_MINUS syntax: # pushd +N: start counting from left of `dirs' output # pushd -N: start counting from right of `dirs' output -setopt nopushdminus insert-cycledleft () { + emulate -L zsh + setopt nopushdminus + builtin pushd -q +1 &>/dev/null || true zle reset-prompt } zle -N insert-cycledleft insert-cycledright () { + emulate -L zsh + setopt nopushdminus + builtin pushd -q -0 &>/dev/null || true zle reset-prompt } From 282240bf37d6fd9979da2c3a41006824dbb4e268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 24 Dec 2014 01:33:28 +0100 Subject: [PATCH 17/46] Account for iTerm2 sent keys in dircycle plugin --- plugins/dircycle/dircycle.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index 12b20ab04..1e31105b1 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -26,5 +26,12 @@ insert-cycledright () { } zle -N insert-cycledright -bindkey "\e[1;6D" insert-cycledleft -bindkey "\e[1;6C" insert-cycledright + +# add key bindings for iTerm2 +if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then + bindkey "^[[1;6D" insert-cycledleft + bindkey "^[[1;6C" insert-cycledright +else + bindkey "\e[1;6D" insert-cycledleft + bindkey "\e[1;6C" insert-cycledright +fi \ No newline at end of file From 25b1cd687b28cb8d05229130ee5a0e2494276894 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Fri, 10 Jan 2014 23:32:20 +0100 Subject: [PATCH 18/46] Brings all directory stuff to directories.zsh - Cleans out aliases.zsh. - Removes unneeded cd function. --- lib/aliases.zsh | 13 ------------- lib/directories.zsh | 38 +++++++++++++++----------------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/lib/aliases.zsh b/lib/aliases.zsh index aae865046..c67f854a7 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -1,11 +1,3 @@ -# Push and pop directories on directory stack -alias pu='pushd' -alias po='popd' - -# Basic directory operations -alias ...='cd ../..' -alias -- -='cd -' - # Super user alias _='sudo' alias please='sudo' @@ -25,11 +17,6 @@ then else alias history='fc -l 1' fi -# List direcory contents -alias lsa='ls -lah' -alias l='ls -lah' -alias ll='ls -lh' -alias la='ls -lAh' alias afind='ack-grep -il' diff --git a/lib/directories.zsh b/lib/directories.zsh index 02743e0c7..1693d5dd1 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -3,12 +3,10 @@ setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus -alias ..='cd ..' -alias cd..='cd ..' -alias cd...='cd ../..' -alias cd....='cd ../../..' -alias cd.....='cd ../../../..' -alias cd/='cd /' +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' +alias -g ......='../../../../..' alias 1='cd -' alias 2='cd -2' @@ -20,23 +18,17 @@ alias 7='cd -7' alias 8='cd -8' alias 9='cd -9' -cd () { - if [[ "x$*" == "x..." ]]; then - cd ../.. - elif [[ "x$*" == "x...." ]]; then - cd ../../.. - elif [[ "x$*" == "x....." ]]; then - cd ../../../.. - elif [[ "x$*" == "x......" ]]; then - cd ../../../../.. - elif [ -d ~/.autoenv ]; then - source ~/.autoenv/activate.sh - autoenv_cd "$@" - else - builtin cd "$@" - fi -} - alias md='mkdir -p' alias rd=rmdir alias d='dirs -v | head -10' + +# List direcory contents +alias lsa='ls -lah' +alias l='ls -la' +alias ll='ls -l' +alias la='ls -lA' +alias sl=ls # often screw this up + +# Push and pop directories on directory stack +alias pu='pushd' +alias po='popd' From ace98846eac9726f7161617291e1fd2affc3f4eb Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Fri, 10 Jan 2014 23:40:22 +0100 Subject: [PATCH 19/46] Pushes autoenv code to its plugin. Sources the activate.sh file or informs the user, that its not available. Overriding the cd function, as it was formerly done, is not needed anymore, activate.sh does this by itself. --- plugins/autoenv/autoenv.plugin.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index ca5666979..a8271849e 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,6 +1,17 @@ +# Activates autoenv or reports its failure +if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then + echo '-------- AUTOENV ---------' + echo 'Could not find ~/.autoenv/activate.sh.' + echo 'Please check if autoenv is correctly installed.' + echo 'In the meantime the autoenv plugin is DISABLED.' + echo '--------------------------' + return 1 +fi + # The use_env call below is a reusable command to activate/create a new Python # virtualenv, requiring only a single declarative line of code in your .env files. # It only performs an action if the requested virtualenv is not the current one. + use_env() { typeset venv venv="$1" From d33b0aae917c62012bf203538ba86d6236869834 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Fri, 10 Jan 2014 23:50:19 +0100 Subject: [PATCH 20/46] Refactors history alias and moves it. More compact case statement instead of the ugly if elif... else statement. Moves it to history.zsh --- lib/aliases.zsh | 14 -------------- lib/history.zsh | 9 +++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/aliases.zsh b/lib/aliases.zsh index c67f854a7..da29fde58 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -4,19 +4,5 @@ alias please='sudo' #alias g='grep -in' -# Show history -if [ "$HIST_STAMPS" = "mm/dd/yyyy" ] -then - alias history='fc -fl 1' -elif [ "$HIST_STAMPS" = "dd.mm.yyyy" ] -then - alias history='fc -El 1' -elif [ "$HIST_STAMPS" = "yyyy-mm-dd" ] -then - alias history='fc -il 1' -else - alias history='fc -l 1' -fi - alias afind='ack-grep -il' diff --git a/lib/history.zsh b/lib/history.zsh index e78a98e9e..5de71c2d3 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -6,6 +6,15 @@ fi HISTSIZE=10000 SAVEHIST=10000 +# Show history +case $HIST_STAMPS in + "mm/dd/yyyy") alias history='fc -fl 1' ;; + "dd.mm.yyyy") alias history='fc -El 1' ;; + "yyyy-mm-dd") alias history='fc -il 1' ;; + *) alias history='fc -l 1' ;; +esac + +setopt append_history setopt extended_history setopt hist_expire_dups_first setopt hist_ignore_dups # ignore duplication command history list From 101149b1ae6fb5ce0b982289fca901b2feab5439 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Fri, 10 Jan 2014 23:53:14 +0100 Subject: [PATCH 21/46] Moves remaining aliases to misc and deletes file. There were only three aliases left in aliases.zsh File deleted! --- lib/aliases.zsh | 8 -------- lib/misc.zsh | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 lib/aliases.zsh diff --git a/lib/aliases.zsh b/lib/aliases.zsh deleted file mode 100644 index da29fde58..000000000 --- a/lib/aliases.zsh +++ /dev/null @@ -1,8 +0,0 @@ -# Super user -alias _='sudo' -alias please='sudo' - -#alias g='grep -in' - -alias afind='ack-grep -il' - diff --git a/lib/misc.zsh b/lib/misc.zsh index a8678b8ec..892d78ef3 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -13,3 +13,10 @@ export PAGER="less" export LESS="-R" export LC_CTYPE=$LANG + +## super user alias +alias _='sudo' +alias please='sudo' + +## more intelligent acking for ubuntu users +alias afind='ack-grep -il' From 83c4e0620689d2410056bddcdfbf8e300673e982 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Fri, 10 Jan 2014 23:55:10 +0100 Subject: [PATCH 22/46] Moves a bindkey call from misc to key-bindings. --- lib/key-bindings.zsh | 3 +++ lib/misc.zsh | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 9063c6a18..eb2b58058 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -64,6 +64,9 @@ autoload -U edit-command-line zle -N edit-command-line bindkey '\C-x\C-e' edit-command-line +# file rename magick +bindkey "^[m" copy-prev-shell-word + # consider emacs keybindings: #bindkey -e ## emacs key bindings diff --git a/lib/misc.zsh b/lib/misc.zsh index 892d78ef3..ea8a05fcb 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -2,9 +2,6 @@ autoload -U url-quote-magic zle -N self-insert url-quote-magic -## file rename magick -bindkey "^[m" copy-prev-shell-word - ## jobs setopt long_list_jobs From 724143c3297249961977a957d8fa1bc92cd7be2c Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Sat, 11 Jan 2014 00:04:53 +0100 Subject: [PATCH 23/46] Deletes dot aliases from common-aliases. They are implemented in lib anyway. --- plugins/common-aliases/common-aliases.plugin.zsh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 90d59910c..e3830adcf 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -20,12 +20,6 @@ alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' alias t='tail -f' -# because typing 'cd' is A LOT of work!! -alias ..='cd ../' -alias ...='cd ../../' -alias ....='cd ../../../' -alias .....='cd ../../../../' - # Command line head / tail shortcuts alias -g H='| head' alias -g T='| tail' From 4b4292a496c139039807f082425cc5507f762c0d Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Sat, 15 Mar 2014 00:00:14 +0100 Subject: [PATCH 24/46] Fix a typo --- lib/directories.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index 1693d5dd1..b7a53ecfe 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -22,7 +22,7 @@ alias md='mkdir -p' alias rd=rmdir alias d='dirs -v | head -10' -# List direcory contents +# List directory contents alias lsa='ls -lah' alias l='ls -la' alias ll='ls -l' From 51946eb3ce8021aebe940f879225828d89c12317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 9 Feb 2015 20:29:10 +0100 Subject: [PATCH 25/46] Implement deletion of sl alias as per #3055 --- lib/directories.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/directories.zsh b/lib/directories.zsh index b7a53ecfe..1a9698544 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -27,7 +27,6 @@ alias lsa='ls -lah' alias l='ls -la' alias ll='ls -l' alias la='ls -lA' -alias sl=ls # often screw this up # Push and pop directories on directory stack alias pu='pushd' From 2193135ebc4ce0778ff6949b448e4526dbd34284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 9 Feb 2015 20:43:48 +0100 Subject: [PATCH 26/46] Clean up appearance lib file and redundant `colors` calls in other files --- lib/theme-and-appearance.zsh | 8 +++----- plugins/git-prompt/git-prompt.plugin.zsh | 3 --- plugins/jump/jump.plugin.zsh | 1 - themes/adben.zsh-theme | 15 ++++++--------- themes/apple.zsh-theme | 1 - themes/gnzh.zsh-theme | 3 +-- themes/half-life.zsh-theme | 2 -- themes/jonathan.zsh-theme | 5 +---- themes/kolo.zsh-theme | 2 -- themes/mikeh.zsh-theme | 2 -- themes/simonoff.zsh-theme | 5 +---- themes/steeef.zsh-theme | 2 -- themes/zhann.zsh-theme | 2 -- 13 files changed, 12 insertions(+), 39 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 0353f9db4..926303ca4 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,14 +1,13 @@ # ls colors -autoload colors; colors; +autoload -U colors && colors export LSCOLORS="Gxfxcxdxbxegedabagacad" -#export LS_COLORS # Enable ls colors if [ "$DISABLE_LS_COLORS" != "true" ] then # Find the option for using colors in ls, depending on the version: Linux or BSD if [[ "$(uname -s)" == "NetBSD" ]]; then - # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); + # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then @@ -23,7 +22,7 @@ fi #setopt no_beep setopt auto_cd setopt multios -setopt cdablevarS +setopt cdablevars if [[ x$WINDOW != x ]] then @@ -43,4 +42,3 @@ ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is c # Setup the prompt with pretty colors setopt prompt_subst - diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 01b8a88d9..d868a5fe1 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -2,9 +2,6 @@ # http://github.com/olivierverdier/zsh-git-prompt # export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt -# Initialize colors. -autoload -U colors -colors # Allow for functions in the prompt. setopt PROMPT_SUBST diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index b16814fe4..d082c11e5 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -27,7 +27,6 @@ unmark() { rm -i "$MARKPATH/$1" } -autoload colors marks() { for link in $MARKPATH/*(@); do local markname="$fg[cyan]${link:t}$reset_color" diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme index 6869c8a20..212b823a5 100644 --- a/themes/adben.zsh-theme +++ b/themes/adben.zsh-theme @@ -69,17 +69,17 @@ function precmd { #Choose from all databases, regardless of whether they are considered "offensive" fortune -a } - #obtains the tip + #obtains the tip ps1_command_tip () { wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d' - } + } prompt_header () { if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then ps1_command_tip else ps1_fortune - fi - } + fi + } PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}" # set a simple variable to show when in screen if [[ -n "${WINDOW}" ]]; then @@ -99,11 +99,8 @@ prompt_context () { set_prompt () { # required for the prompt setopt prompt_subst - autoload colors zsh/terminfo - if [[ "$terminfo[colors]" -gt 8 ]]; then - colors - fi - + autoload zsh/terminfo + # ######### PROMPT ######### PROMPT='${PROMPT_HEAD} ${RED_START}$(prompt_context) diff --git a/themes/apple.zsh-theme b/themes/apple.zsh-theme index 275341dc6..95e6249fa 100644 --- a/themes/apple.zsh-theme +++ b/themes/apple.zsh-theme @@ -7,7 +7,6 @@ get_git_dirty() { } autoload -Uz vcs_info -autoload -U colors && colors zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme index 0519fbefb..ab154c1e5 100644 --- a/themes/gnzh.zsh-theme +++ b/themes/gnzh.zsh-theme @@ -2,8 +2,7 @@ # Based on bira theme # load some modules -autoload -U colors zsh/terminfo # Used in the colour alias below -colors +autoload -U zsh/terminfo # Used in the colour alias below setopt prompt_subst # make some aliases for the colours: (could use normal escape sequences too) diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme index 942affa94..a3c505706 100644 --- a/themes/half-life.zsh-theme +++ b/themes/half-life.zsh-theme @@ -13,8 +13,6 @@ function virtualenv_info { PR_GIT_UPDATE=1 setopt prompt_subst -autoload colors -colors autoload -U add-zsh-hook autoload -Uz vcs_info diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index bca92970c..2f0e77431 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -44,10 +44,7 @@ setprompt () { ### # See if we can use colors. - autoload colors zsh/terminfo - if [[ "$terminfo[colors]" -ge 8 ]]; then - colors - fi + autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' diff --git a/themes/kolo.zsh-theme b/themes/kolo.zsh-theme index e743289c3..51b0af724 100644 --- a/themes/kolo.zsh-theme +++ b/themes/kolo.zsh-theme @@ -1,5 +1,3 @@ -autoload -U colors && colors - autoload -Uz vcs_info zstyle ':vcs_info:*' stagedstr '%F{green}●' diff --git a/themes/mikeh.zsh-theme b/themes/mikeh.zsh-theme index 943f04d38..a95383ba5 100644 --- a/themes/mikeh.zsh-theme +++ b/themes/mikeh.zsh-theme @@ -1,6 +1,4 @@ setopt prompt_subst -autoload colors -colors autoload -U add-zsh-hook autoload -Uz vcs_info diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index fb4d32e24..63ce4261b 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -63,10 +63,7 @@ setprompt () { ### # See if we can use colors. - autoload colors zsh/terminfo - if [[ "$terminfo[colors]" -ge 8 ]]; then - colors - fi + autoload zsh/terminfo for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme index e38188d35..13728ca9a 100644 --- a/themes/steeef.zsh-theme +++ b/themes/steeef.zsh-theme @@ -15,8 +15,6 @@ function virtualenv_info { PR_GIT_UPDATE=1 setopt prompt_subst -autoload colors -colors autoload -U add-zsh-hook autoload -Uz vcs_info diff --git a/themes/zhann.zsh-theme b/themes/zhann.zsh-theme index 5c0854730..27597ec6c 100644 --- a/themes/zhann.zsh-theme +++ b/themes/zhann.zsh-theme @@ -1,5 +1,3 @@ -autoload -U colors && colors - autoload -Uz vcs_info zstyle ':vcs_info:*' stagedstr '%F{green}●' From 80d856e1655cc2b2e9d6899bae884631283a8063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 26 Dec 2014 22:33:36 +0100 Subject: [PATCH 27/46] Clean up web-search plugin logic to allow easier changes --- plugins/web-search/web-search.plugin.zsh | 55 ++++++++++++------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 28559deb9..1e661250a 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -1,42 +1,43 @@ # web_search from terminal function web_search() { - # get the open command - local open_cmd - if [[ "$OSTYPE" = darwin* ]]; then - open_cmd='open' - else - open_cmd='xdg-open' - fi + emulate -L zsh + + # define search engine URLS + typeset -A urls + urls=( + google "https://www.google.com/search?q=" + bing "https://www.bing.com/search?q=" + yahoo "https://www.yahoo.com/search?q=" + duckduckgo "https://www.duckduckgo.com/?q=" + ) + + # define the open command + case "$OSTYPE" in + darwin*) open_cmd="open" ;; + linux*) open_cmd="xdg-open" ;; + *) echo "Platform $OSTYPE not supported" + return 1 + ;; + esac # check whether the search engine is supported - if [[ ! $1 =~ '(google|bing|yahoo|duckduckgo)' ]]; - then + if [[ -z "$urls[$1]" ]]; then echo "Search engine $1 not supported." return 1 fi - local url="http://www.$1.com" - - # no keyword provided, simply open the search engine homepage - if [[ $# -le 1 ]]; then - $open_cmd "$url" - return - fi - if [[ $1 == 'duckduckgo' ]]; then - #slightly different search syntax for DDG - url="${url}/?q=" + # search or go to main page depending on number of arguments passed + if [[ $# -gt 1 ]]; then + # build search url: + # join arguments passed with '+', then append to search engine URL + url="${urls[$1]}${(j:+:)@[2,-1]}" else - url="${url}/search?q=" + # build main page url: + # split by '/', then rejoin protocol (1) and domain (2) parts with '//' + url="${(j://:)${(s:/:)urls[$1]}[1,2]}" fi - shift # shift out $1 - while [[ $# -gt 0 ]]; do - url="${url}$1+" - shift - done - - url="${url%?}" # remove the last '+' nohup $open_cmd "$url" >/dev/null 2&>1 } From 80ba54a94fe7d7628d159823d5c63e12811c68b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 27 Dec 2014 02:27:24 +0100 Subject: [PATCH 28/46] Add Yandex support to web-search plugin --- plugins/web-search/web-search.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 1e661250a..5e3c00d3c 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -10,6 +10,7 @@ function web_search() { bing "https://www.bing.com/search?q=" yahoo "https://www.yahoo.com/search?q=" duckduckgo "https://www.duckduckgo.com/?q=" + yandex "http://yandex.ru/yandsearch?text=" ) # define the open command @@ -46,6 +47,8 @@ alias bing='web_search bing' alias google='web_search google' alias yahoo='web_search yahoo' alias ddg='web_search duckduckgo' +alias yandex='web_search yandex' + #add your own !bang searches here alias wiki='web_search duckduckgo \!w' alias news='web_search duckduckgo \!n' From adaea31ca013054094a45b009ab22382c4d94666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 27 Dec 2014 02:30:16 +0100 Subject: [PATCH 29/46] Silence nohup output in web-search plugin --- plugins/web-search/web-search.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 5e3c00d3c..19f9cad33 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -39,7 +39,7 @@ function web_search() { url="${(j://:)${(s:/:)urls[$1]}[1,2]}" fi - nohup $open_cmd "$url" >/dev/null 2&>1 + nohup $open_cmd "$url" &>/dev/null } From c45885093fd8fa3375286ef1dcba9bc296e08a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 27 Dec 2014 02:56:30 +0100 Subject: [PATCH 30/46] Add support for cygwin open in web-search plugin --- plugins/web-search/web-search.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 19f9cad33..52d03b2d0 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -16,6 +16,7 @@ function web_search() { # define the open command case "$OSTYPE" in darwin*) open_cmd="open" ;; + cygwin*) open_cmd="cygstart" ;; linux*) open_cmd="xdg-open" ;; *) echo "Platform $OSTYPE not supported" return 1 From e8daf8150e923bfd30769e9a55c15daec523996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 27 Dec 2014 03:15:56 +0100 Subject: [PATCH 31/46] Fix yahoo search URL in web-search plugin --- plugins/web-search/web-search.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 52d03b2d0..b0a4a2926 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -8,7 +8,7 @@ function web_search() { urls=( google "https://www.google.com/search?q=" bing "https://www.bing.com/search?q=" - yahoo "https://www.yahoo.com/search?q=" + yahoo "https://search.yahoo.com/search?p=" duckduckgo "https://www.duckduckgo.com/?q=" yandex "http://yandex.ru/yandsearch?text=" ) From 02d75684f3ddd2dcd181c9265545d5639d09bd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 4 Jan 2015 01:40:25 +0100 Subject: [PATCH 32/46] Force using https in Yandex search engine --- plugins/web-search/web-search.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index b0a4a2926..572427b0b 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -10,7 +10,7 @@ function web_search() { bing "https://www.bing.com/search?q=" yahoo "https://search.yahoo.com/search?p=" duckduckgo "https://www.duckduckgo.com/?q=" - yandex "http://yandex.ru/yandsearch?text=" + yandex "https://yandex.ru/yandsearch?text=" ) # define the open command From 0cc3afe27788e35d5f72236f41a7e4514c11491d Mon Sep 17 00:00:00 2001 From: Julien Pepy Date: Fri, 5 Dec 2014 09:57:59 +0100 Subject: [PATCH 33/46] Fix get command list for recent composer versions --- plugins/composer/composer.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 86f2ca4df..f75119c4a 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -7,7 +7,7 @@ # Composer basic command completion _composer_get_command_list () { - composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + composer --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' } _composer_get_required_list () { From 5f4e8e57da117b5fc2325ea411aafc66053b8570 Mon Sep 17 00:00:00 2001 From: Andrey Janzen Date: Fri, 26 Jul 2013 00:37:11 +0700 Subject: [PATCH 34/46] Allow completion for 'composer.phar', not only 'composer' Use $_comp_command1 for command list generation instead of 'composer': `$_comp_command1` contains the command written in the command line. This allows us to have a different composer name --- plugins/composer/composer.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index f75119c4a..324bc64a0 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -7,11 +7,11 @@ # Composer basic command completion _composer_get_command_list () { - composer --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' + $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' } _composer_get_required_list () { - composer show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' + $_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' } _composer () { @@ -35,6 +35,7 @@ _composer () { } compdef _composer composer +compdef _composer composer.phar # Aliases alias c='composer' From ef220f0928269f3cdb613db3d3f9ba7775317109 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Sat, 17 Aug 2013 17:11:21 +0200 Subject: [PATCH 35/46] Add aliases for composer global --- plugins/composer/composer.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 324bc64a0..97207242a 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -41,9 +41,12 @@ compdef _composer composer.phar alias c='composer' alias csu='composer self-update' alias cu='composer update' +alias cr='composer require' alias ci='composer install' alias ccp='composer create-project' alias cdu='composer dump-autoload' +alias cgu='composer global update' +alias cgr='composer global require' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' From 6fb866183d84e53fa009853691e5c0bdd101820b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 4 Jan 2015 22:24:55 +0100 Subject: [PATCH 36/46] Remove composer.json file requirement This is because we can't be sure which arguments require a json file and which don't, so the `else' statement will always be difficult to check for correctness. --- plugins/composer/composer.plugin.zsh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 97207242a..7f70e3d72 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -20,18 +20,15 @@ _composer () { _arguments \ '1: :->command'\ '*: :->args' - if [ -f composer.json ]; then - case $state in - command) - compadd `_composer_get_command_list` - ;; - *) - compadd `_composer_get_required_list` - ;; - esac - else - compadd create-project init search selfupdate show - fi + + case $state in + command) + compadd $(_composer_get_command_list) + ;; + *) + compadd $(_composer_get_required_list) + ;; + esac } compdef _composer composer From c3940cf44a58393906e896decc93542c3ab17f4a Mon Sep 17 00:00:00 2001 From: Martin Schrodi Date: Fri, 14 Mar 2014 11:52:40 +0100 Subject: [PATCH 37/46] Fixed breakage in new git repo without commits --- themes/rkj-repos.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme index eed084f15..0a9f83d36 100644 --- a/themes/rkj-repos.zsh-theme +++ b/themes/rkj-repos.zsh-theme @@ -19,7 +19,8 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈" function mygit() { ref1=$(git symbolic-ref HEAD 2> /dev/null) || return - ref2=$(git rev-parse HEAD | head -c 6) || return + gitdir=$(git rev-parse --git-dir 2> /dev/null) || return + heads=($gitdir/refs/heads/*(N)) ; [[ -z $heads ]] && ref2="" || ref2=$(git rev-parse HEAD | head -c 6) ref="$ref1 %{$fg[grey]%}$ref2" #ref=$(git symbolic-ref HEAD 2> /dev/null) $(git rev-parse HEAD | head -c 6) || return echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX " From f04246aa4820031c025ed25baf0df23d786d38fd Mon Sep 17 00:00:00 2001 From: Martin Schrodi Date: Sat, 19 Apr 2014 03:04:58 +0200 Subject: [PATCH 38/46] rkj-repos: code cleanup and updated with functions from lib/git.zsh (thx mcornella) --- themes/rkj-repos.zsh-theme | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme index 0a9f83d36..8585e66be 100644 --- a/themes/rkj-repos.zsh-theme +++ b/themes/rkj-repos.zsh-theme @@ -16,14 +16,15 @@ ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✗" ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}➦" ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}✂" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈" +ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$fg[grey]%}" +ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}" function mygit() { - ref1=$(git symbolic-ref HEAD 2> /dev/null) || return - gitdir=$(git rev-parse --git-dir 2> /dev/null) || return - heads=($gitdir/refs/heads/*(N)) ; [[ -z $heads ]] && ref2="" || ref2=$(git rev-parse HEAD | head -c 6) - ref="$ref1 %{$fg[grey]%}$ref2" - #ref=$(git symbolic-ref HEAD 2> /dev/null) $(git rev-parse HEAD | head -c 6) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX " + if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_short_sha)$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX " + fi } function retcode() {} From 4fc6dccb4286828c7cd53d3612ec69b0c0d9aaf2 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 20 Dec 2014 02:24:26 -0500 Subject: [PATCH 39/46] term: Move DISABLE_AUTO_TITLE check to hooks Move the DISABLE_AUTO_TITLE check from title() to the preX hook functions that call it, to allow the title() function to be used directly by user or other callers. --- lib/termsupport.zsh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index bd0cf6ffe..2fa61c431 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -1,8 +1,16 @@ -#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title -#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 -#Fully support screen, iterm, and probably most modern xterm and rxvt +# Set terminal window and tab/icon title +# +# usage: title short_tab_title [long_window_title] +# +# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 +# Fully supports screen, iterm, and probably most modern xterm and rxvt +# (In screen, only short_tab_title is used) +# Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { - if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then + if [[ $2 == "" ]]; then + 2="$1" + fi + if [[ "$EMACS" == *term* ]]; then return fi if [[ "$TERM" == screen* ]]; then @@ -18,6 +26,10 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" # Runs before showing the prompt function omz_termsupport_precmd { + if [[ $DISABLE_AUTO_TITLE == true ]]; then + return + fi + title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE # Notify Terminal.app of current directory using undocumented OSC sequence @@ -30,6 +42,10 @@ function omz_termsupport_precmd { # Runs before executing the command function omz_termsupport_preexec { + if [[ $DISABLE_AUTO_TITLE == true ]]; then + return + fi + emulate -L zsh setopt extended_glob From b7e5dd35efb0750634eb16b7040337ce80f67684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 19:43:25 +0100 Subject: [PATCH 40/46] Quick-fix code style --- lib/termsupport.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 2fa61c431..f21b0b041 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -7,12 +7,12 @@ # (In screen, only short_tab_title is used) # Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { - if [[ $2 == "" ]]; then - 2="$1" - fi - if [[ "$EMACS" == *term* ]]; then - return - fi + [[ "$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 From 2e41d06b7655067272cee1e54d2d66693136a90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 19:53:40 +0100 Subject: [PATCH 41/46] Use quoted $TERM value everywhere --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index f21b0b041..58c6203a0 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -15,7 +15,7 @@ function title { 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 + 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 From 4161aa4f9de45233bdee7073933498422a50d213 Mon Sep 17 00:00:00 2001 From: Brandon Sandrowicz Date: Tue, 20 May 2014 09:41:36 -0400 Subject: [PATCH 42/46] Fixing virtualenvwrapper plugin for Ubuntu (and Debian) Ubuntu and Debian store the system-installed virtualenvwrapper in /etc/bash_completion.d/virtualenvwrapper, so that it gets automatically sourced at startup in Bash. By not putting it somewhere in $PATH, they end up excluding others (e.g. Zsh) that might want to use that file. Oops! The virtualenvwrapper plugin should account for this so that Ubuntu (or Debian) users don't end up with this message: zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh. Please install with `pip install virtualenvwrapper`. even when they have a virtualenvwrapper installed to a known location. --- .../virtualenvwrapper/virtualenvwrapper.plugin.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 217ab0722..9a0616b72 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,12 +1,19 @@ virtualenvwrapper='virtualenvwrapper.sh' + if (( $+commands[$virtualenvwrapper] )); then - source ${${virtualenvwrapper}:c} +elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then + virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper" + source "/etc/bash_completion.d/virtualenvwrapper" +else + print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`." + return +fi +if type workon 2>&1 >/dev/null; then if [[ "$WORKON_HOME" == "" ]]; then echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" else - if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then # Automatically activate Git projects's virtual environments based on the # directory name of the project. Virtual environment name can be overridden @@ -61,5 +68,5 @@ if (( $+commands[$virtualenvwrapper] )); then fi fi else - print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`." + print "zsh virtualenvwrapper plugin: shell function 'workon' not defined. Please check ${virtualenvwrapper}." >&2 fi From b62911660d3743d3dfb0116f5b05aabd67a24a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 12:20:24 +0100 Subject: [PATCH 43/46] Organize error checking in virtualenwrapper plugin --- .../virtualenvwrapper.plugin.zsh | 123 +++++++++--------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 9a0616b72..0ad336917 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -6,67 +6,70 @@ elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper" source "/etc/bash_completion.d/virtualenvwrapper" else - print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`." + print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\ + "Please install with \`pip install virtualenvwrapper\`" >&2 + return +fi +if ! type workon &>/dev/null; then + print "zsh virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ + "Please check ${virtualenvwrapper}" >&2 return fi -if type workon 2>&1 >/dev/null; then - if [[ "$WORKON_HOME" == "" ]]; then - echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" - else - if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then - # Automatically activate Git projects's virtual environments based on the - # directory name of the project. Virtual environment name can be overridden - # by placing a .venv file in the project root with a virtualenv name in it - function workon_cwd { - if [ ! $WORKON_CWD ]; then - WORKON_CWD=1 - # Check if this is a Git repo - PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` - if (( $? != 0 )); then - PROJECT_ROOT="." - fi - # Check for virtualenv name override - if [[ -f "$PROJECT_ROOT/.venv" ]]; then - ENV_NAME=`cat "$PROJECT_ROOT/.venv"` - elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then - ENV_NAME="$PROJECT_ROOT/.venv" - elif [[ "$PROJECT_ROOT" != "." ]]; then - ENV_NAME=`basename "$PROJECT_ROOT"` - else - ENV_NAME="" - fi - if [[ "$ENV_NAME" != "" ]]; then - # Activate the environment only if it is not already active - if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then - if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then - workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" - elif [[ -e "$ENV_NAME/bin/activate" ]]; then - source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" - fi - fi - elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then - # We've just left the repo, deactivate the environment - # Note: this only happens if the virtualenv was activated automatically - deactivate && unset CD_VIRTUAL_ENV - fi - unset PROJECT_ROOT - unset WORKON_CWD - fi - } - - # Append workon_cwd to the chpwd_functions array, so it will be called on cd - # http://zsh.sourceforge.net/Doc/Release/Functions.html - # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 - if (( ${+chpwd_functions} )); then - if (( $chpwd_functions[(I)workon_cwd] == 0 )); then - set -A chpwd_functions $chpwd_functions workon_cwd - fi - else - set -A chpwd_functions workon_cwd - fi - fi - fi -else - print "zsh virtualenvwrapper plugin: shell function 'workon' not defined. Please check ${virtualenvwrapper}." >&2 +if [[ "$WORKON_HOME" == "" ]]; then + print "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" >&2 + return +fi + +if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then + # Automatically activate Git projects's virtual environments based on the + # directory name of the project. Virtual environment name can be overridden + # by placing a .venv file in the project root with a virtualenv name in it + function workon_cwd { + if [ ! $WORKON_CWD ]; then + WORKON_CWD=1 + # Check if this is a Git repo + PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` + if (( $? != 0 )); then + PROJECT_ROOT="." + fi + # Check for virtualenv name override + if [[ -f "$PROJECT_ROOT/.venv" ]]; then + ENV_NAME=`cat "$PROJECT_ROOT/.venv"` + elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then + ENV_NAME="$PROJECT_ROOT/.venv" + elif [[ "$PROJECT_ROOT" != "." ]]; then + ENV_NAME=`basename "$PROJECT_ROOT"` + else + ENV_NAME="" + fi + if [[ "$ENV_NAME" != "" ]]; then + # Activate the environment only if it is not already active + if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then + workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + elif [[ -e "$ENV_NAME/bin/activate" ]]; then + source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" + fi + fi + elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV + fi + unset PROJECT_ROOT + unset WORKON_CWD + fi + } + + # Append workon_cwd to the chpwd_functions array, so it will be called on cd + # http://zsh.sourceforge.net/Doc/Release/Functions.html + # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 + if (( ${+chpwd_functions} )); then + if (( $chpwd_functions[(I)workon_cwd] == 0 )); then + set -A chpwd_functions $chpwd_functions workon_cwd + fi + else + set -A chpwd_functions workon_cwd + fi fi From 732c7b8070a75ac5ad5384b4d22d19f499e8424f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 12:24:05 +0100 Subject: [PATCH 44/46] Simplify adding workon_cwd to chpwd hook --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 0ad336917..5faa1a823 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -64,12 +64,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then # Append workon_cwd to the chpwd_functions array, so it will be called on cd # http://zsh.sourceforge.net/Doc/Release/Functions.html - # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 - if (( ${+chpwd_functions} )); then - if (( $chpwd_functions[(I)workon_cwd] == 0 )); then - set -A chpwd_functions $chpwd_functions workon_cwd - fi - else - set -A chpwd_functions workon_cwd + if ! (( $chpwd_functions[(I)workon_cwd] )); then + chpwd_functions+=(workon_cwd) fi fi From 448e966129bb5c08c7b2da4636491f0f890cf0ab Mon Sep 17 00:00:00 2001 From: frozen_dude Date: Mon, 29 Jul 2013 20:04:23 +0200 Subject: [PATCH 45/46] Fix for bad LC_CTYPE entry LANG is a colon-separated list of prefered locales; LC_CTYPE is single entry, therefore we need to remove all but one entry. Also, there is no need setting it if it is already set (LC_ALL also sets LC_CTYPE, so we check it too). --- lib/misc.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/misc.zsh b/lib/misc.zsh index ea8a05fcb..6987c099c 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -9,11 +9,21 @@ setopt long_list_jobs export PAGER="less" export LESS="-R" -export LC_CTYPE=$LANG - ## super user alias alias _='sudo' alias please='sudo' ## more intelligent acking for ubuntu users alias afind='ack-grep -il' + +## how to interpret text characters +if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then # only define if undefined + export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG + [[ -z "$LC_CTYPE" ]] && \ + export LC_CTYPE=`locale -a | grep en_US.utf8 | head -1` + [[ -z "$LC_CTYPE" ]] && \ + export LC_CTYPE=`locale -a | grep en_US | head -1` + [[ -z "$LC_CTYPE" ]] && \ + export LC_CTYPE=C # default to internal encoding. +fi + From 0edf416bea1a180e82a8f5f96444d74fabb5867f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 9 Feb 2015 18:57:23 +0100 Subject: [PATCH 46/46] Temporarily delete over-engineered solution --- lib/misc.zsh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/misc.zsh b/lib/misc.zsh index 6987c099c..0b7cb2696 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -16,14 +16,7 @@ alias please='sudo' ## more intelligent acking for ubuntu users alias afind='ack-grep -il' -## how to interpret text characters -if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then # only define if undefined - export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG - [[ -z "$LC_CTYPE" ]] && \ - export LC_CTYPE=`locale -a | grep en_US.utf8 | head -1` - [[ -z "$LC_CTYPE" ]] && \ - export LC_CTYPE=`locale -a | grep en_US | head -1` - [[ -z "$LC_CTYPE" ]] && \ - export LC_CTYPE=C # default to internal encoding. +# only define LC_CTYPE if undefined +if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then + export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG fi -