5a586670d73dbbda97d124e33398aabf21597659

Author
Bob Williams <bobwilliams.ii@gmail.com>
Committer
Bob Williams <bobwilliams.ii@gmail.com>
Date

Message

Merge remote-tracking branch 'upstream/master'

Diff

This diff is truncated to protect this page.

  1diff --git a/lib/completion.zsh b/lib/completion.zsh
  2index e0cdcf626bfaf6250818f983e2bc954ec2fb6f53..c54249c527b04b4c51ef014f2d9cdeddcf7ee252 100644
  3--- a/lib/completion.zsh
  4+++ b/lib/completion.zsh
  5@@ -31,35 +31,20 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm
  6 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
  7 cdpath=(.)
  8 
  9-# use /etc/hosts and known_hosts for hostname completion
 10-[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
 11-[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
 12-[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
 13-[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
 14-hosts=(
 15-  "$_ssh_config[@]"
 16-  "$_global_ssh_hosts[@]"
 17-  "$_ssh_hosts[@]"
 18-  "$_etc_hosts[@]"
 19-  "$HOST"
 20-  localhost
 21-)
 22-zstyle ':completion:*:hosts' hosts $hosts
 23-zstyle ':completion:*' users off
 24-
 25 # Use caching so that commands like apt and dpkg complete are useable
 26 zstyle ':completion::complete:*' use-cache 1
 27 zstyle ':completion::complete:*' cache-path $ZSH/cache/
 28 
 29 # Don't complete uninteresting users
 30 zstyle ':completion:*:*:*:users' ignored-patterns \
 31-        adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
 32-        dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
 33-        hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
 34-        mailman mailnull mldonkey mysql nagios \
 35-        named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
 36-        operator pcap postfix postgres privoxy pulse pvm quagga radvd \
 37-        rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
 38+        adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
 39+        clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
 40+        gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
 41+        ldap lp mail mailman mailnull man messagebus  mldonkey mysql nagios \
 42+        named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
 43+        operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
 44+        rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
 45+        usbmux uucp vcsa wwwrun xfs
 46 
 47 # ... unless we really want to.
 48 zstyle '*' single-ignored show
 49diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
 50index e39cc5b8f455c952f3af876ee9b1e68c397903c3..b16a75c5b1cb07466b83673c32e29183dbe7a684 100644
 51--- a/plugins/battery/battery.plugin.zsh
 52+++ b/plugins/battery/battery.plugin.zsh
 53@@ -34,7 +34,11 @@ if [[ $(uname) == "Darwin" ]] ; then
 54   	local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
 55     if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
 56       timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
 57-      echo "~$((timeremaining / 60)):$((timeremaining % 60))"
 58+      if [ $timeremaining -gt 720 ] ; then
 59+        echo "::"
 60+      else
 61+        echo "~$((timeremaining / 60)):$((timeremaining % 60))"
 62+      fi
 63     else
 64       echo "∞"
 65     fi
 66@@ -62,9 +66,19 @@ if [[ $(uname) == "Darwin" ]] ; then
 67 
 68 elif [[ $(uname) == "Linux"  ]] ; then
 69 
 70+  function battery_is_charging() {
 71+    ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
 72+  }
 73+
 74+  function battery_pct() {
 75+    echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" 
 76+  }
 77+
 78   function battery_pct_remaining() {
 79-    if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
 80-      echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" 
 81+    if [ ! $(battery_is_charging) ] ; then
 82+      battery_pct
 83+    else
 84+      echo "External Power"
 85     fi
 86   }
 87 
 88@@ -90,15 +104,6 @@ elif [[ $(uname) == "Linux"  ]] ; then
 89     fi
 90   }
 91   
 92-  function battery_pct() {
 93-    # todo for on linux
 94-  }
 95-  
 96-  function battery_is_charging() {
 97-    # todo on linux
 98-	false
 99-  }
100-
101 else
102   # Empty functions so we don't cause errors in prompts
103   function battery_pct_remaining() {
104diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
105index 9dfed61a46b0f0bf93f84ae172b6e0704d75fdd8..df30ed7c7063578745d2409d8f826c548182d8f9 100644
106--- a/plugins/bundler/bundler.plugin.zsh
107+++ b/plugins/bundler/bundler.plugin.zsh
108@@ -6,7 +6,7 @@ alias bu="bundle update"
109 
110 # The following is based on https://github.com/gma/bundler-exec
111 
112-bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma)
113+bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife mailcatcher middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma)
114 
115 # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
116 for cmd in $UNBUNDLED_COMMANDS; do
117diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
118index 1e15487ba4768d72b0edfbc3deb4496de888278e..28dfb82a5c53e210a8874e81b3f9ab36c16d7c94 100644
119--- a/plugins/debian/debian.plugin.zsh
120+++ b/plugins/debian/debian.plugin.zsh
121@@ -217,3 +217,11 @@ kerndeb () {
122         "$revision" kernel_image kernel_headers
123 }
124 
125+# List packages by size
126+function apt-list-packages {
127+    dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
128+    grep -v deinstall | \
129+    sort -n | \
130+    awk '{print $1" "$2}'
131+}
132+
133diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
134new file mode 100644
135index 0000000000000000000000000000000000000000..504d7ec14b3817631b2aff8d36fd8a6c8d227c24
136--- /dev/null
137+++ b/plugins/dirhistory/dirhistory.plugin.zsh
138@@ -0,0 +1,132 @@
139+## 
140+#   Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories 
141+#   that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
142+# 
143+
144+dirhistory_past=(`pwd`)
145+dirhistory_future=()
146+export dirhistory_past
147+export dirhistory_future
148+
149+export DIRHISTORY_SIZE=30
150+
151+# Pop the last element of dirhistory_past. 
152+# Pass the name of the variable to return the result in. 
153+# Returns the element if the array was not empty,
154+# otherwise returns empty string.
155+function pop_past() {
156+  eval "$1='$dirhistory_past[$#dirhistory_past]'"
157+  if [[ $#dirhistory_past -gt 0 ]]; then
158+    dirhistory_past[$#dirhistory_past]=()
159+  fi
160+}
161+
162+function pop_future() {
163+  eval "$1='$dirhistory_future[$#dirhistory_future]'"
164+  if [[ $#dirhistory_future -gt 0 ]]; then
165+    dirhistory_future[$#dirhistory_future]=()
166+  fi
167+}
168+
169+# Push a new element onto the end of dirhistory_past. If the size of the array 
170+# is >= DIRHISTORY_SIZE, the array is shifted
171+function push_past() {
172+  if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
173+    shift dirhistory_past
174+  fi
175+  if [[ $#dirhistory_past -eq 0 || $dirhistory_past[$#dirhistory_past] != "$1" ]]; then
176+    dirhistory_past+=($1)
177+  fi
178+}
179+
180+function push_future() {
181+  if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
182+    shift dirhistory_future
183+  fi
184+  if [[ $#dirhistory_future -eq 0 || $dirhistory_futuret[$#dirhistory_future] != "$1" ]]; then
185+    dirhistory_future+=($1)
186+  fi
187+}
188+
189+# Called by zsh when directory changes
190+function chpwd() {
191+  push_past `pwd`
192+  # If DIRHISTORY_CD is not set...
193+  if [[ -z "${DIRHISTORY_CD+x}" ]]; then
194+    # ... clear future.
195+    dirhistory_future=()
196+  fi
197+}
198+
199+function dirhistory_cd(){
200+  DIRHISTORY_CD="1"
201+  cd $1
202+  unset DIRHISTORY_CD
203+}
204+
205+# Move backward in directory history
206+function dirhistory_back() {
207+  local cw=""
208+  local d=""
209+  # Last element in dirhistory_past is the cwd.
210+
211+  pop_past cw 
212+  if [[ "" == "$cw" ]]; then
213+    # Someone overwrote our variable. Recover it.
214+    dirhistory_past=(`pwd`)
215+    return
216+  fi
217+
218+  pop_past d
219+  if [[ "" != "$d" ]]; then
220+    dirhistory_cd $d
221+    push_future $cw
222+  else
223+    push_past $cw
224+  fi
225+}
226+
227+
228+# Move forward in directory history
229+function dirhistory_forward() {
230+  local d=""
231+
232+  pop_future d
233+  if [[ "" != "$d" ]]; then
234+    dirhistory_cd $d
235+    push_past $d
236+  fi
237+}
238diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
239index a1e64ad0f119fdd627ae8f9a82d41d987d82bb34..2fb8d54624dcfa86b49e53817a7168699ec01bd0 100644
240--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
241+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
242@@ -27,7 +27,7 @@
243 #   Florent Thoumie and Jonas Pfenniger
244 #
245 
246-local _plugin__ssh_env=$HOME/.ssh/environment-$HOST
247+local _plugin__ssh_env
248 local _plugin__forwarding
249 
250 function _plugin__start_agent()
251@@ -42,12 +42,20 @@ function _plugin__start_agent()
252   . ${_plugin__ssh_env} > /dev/null
253 
254   # load identies
255-  zstyle -a :omz:plugins:ssh-agent identities identities 
256+  zstyle -a :omz:plugins:ssh-agent identities identities
257   echo starting ssh-agent...
258 
259   /usr/bin/ssh-add $HOME/.ssh/${^identities}
260 }
261 
262+# Get the filename to store/lookup the environment from
263+if (( $+commands[scutil] )); then
264+  # It's OS X!
265+  _plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)"
266+else
267+  _plugin__ssh_env="$HOME/.ssh/environment-$HOST"
268+fi
269+
270 # test if agent-forwarding is enabled
271 zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
272 if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
273diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
274index 4f008ba4e219d986f9c5515c209ffec68da2a68e..ef6da5bd3cb6e6447e59c224fc8a158ecc1ac590 100644
275--- a/plugins/svn/svn.plugin.zsh
276+++ b/plugins/svn/svn.plugin.zsh
277@@ -9,7 +9,7 @@ function svn_prompt_info() {
278       _DISPLAY=$(svn_get_repo_name)
279     fi
280     echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
281-$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
282+$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
283     unset _DISPLAY
284   fi
285 }
286@@ -74,3 +74,22 @@ function svn_dirty_choose() {
287 function svn_dirty() {
288   svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
289 }
290+
291+function svn_dirty_choose_pwd () {
292+  if in_svn; then
293+    root=`pwd`
294+    if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
295+      # Grep exits with 0 when "One or more lines were selected", return "dirty".
296+      echo $1
297+    else
298+      # Otherwise, no lines were found, or an error occurred. Return clean.
299+      echo $2
300+    fi
301+  fi
302+}
303+
304+function svn_dirty_pwd () {
305+  svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
306+}
307+
308+