3b6a695b60d81691ab8e31197fc8e0444df0e394

Author
Ashley Valent <avalent@atlassian.com>
Committer
Ashley Valent <avalent@atlassian.com>
Date

Message

Merge branch 'master' of github.com:avalent/oh-my-zsh

Diff

This diff is truncated to protect this page.

  1diff --git a/lib/aliases.zsh b/lib/aliases.zsh
  2deleted file mode 100644
  3index aae865046ef6ea7467deb675a5cbd82bfdac9a94..0000000000000000000000000000000000000000
  4--- a/lib/aliases.zsh
  5+++ /dev/null
  6@@ -1,35 +0,0 @@
  7-# Push and pop directories on directory stack
  8-alias pu='pushd'
  9-alias po='popd'
 10-
 11-# Basic directory operations
 12-alias ...='cd ../..'
 13-alias -- -='cd -'
 14-
 15-# Super user
 16-alias _='sudo'
 17-alias please='sudo'
 18-
 19-#alias g='grep -in'
 20-
 21-# Show history
 22-if [ "$HIST_STAMPS" = "mm/dd/yyyy" ]
 23-then
 24-    alias history='fc -fl 1'
 25-elif [ "$HIST_STAMPS" = "dd.mm.yyyy" ]
 26-then
 27-    alias history='fc -El 1'
 28-elif [ "$HIST_STAMPS" = "yyyy-mm-dd" ]
 29-then
 30-    alias history='fc -il 1'
 31-else
 32-    alias history='fc -l 1'
 33-fi
 34-# List direcory contents
 35-alias lsa='ls -lah'
 36-alias l='ls -lah'
 37-alias ll='ls -lh'
 38-alias la='ls -lAh'
 39-
 40-alias afind='ack-grep -il'
 41-
 42diff --git a/lib/directories.zsh b/lib/directories.zsh
 43index 02743e0c78130bb05f7150cd3ade0a14b98c7831..1a9698544d8802ea0b06ea11a0aba009826f9399 100644
 44--- a/lib/directories.zsh
 45+++ b/lib/directories.zsh
 46@@ -3,12 +3,10 @@ setopt auto_pushd
 47 setopt pushd_ignore_dups
 48 setopt pushdminus
 49 
 50-alias ..='cd ..'
 51-alias cd..='cd ..'
 52-alias cd...='cd ../..'
 53-alias cd....='cd ../../..'
 54-alias cd.....='cd ../../../..'
 55-alias cd/='cd /'
 56+alias -g ...='../..'
 57+alias -g ....='../../..'
 58+alias -g .....='../../../..'
 59+alias -g ......='../../../../..'
 60 
 61 alias 1='cd -'
 62 alias 2='cd -2'
 63@@ -20,23 +18,16 @@ alias 7='cd -7'
 64 alias 8='cd -8'
 65 alias 9='cd -9'
 66 
 67-cd () {
 68-  if   [[ "x$*" == "x..." ]]; then
 69-    cd ../..
 70-  elif [[ "x$*" == "x...." ]]; then
 71-    cd ../../..
 72-  elif [[ "x$*" == "x....." ]]; then
 73-    cd ../../../..
 74-  elif [[ "x$*" == "x......" ]]; then
 75-    cd ../../../../..
 76-  elif [ -d ~/.autoenv ]; then
 77-    source ~/.autoenv/activate.sh
 78-    autoenv_cd "$@"
 79-  else
 80-    builtin cd "$@"
 81-  fi
 82-}
 83-
 84 alias md='mkdir -p'
 85 alias rd=rmdir
 86 alias d='dirs -v | head -10'
 87+
 88+# List directory contents
 89+alias lsa='ls -lah'
 90+alias l='ls -la'
 91+alias ll='ls -l'
 92+alias la='ls -lA'
 93+
 94+# Push and pop directories on directory stack
 95+alias pu='pushd'
 96+alias po='popd'
 97diff --git a/lib/history.zsh b/lib/history.zsh
 98index e78a98e9e8da4e9a11d101dfa6fa1ffd7e9f9c32..5de71c2d3e0fdd0296cc8d46da9fbd1724fd7a00 100644
 99--- a/lib/history.zsh
100+++ b/lib/history.zsh
101@@ -6,6 +6,15 @@ fi
102 HISTSIZE=10000
103 SAVEHIST=10000
104 
105+# Show history
106+case $HIST_STAMPS in
107+  "mm/dd/yyyy") alias history='fc -fl 1' ;;
108+  "dd.mm.yyyy") alias history='fc -El 1' ;;
109+  "yyyy-mm-dd") alias history='fc -il 1' ;;
110+  *) alias history='fc -l 1' ;;
111+esac
112+
113+setopt append_history
114 setopt extended_history
115 setopt hist_expire_dups_first
116 setopt hist_ignore_dups # ignore duplication command history list
117diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
118index 9063c6a18c2778056832654e5a300b25ec32a084..eb2b58058cee10471175530ee3fa67bb04436543 100644
119--- a/lib/key-bindings.zsh
120+++ b/lib/key-bindings.zsh
121@@ -64,6 +64,9 @@ autoload -U edit-command-line
122 zle -N edit-command-line
123 bindkey '\C-x\C-e' edit-command-line
124 
125+# file rename magick
126+bindkey "^[m" copy-prev-shell-word
127+
128 # consider emacs keybindings:
129 
130 #bindkey -e  ## emacs key bindings
131diff --git a/lib/misc.zsh b/lib/misc.zsh
132index a8678b8ecd0185d66500e79bab39224676def2a6..0b7cb26967437479cae98aae452985a9e9cb1c8e 100644
133--- a/lib/misc.zsh
134+++ b/lib/misc.zsh
135@@ -2,9 +2,6 @@
136 autoload -U url-quote-magic
137 zle -N self-insert url-quote-magic
138 
139-## file rename magick
140-bindkey "^[m" copy-prev-shell-word
141-
142 ## jobs
143 setopt long_list_jobs
144 
145@@ -12,4 +9,14 @@ setopt long_list_jobs
146 export PAGER="less"
147 export LESS="-R"
148 
149-export LC_CTYPE=$LANG
150+## super user alias
151+alias _='sudo'
152+alias please='sudo'
153+
154+## more intelligent acking for ubuntu users
155+alias afind='ack-grep -il'
156+
157+# only define LC_CTYPE if undefined
158+if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
159+	export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
160+fi
161diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
162index d9f2b64d4548006e901e850560268892b2d1eec6..58c6203a0663374c1af46a0cafb4a05fcde1db8b 100644
163--- a/lib/termsupport.zsh
164+++ b/lib/termsupport.zsh
165@@ -1,13 +1,21 @@
166-#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
167-#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
168-#Fully support screen, iterm, and probably most modern xterm and rxvt
169+# Set terminal window and tab/icon title
170+#
171+# usage: title short_tab_title [long_window_title]
172+#
173+# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
174+# Fully supports screen, iterm, and probably most modern xterm and rxvt
175+# (In screen, only short_tab_title is used)
176+# Limited support for Apple Terminal (Terminal can't set window and tab separately)
177 function title {
178-  if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
179-    return
180-  fi
181+  [[ "$EMACS" == *term* ]] && return
182+
183+  # if $2 is unset use $1 as default
184+  # if it is set and empty, leave it as is
185+  : ${2=$1}
186+
187   if [[ "$TERM" == screen* ]]; then
188     print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
189-  elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
190+  elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
191     print -Pn "\e]2;$2:q\a" #set window name
192     print -Pn "\e]1;$1:q\a" #set icon (=tab) name
193   fi
194@@ -16,13 +24,28 @@ function title {
195 ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
196 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
197 
198-#Appears when you have the prompt
199+# Runs before showing the prompt
200 function omz_termsupport_precmd {
201+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
202+    return
203+  fi
204+
205   title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
206+
207+  # Notify Terminal.app of current directory using undocumented OSC sequence
208+  # found in OS X 10.9 and 10.10's /etc/bashrc
209+  if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
210+    local PWD_URL="file://$HOSTNAME${PWD// /%20}"
211+    printf '\e]7;%s\a' "$PWD_URL"
212+  fi
213 }
214 
215-#Appears at the beginning of (and during) of command execution
216+# Runs before executing the command
217 function omz_termsupport_preexec {
218+  if [[ $DISABLE_AUTO_TITLE == true ]]; then
219+    return
220+  fi
221+
222   emulate -L zsh
223   setopt extended_glob
224 
225@@ -33,18 +56,5 @@ function omz_termsupport_preexec {
226   title '$CMD' '%100>...>$LINE%<<'
227 }
228 
229-#Appears each time pwd is changed
230-function omz_termsupport_chpwd {
231-  #Notify Terminal.app of current directory using undocumented OSC sequence
232-  #found in OS X 10.10's /etc/bashrc
233-  if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
234-    local PWD_URL="file://$HOSTNAME${PWD// /%20}"
235-    printf '\e]7;%s\a' "$PWD_URL"
236-  fi
237-}
238-#Fire it once so the pwd is set properly upon shell startup
239-omz_termsupport_chpwd
240-
241 precmd_functions+=(omz_termsupport_precmd)
242 preexec_functions+=(omz_termsupport_preexec)
243-chpwd_functions+=(omz_termsupport_chpwd)
244diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
245index 0353f9db4d1c5ac973264132c316fde2dc084cf7..926303ca4509cd89bbc30187fd99879c1fbeb771 100644
246--- a/lib/theme-and-appearance.zsh
247+++ b/lib/theme-and-appearance.zsh
248@@ -1,14 +1,13 @@
249 # ls colors
250-autoload colors; colors;
251+autoload -U colors && colors
252 export LSCOLORS="Gxfxcxdxbxegedabagacad"
253-#export LS_COLORS
254 
255 # Enable ls colors
256 if [ "$DISABLE_LS_COLORS" != "true" ]
257 then
258   # Find the option for using colors in ls, depending on the version: Linux or BSD
259   if [[ "$(uname -s)" == "NetBSD" ]]; then
260-    # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); 
261+    # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
262     # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
263     gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
264   elif [[ "$(uname -s)" == "OpenBSD" ]]; then
265@@ -23,7 +22,7 @@ fi
266 #setopt no_beep
267 setopt auto_cd
268 setopt multios
269-setopt cdablevarS
270+setopt cdablevars
271 
272 if [[ x$WINDOW != x ]]
273 then
274@@ -43,4 +42,3 @@ ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is c
275 
276 # Setup the prompt with pretty colors
277 setopt prompt_subst
278-
279diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh
280index 45f2b06eb600511408934471ca4320f2497ab218..0b738c94fc8ff1f0f1683fc7684c6b042100ff7a 100644
281--- a/plugins/ant/ant.plugin.zsh
282+++ b/plugins/ant/ant.plugin.zsh
283@@ -1,15 +1,15 @@
284 _ant_does_target_list_need_generating () {
285   [ ! -f .ant_targets ] && return 0;
286-  [ .ant_targets -nt build.xml ] && return 0;
287+  [ build.xml -nt .ant_targets ] && return 0;
288   return 1;
289 }
290 
291 _ant () {
292   if [ -f build.xml ]; then
293     if _ant_does_target_list_need_generating; then
294-     sed -n '/<target/s/<target.*name="\([^"]*\).*$/\1/p' build.xml > .ant_targets
295+    	ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
296     fi
297-    compadd `cat .ant_targets`
298+    compadd -- `cat .ant_targets`
299   fi
300 }
301 
302diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
303index ca5666979cd7de508643295b7625835643847e8a..a8271849e3004255b2acb29b6cdefa089e917ddb 100644
304--- a/plugins/autoenv/autoenv.plugin.zsh
305+++ b/plugins/autoenv/autoenv.plugin.zsh
306@@ -1,6 +1,17 @@
307+# Activates autoenv or reports its failure
308+if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then
309+  echo '-------- AUTOENV ---------'
310+  echo 'Could not find ~/.autoenv/activate.sh.'
311+  echo 'Please check if autoenv is correctly installed.'
312+  echo 'In the meantime the autoenv plugin is DISABLED.'
313+  echo '--------------------------'
314+  return 1
315+fi
316+
317 # The use_env call below is a reusable command to activate/create a new Python
318 # virtualenv, requiring only a single declarative line of code in your .env files.
319 # It only performs an action if the requested virtualenv is not the current one.
320+
321 use_env() {
322     typeset venv
323     venv="$1"
324diff --git a/plugins/cake/cake.plugin.zsh b/plugins/cake/cake.plugin.zsh
325index 44cc47470200264729bd9e8d745683aa80037344..2370df9493238f90249cb63473a29783fc981c3d 100644
326--- a/plugins/cake/cake.plugin.zsh
327+++ b/plugins/cake/cake.plugin.zsh
328@@ -15,7 +15,7 @@ _cake_does_target_list_need_generating () {
329 	fi
330 
331 	[ ! -f ${_cake_task_cache_file} ] && return 0;
332-	[ ${_cake_task_cache_file} -nt Cakefile ] && return 0;
333+	[ Cakefile -nt ${_cake_task_cache_file} ] && return 0;
334 	return 1;
335 }
336 
337diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
338index f3d7ec2df4128cdafc58bf134e30891f46002dc4..797554a13e3501787763a03d79e019d93f0261d9 100644
339--- a/plugins/command-not-found/command-not-found.plugin.zsh
340+++ b/plugins/command-not-found/command-not-found.plugin.zsh
341@@ -7,3 +7,19 @@
342 # Arch Linux command-not-found support, you must have package pkgfile installed
343 # https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
344 [[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
345+
346+# Fedora command-not-found support
347+if [ -f /usr/libexec/pk-command-not-found ]; then
348+    command_not_found_handler () {
349+        runcnf=1
350+        retval=127
351+        [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
352+        [ ! -x /usr/libexec/packagekitd ] && runcnf=0
353+        if [ $runcnf -eq 1 ]
354+            then
355+            /usr/libexec/pk-command-not-found $@
356+            retval=$?
357+        fi
358+        return $retval
359+    }
360+fi
361diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
362index 90d59910c794e7a893281e0c6096be81881c3916..e3830adcf9566f5bc6c944dd3d022a6a35707cc5 100644
363--- a/plugins/common-aliases/common-aliases.plugin.zsh
364+++ b/plugins/common-aliases/common-aliases.plugin.zsh
365@@ -20,12 +20,6 @@ alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
366 
367 alias t='tail -f'
368 
369-# because typing 'cd' is A LOT of work!!
370-alias ..='cd ../'
371-alias ...='cd ../../'
372-alias ....='cd ../../../'
373-alias .....='cd ../../../../'
374-
375 # Command line head / tail shortcuts
376 alias -g H='| head'
377 alias -g T='| tail'
378diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
379index 86f2ca4dfba5bbaf5dcf391392423b622f517f8e..7f70e3d7267ea9ff6a37b70846bfaf04b41df193 100644
380--- a/plugins/composer/composer.plugin.zsh
381+++ b/plugins/composer/composer.plugin.zsh
382@@ -7,11 +7,11 @@
383 
384 # Composer basic command completion
385 _composer_get_command_list () {
386-	composer --no-ansi | sed "1,/Available commands/d" | awk '/^  [a-z]+/ { print $1 }'
387+    $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }'
388 }
389 
390 _composer_get_required_list () {
391-    composer show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
392+    $_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
393 }
394 
395 _composer () {
396@@ -20,29 +20,30 @@ _composer () {
397   _arguments \
398     '1: :->command'\
399     '*: :->args'
400-  if [ -f composer.json ]; then
401-    case $state in
402-      command)
403-        compadd `_composer_get_command_list`
404-        ;;
405-      *)
406-        compadd `_composer_get_required_list`
407-        ;;
408-    esac
409-  else
410-    compadd create-project init search selfupdate show
411-  fi
412+
413+  case $state in
414+    command)
415+      compadd $(_composer_get_command_list)
416+      ;;
417+    *)
418+      compadd $(_composer_get_required_list)
419+      ;;
420+  esac
421 }
422 
423 compdef _composer composer
424+compdef _composer composer.phar
425 
426 # Aliases
427 alias c='composer'
428 alias csu='composer self-update'
429 alias cu='composer update'
430+alias cr='composer require'
431 alias ci='composer install'
432 alias ccp='composer create-project'
433 alias cdu='composer dump-autoload'
434+alias cgu='composer global update'
435+alias cgr='composer global require'
436 
437 # install composer in the current directory
438 alias cget='curl -s https://getcomposer.org/installer | php'
439diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh
440index c6b6ba78576f5d1d51b79ee642f9a8b7210057dd..1e31105b17e2b2b4d81bca1d8d95aa44e18c6326 100644
441--- a/plugins/dircycle/dircycle.plugin.zsh
442+++ b/plugins/dircycle/dircycle.plugin.zsh
443@@ -1,10 +1,37 @@
444-##
445-# dircycle plugin: enables cycling through the directory
446-# stack using Ctrl+Shift+Left/Right
447+# enables cycling through the directory stack using
448+# Ctrl+Shift+Left/Right
449+#
450+# left/right direction follows the order in which directories
451+# were visited, like left/right arrows do in a browser
452 
453-eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
454+# NO_PUSHD_MINUS syntax:
455+#  pushd +N: start counting from left of `dirs' output
456+#  pushd -N: start counting from right of `dirs' output
457+
458+insert-cycledleft () {
459+	emulate -L zsh
460+	setopt nopushdminus
461+
462+	builtin pushd -q +1 &>/dev/null || true
463+	zle reset-prompt
464+}
465 zle -N insert-cycledleft
466-bindkey "\e[1;6D" insert-cycledleft
467-eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
468+
469+insert-cycledright () {
470+	emulate -L zsh
471+	setopt nopushdminus
472+
473+	builtin pushd -q -0 &>/dev/null || true
474+	zle reset-prompt
475+}
476 zle -N insert-cycledright
477-bindkey "\e[1;6C" insert-cycledright
478+
479+
480+# add key bindings for iTerm2
481+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
482+	bindkey "^[[1;6D" insert-cycledleft
483+	bindkey "^[[1;6C" insert-cycledright
484+else
485+	bindkey "\e[1;6D" insert-cycledleft
486+	bindkey "\e[1;6C" insert-cycledright
487+fi
488diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
489index 01b8a88d921247bc43d5e003956ffb4fefa2dd53..d868a5fe1d1bf6b6117db674b093d1a632f5d0d7 100644
490--- a/plugins/git-prompt/git-prompt.plugin.zsh
491+++ b/plugins/git-prompt/git-prompt.plugin.zsh
492@@ -2,9 +2,6 @@
493 # http://github.com/olivierverdier/zsh-git-prompt
494 #
495 export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt
496-# Initialize colors.
497-autoload -U colors
498-colors
499 
500 # Allow for functions in the prompt.
501 setopt PROMPT_SUBST
502diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
503index b16814fe4d12b9935a046e745ab46169090c3446..d082c11e54280c392846ef8800545ef9d01a0644 100644
504--- a/plugins/jump/jump.plugin.zsh
505+++ b/plugins/jump/jump.plugin.zsh
506@@ -27,7 +27,6 @@ unmark() {
507 	rm -i "$MARKPATH/$1"
508 }
509 
510-autoload colors
511 marks() {
512 	for link in $MARKPATH/*(@); do
513 		local markname="$fg[cyan]${link:t}$reset_color"
514diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh
515index e472578b0eaa85b9c9f58b3dc3261a30d999a4b6..4fa6fcc34800ec812a75cdd01a9ba8eecbf49fcc 100644
516--- a/plugins/last-working-dir/last-working-dir.plugin.zsh
517+++ b/plugins/last-working-dir/last-working-dir.plugin.zsh
518@@ -5,7 +5,7 @@
519 # Flag indicating if we've previously jumped to last directory.
520 typeset -g ZSH_LAST_WORKING_DIRECTORY
521 mkdir -p $ZSH_CACHE_DIR
522-local cache_file="$ZSH_CACHE_DIR/last-working-dir"
523+cache_file="$ZSH_CACHE_DIR/last-working-dir"
524 
525 # Updates the last directory once directory is changed.
526 function chpwd() {
527diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
528index d12e068530e70ca2dc8e55d21e628214ecadbf29..e3ba39918af9345bb04801bb2c5dc5c6704d99b0 100644
529--- a/plugins/sudo/sudo.plugin.zsh
530+++ b/plugins/sudo/sudo.plugin.zsh
531@@ -13,9 +13,8 @@
532 # ------------------------------------------------------------------------------
533 
534 sudo-command-line() {
535-[[ -z $BUFFER ]] && zle up-history
536-[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
537-zle end-of-line 
538+    [[ -z $BUFFER ]] && zle up-history
539+    [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
540 }
541 zle -N sudo-command-line
542 # Defined shortcut keys: [Esc] [Esc]
543diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
544index 3ed32b3fb29decd731c6780a73f757f8945c6bd6..f2745b409097c6cdf6c5a02069728e8b18f2f632 100644
545--- a/plugins/vi-mode/vi-mode.plugin.zsh
546+++ b/plugins/vi-mode/vi-mode.plugin.zsh
547@@ -14,6 +14,14 @@ function zle-keymap-select zle-line-init zle-line-finish {
548   zle -R
549 }
550 
551+# Ensure that the prompt is redrawn when the terminal size changes.
552+TRAPWINCH() {
553+  if [[ -o zle ]]; then
554+    zle reset-prompt
555+    zle -R
556+  fi
557+}
558+
559 zle -N zle-line-init
560 zle -N zle-line-finish
561 zle -N zle-keymap-select
562diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
563index 52e02d3e01390c77f669d2fa657d2b65e7ae5029..5faa1a823aa7c9764aef2eb95aed5fa16a5e3bb4 100644
564--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
565+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
566@@ -1,65 +1,70 @@
567 virtualenvwrapper='virtualenvwrapper.sh'
568-if (( $+commands[$virtualenvwrapper] )); then
569 
570+if (( $+commands[$virtualenvwrapper] )); then
571   source ${${virtualenvwrapper}:c}
572+elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
573+  virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
574+  source "/etc/bash_completion.d/virtualenvwrapper"
575+else
576+  print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
577+        "Please install with \`pip install virtualenvwrapper\`" >&2
578+  return
579+fi
580+if ! type workon &>/dev/null; then
581+  print "zsh virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
582+        "Please check ${virtualenvwrapper}" >&2
583+  return
584+fi
585 
586-  if [[ "$WORKON_HOME" == "" ]]; then
587-    echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work"
588-  else
589+if [[ "$WORKON_HOME" == "" ]]; then
590+  print "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" >&2
591+  return
592+fi
593 
594-    if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
595-      # Automatically activate Git projects's virtual environments based on the
596-      # directory name of the project. Virtual environment name can be overridden
597-      # by placing a .venv file in the project root with a virtualenv name in it
598-      function workon_cwd {
599-        if [ ! $WORKON_CWD ]; then
600-          WORKON_CWD=1
601-          # Check if this is a Git repo
602-          PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
603-          if (( $? != 0 )); then
604-            PROJECT_ROOT="."
605-          fi
606-          # Check for virtualenv name override
607-          if [[ -f "$PROJECT_ROOT/.venv" ]]; then
608-            ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
609-          elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
610-            ENV_NAME="$PROJECT_ROOT/.venv"
611-          elif [[ "$PROJECT_ROOT" != "." ]]; then
612-            ENV_NAME=`basename "$PROJECT_ROOT"`
613-          else
614-            ENV_NAME=""
615-          fi
616-          if [[ "$ENV_NAME" != "" ]]; then
617-            # Activate the environment only if it is not already active
618-            if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
619-              if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
620-                workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
621-              elif [[ -e "$ENV_NAME/bin/activate" ]]; then
622-                source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
623-              fi
624-            fi
625-          elif [ $CD_VIRTUAL_ENV ]; then
626-            # We've just left the repo, deactivate the environment
627-            # Note: this only happens if the virtualenv was activated automatically
628-            deactivate && unset CD_VIRTUAL_ENV
629+if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
630+  # Automatically activate Git projects's virtual environments based on the
631+  # directory name of the project. Virtual environment name can be overridden
632+  # by placing a .venv file in the project root with a virtualenv name in it
633+  function workon_cwd {
634+    if [ ! $WORKON_CWD ]; then
635+      WORKON_CWD=1
636+      # Check if this is a Git repo
637+      PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
638+      if (( $? != 0 )); then
639+        PROJECT_ROOT="."
640+      fi
641+      # Check for virtualenv name override
642+      if [[ -f "$PROJECT_ROOT/.venv" ]]; then
643+        ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
644+      elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
645+        ENV_NAME="$PROJECT_ROOT/.venv"
646+      elif [[ "$PROJECT_ROOT" != "." ]]; then
647+        ENV_NAME=`basename "$PROJECT_ROOT"`
648+      else
649+        ENV_NAME=""
650+      fi
651+      if [[ "$ENV_NAME" != "" ]]; then
652+        # Activate the environment only if it is not already active
653+        if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
654+          if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
655+            workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
656+          elif [[ -e "$ENV_NAME/bin/activate" ]]; then
657+            source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
658           fi
659-          unset PROJECT_ROOT
660-          unset WORKON_CWD
661-        fi
662-      }
663-
664-      # Append workon_cwd to the chpwd_functions array, so it will be called on cd
665-      # http://zsh.sourceforge.net/Doc/Release/Functions.html
666diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh
667index 28559deb9d084895371a348ee89585be703b0b33..572427b0b61209f03616ae14cdd9d0b3bf67e109 100644
668--- a/plugins/web-search/web-search.plugin.zsh
669+++ b/plugins/web-search/web-search.plugin.zsh
670@@ -1,43 +1,46 @@
671 # web_search from terminal
672 
673 function web_search() {
674-  # get the open command
675-  local open_cmd
676-  if [[ "$OSTYPE" = darwin* ]]; then
677-    open_cmd='open'
678-  else
679-    open_cmd='xdg-open'
680-  fi
681+  emulate -L zsh
682+
683+  # define search engine URLS
684+  typeset -A urls
685+  urls=(
686+    google      "https://www.google.com/search?q="
687+    bing        "https://www.bing.com/search?q="
688+    yahoo       "https://search.yahoo.com/search?p="
689+    duckduckgo  "https://www.duckduckgo.com/?q="
690+    yandex      "https://yandex.ru/yandsearch?text="
691+  )
692+
693+  # define the open command
694+  case "$OSTYPE" in
695+    darwin*)  open_cmd="open" ;;
696+    cygwin*)  open_cmd="cygstart" ;;
697+    linux*)   open_cmd="xdg-open" ;;
698+    *)        echo "Platform $OSTYPE not supported"
699+              return 1
700+              ;;
701+  esac
702 
703   # check whether the search engine is supported
704-  if [[ ! $1 =~ '(google|bing|yahoo|duckduckgo)' ]];
705-  then
706+  if [[ -z "$urls[$1]" ]]; then
707     echo "Search engine $1 not supported."
708     return 1
709   fi
710 
711-  local url="http://www.$1.com"
712-
713-  # no keyword provided, simply open the search engine homepage
714-  if [[ $# -le 1 ]]; then
715-    $open_cmd "$url"
716-    return
717-  fi
718-  if [[ $1 == 'duckduckgo' ]]; then
719-  #slightly different search syntax for DDG
720-    url="${url}/?q="
721+  # search or go to main page depending on number of arguments passed
722+  if [[ $# -gt 1 ]]; then
723+    # build search url:
724+    # join arguments passed with '+', then append to search engine URL
725+    url="${urls[$1]}${(j:+:)@[2,-1]}"
726   else
727-    url="${url}/search?q="
728+    # build main page url:
729+    # split by '/', then rejoin protocol (1) and domain (2) parts with '//'
730+    url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
731   fi
732-  shift   # shift out $1
733-
734-  while [[ $# -gt 0 ]]; do
735-    url="${url}$1+"
736-    shift
737-  done
738 
739-  url="${url%?}" # remove the last '+'
740-  nohup $open_cmd "$url" >/dev/null 2&>1
741+  nohup $open_cmd "$url" &>/dev/null
742 }
743 
744 
745@@ -45,6 +48,8 @@ alias bing='web_search bing'
746 alias google='web_search google'
747 alias yahoo='web_search yahoo'
748 alias ddg='web_search duckduckgo'
749+alias yandex='web_search yandex'
750+
751 #add your own !bang searches here
752 alias wiki='web_search duckduckgo \!w'
753 alias news='web_search duckduckgo \!n'
754diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme
755index 6869c8a20ae20203ded67bd33f1ee987af09bd19..212b823a5c95c3a8bd64f39480fb7b9ab6d2be25 100644
756--- a/themes/adben.zsh-theme
757+++ b/themes/adben.zsh-theme
758@@ -69,17 +69,17 @@ function precmd {
759         #Choose from all databases, regardless of whether they are considered "offensive"
760         fortune -a
761     }
762-    #obtains the tip 
763+    #obtains the tip
764     ps1_command_tip () {
765         wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d'
766-    }  
767+    }
768     prompt_header () {
769         if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then
770             ps1_command_tip
771         else
772             ps1_fortune
773-        fi 
774-    }   
775+        fi
776+    }
777     PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
778     # set a simple variable to show when in screen
779     if [[ -n "${WINDOW}" ]]; then
780@@ -99,11 +99,8 @@ prompt_context () {
781 set_prompt () {
782     # required for the prompt
783     setopt prompt_subst
784-    autoload colors zsh/terminfo
785-    if [[ "$terminfo[colors]" -gt 8 ]]; then
786-        colors
787-    fi 
788-    
789+    autoload zsh/terminfo
790+
791     # ######### PROMPT #########
792     PROMPT='${PROMPT_HEAD}
793 ${RED_START}$(prompt_context)
794diff --git a/themes/apple.zsh-theme b/themes/apple.zsh-theme
795index 275341dc67a8d85caafe92d78ab414787f104cdc..95e6249fa897a46ab12c80b9b3f18b99dc1f0ba7 100644
796--- a/themes/apple.zsh-theme
797+++ b/themes/apple.zsh-theme
798@@ -7,7 +7,6 @@ get_git_dirty() {
799 }
800 
801 autoload -Uz vcs_info
802-autoload -U colors && colors
803 zstyle ':vcs_info:*' check-for-changes true
804 zstyle ':vcs_info:*' unstagedstr '%F{red}*'   # display this when there are unstaged changes
805 zstyle ':vcs_info:*' stagedstr '%F{yellow}+'  # display this when there are staged changes
806diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme
807index 0519fbefb4150397be44d164cb6c93edcc8d9470..ab154c1e5cbc8a5cdbd014a11c2967449d591530 100644
808--- a/themes/gnzh.zsh-theme
809+++ b/themes/gnzh.zsh-theme
810@@ -2,8 +2,7 @@
811 # Based on bira theme
812 
813 # load some modules
814-autoload -U colors zsh/terminfo # Used in the colour alias below
815-colors
816+autoload -U zsh/terminfo # Used in the colour alias below
817 setopt prompt_subst
818 
819 # make some aliases for the colours: (could use normal escape sequences too)
820diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme
821index 942affa94dc3a746ff8895048cb151abd303af64..a3c50570626f8011d4677925ace04929788d4041 100644
822--- a/themes/half-life.zsh-theme
823+++ b/themes/half-life.zsh-theme
824@@ -13,8 +13,6 @@ function virtualenv_info {
825 PR_GIT_UPDATE=1
826 
827 setopt prompt_subst
828-autoload colors
829-colors
830 
831 autoload -U add-zsh-hook
832 autoload -Uz vcs_info
833diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme
834index bca92970c48f63748e4df10b92d1c43fe6386d18..2f0e774315dbb31564ae8d43c5466d1f361c4ec4 100644
835--- a/themes/jonathan.zsh-theme
836+++ b/themes/jonathan.zsh-theme
837@@ -44,10 +44,7 @@ setprompt () {
838     ###
839     # See if we can use colors.
840 
841-    autoload colors zsh/terminfo
842-    if [[ "$terminfo[colors]" -ge 8 ]]; then
843-	colors
844-    fi
845+    autoload zsh/terminfo
846     for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
847 	eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
848 	eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
849diff --git a/themes/kolo.zsh-theme b/themes/kolo.zsh-theme
850index e743289c35aff6561f519b4702c5b070df08320a..51b0af724aff06735f0aef28381d9787e03f6e94 100644
851--- a/themes/kolo.zsh-theme
852+++ b/themes/kolo.zsh-theme
853@@ -1,5 +1,3 @@
854-autoload -U colors && colors
855-
856 autoload -Uz vcs_info
857 
858 zstyle ':vcs_info:*' stagedstr '%F{green}●'
859diff --git a/themes/linuxonly.zsh-theme b/themes/linuxonly.zsh-theme
860index a11b80d7f6dd446af779c7970625822c4daa5740..f9e0aa07df89f0f7bc55999f7c9455a66c746cd6 100644
861--- a/themes/linuxonly.zsh-theme
862+++ b/themes/linuxonly.zsh-theme
863@@ -13,7 +13,6 @@ local c7=$(printf "\033[38;5;149m")
864 local c8=$(printf "\033[38;5;126m")
865 local c9=$(printf "\033[38;5;162m")
866 
867-local foopath=$(perl /home/scp1/bin/foopath)
868 
869 if [ "$TERM" = "linux" ]; then
870     c1=$(printf "\033[34;1m")
871diff --git a/themes/mikeh.zsh-theme b/themes/mikeh.zsh-theme
872index 943f04d389ccee2883584b8c55b9518126d3b4a4..a95383ba56d356b0fed972229468ca1673adaea4 100644
873--- a/themes/mikeh.zsh-theme
874+++ b/themes/mikeh.zsh-theme
875@@ -1,6 +1,4 @@
876 setopt prompt_subst
877-autoload colors
878-colors
879 
880 autoload -U add-zsh-hook
881 autoload -Uz vcs_info
882diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme
883index eed084f15a9eb722095aaea1262ba06ad32e835f..8585e66be551eb66652eb1689061418218751e64 100644
884--- a/themes/rkj-repos.zsh-theme
885+++ b/themes/rkj-repos.zsh-theme
886@@ -16,13 +16,15 @@ ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✗"
887 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}➦"
888 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}✂"
889 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈"
890+ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$fg[grey]%}"
891+ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}"
892 
893 function mygit() {
894-  ref1=$(git symbolic-ref HEAD 2> /dev/null) || return
895-  ref2=$(git rev-parse HEAD | head -c 6) || return
896-  ref="$ref1 %{$fg[grey]%}$ref2"
897-  #ref=$(git symbolic-ref HEAD 2> /dev/null) $(git rev-parse HEAD | head -c 6) || return
898-  echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX "
899+  if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
900+    ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
901+    ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
902+    echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_short_sha)$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX "
903+  fi
904 }
905 
906 function retcode() {}
907diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme
908index fb4d32e2419a42d759af0bc224912c68c7b9117b..63ce4261bf61348a01c3cdb2526b638c563f3602 100644
909--- a/themes/simonoff.zsh-theme
910+++ b/themes/simonoff.zsh-theme
911@@ -63,10 +63,7 @@ setprompt () {
912 ###
913 # See if we can use colors.
914 
915-    autoload colors zsh/terminfo
916-    if [[ "$terminfo[colors]" -ge 8 ]]; then
917-    colors
918-    fi
919+    autoload zsh/terminfo
920     for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
921     eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
922     eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
923diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme
924index e38188d353daafe1d7673719b9a99c9fe78aa87c..13728ca9a9b95fe7bcef160ef5e01f1d2ec3a3b0 100644
925--- a/themes/steeef.zsh-theme
926+++ b/themes/steeef.zsh-theme
927@@ -15,8 +15,6 @@ function virtualenv_info {
928 PR_GIT_UPDATE=1
929 
930 setopt prompt_subst
931-autoload colors
932-colors
933 
934 autoload -U add-zsh-hook
935 autoload -Uz vcs_info
936diff --git a/themes/zhann.zsh-theme b/themes/zhann.zsh-theme
937index 5c085473002a5decae40d9cc7dec78beb5cdf586..27597ec6ce6de3720b58e722c6d3a1f108867285 100644
938--- a/themes/zhann.zsh-theme
939+++ b/themes/zhann.zsh-theme
940@@ -1,5 +1,3 @@
941-autoload -U colors && colors
942-
943 autoload -Uz vcs_info
944 
945 zstyle ':vcs_info:*' stagedstr '%F{green}●'
946diff --git a/tools/install.sh b/tools/install.sh
947index 69213d4a314fd6b6e17c5a7fa72dea669b6e03d8..bd4c5574988646ed5ebb55704e5046665b9c16bd 100755
948--- a/tools/install.sh
949+++ b/tools/install.sh
950@@ -23,8 +23,8 @@ fi
951 
952 echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
953 cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
954-sed -i -e "/^ZSH=/ c\\
955-ZSH=$ZSH
956+sed -i -e "/^export ZSH=/ c\\
957+export ZSH=$ZSH
958 " ~/.zshrc
959 
960 echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"