Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
5a586670d7
|
@ -31,35 +31,20 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm
|
||||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||||
cdpath=(.)
|
cdpath=(.)
|
||||||
|
|
||||||
# use /etc/hosts and known_hosts for hostname completion
|
|
||||||
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
|
|
||||||
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
|
|
||||||
[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
|
|
||||||
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
|
|
||||||
hosts=(
|
|
||||||
"$_ssh_config[@]"
|
|
||||||
"$_global_ssh_hosts[@]"
|
|
||||||
"$_ssh_hosts[@]"
|
|
||||||
"$_etc_hosts[@]"
|
|
||||||
"$HOST"
|
|
||||||
localhost
|
|
||||||
)
|
|
||||||
zstyle ':completion:*:hosts' hosts $hosts
|
|
||||||
zstyle ':completion:*' users off
|
|
||||||
|
|
||||||
# Use caching so that commands like apt and dpkg complete are useable
|
# Use caching so that commands like apt and dpkg complete are useable
|
||||||
zstyle ':completion::complete:*' use-cache 1
|
zstyle ':completion::complete:*' use-cache 1
|
||||||
zstyle ':completion::complete:*' cache-path $ZSH/cache/
|
zstyle ':completion::complete:*' cache-path $ZSH/cache/
|
||||||
|
|
||||||
# Don't complete uninteresting users
|
# Don't complete uninteresting users
|
||||||
zstyle ':completion:*:*:*:users' ignored-patterns \
|
zstyle ':completion:*:*:*:users' ignored-patterns \
|
||||||
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
|
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
||||||
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
|
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
||||||
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
|
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
||||||
mailman mailnull mldonkey mysql nagios \
|
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||||
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
|
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
||||||
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
|
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
||||||
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
|
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
||||||
|
usbmux uucp vcsa wwwrun xfs
|
||||||
|
|
||||||
# ... unless we really want to.
|
# ... unless we really want to.
|
||||||
zstyle '*' single-ignored show
|
zstyle '*' single-ignored show
|
||||||
|
|
|
@ -34,7 +34,11 @@ if [[ $(uname) == "Darwin" ]] ; then
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
||||||
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
||||||
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
||||||
|
if [ $timeremaining -gt 720 ] ; then
|
||||||
|
echo "::"
|
||||||
|
else
|
||||||
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
|
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "∞"
|
echo "∞"
|
||||||
fi
|
fi
|
||||||
|
@ -62,9 +66,19 @@ if [[ $(uname) == "Darwin" ]] ; then
|
||||||
|
|
||||||
elif [[ $(uname) == "Linux" ]] ; then
|
elif [[ $(uname) == "Linux" ]] ; then
|
||||||
|
|
||||||
function battery_pct_remaining() {
|
function battery_is_charging() {
|
||||||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function battery_pct() {
|
||||||
echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
|
echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
|
||||||
|
}
|
||||||
|
|
||||||
|
function battery_pct_remaining() {
|
||||||
|
if [ ! $(battery_is_charging) ] ; then
|
||||||
|
battery_pct
|
||||||
|
else
|
||||||
|
echo "External Power"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,15 +104,6 @@ elif [[ $(uname) == "Linux" ]] ; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct() {
|
|
||||||
# todo for on linux
|
|
||||||
}
|
|
||||||
|
|
||||||
function battery_is_charging() {
|
|
||||||
# todo on linux
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Empty functions so we don't cause errors in prompts
|
# Empty functions so we don't cause errors in prompts
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ alias bu="bundle update"
|
||||||
|
|
||||||
# The following is based on https://github.com/gma/bundler-exec
|
# The following is based on https://github.com/gma/bundler-exec
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
|
||||||
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
||||||
for cmd in $UNBUNDLED_COMMANDS; do
|
for cmd in $UNBUNDLED_COMMANDS; do
|
||||||
|
|
|
@ -217,3 +217,11 @@ kerndeb () {
|
||||||
"$revision" kernel_image kernel_headers
|
"$revision" kernel_image kernel_headers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# List packages by size
|
||||||
|
function apt-list-packages {
|
||||||
|
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
|
||||||
|
grep -v deinstall | \
|
||||||
|
sort -n | \
|
||||||
|
awk '{print $1" "$2}'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
132
plugins/dirhistory/dirhistory.plugin.zsh
Normal file
132
plugins/dirhistory/dirhistory.plugin.zsh
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
##
|
||||||
|
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
|
||||||
|
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
|
||||||
|
#
|
||||||
|
|
||||||
|
dirhistory_past=(`pwd`)
|
||||||
|
dirhistory_future=()
|
||||||
|
export dirhistory_past
|
||||||
|
export dirhistory_future
|
||||||
|
|
||||||
|
export DIRHISTORY_SIZE=30
|
||||||
|
|
||||||
|
# Pop the last element of dirhistory_past.
|
||||||
|
# Pass the name of the variable to return the result in.
|
||||||
|
# Returns the element if the array was not empty,
|
||||||
|
# otherwise returns empty string.
|
||||||
|
function pop_past() {
|
||||||
|
eval "$1='$dirhistory_past[$#dirhistory_past]'"
|
||||||
|
if [[ $#dirhistory_past -gt 0 ]]; then
|
||||||
|
dirhistory_past[$#dirhistory_past]=()
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function pop_future() {
|
||||||
|
eval "$1='$dirhistory_future[$#dirhistory_future]'"
|
||||||
|
if [[ $#dirhistory_future -gt 0 ]]; then
|
||||||
|
dirhistory_future[$#dirhistory_future]=()
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push a new element onto the end of dirhistory_past. If the size of the array
|
||||||
|
# is >= DIRHISTORY_SIZE, the array is shifted
|
||||||
|
function push_past() {
|
||||||
|
if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
|
||||||
|
shift dirhistory_past
|
||||||
|
fi
|
||||||
|
if [[ $#dirhistory_past -eq 0 || $dirhistory_past[$#dirhistory_past] != "$1" ]]; then
|
||||||
|
dirhistory_past+=($1)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function push_future() {
|
||||||
|
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
|
||||||
|
shift dirhistory_future
|
||||||
|
fi
|
||||||
|
if [[ $#dirhistory_future -eq 0 || $dirhistory_futuret[$#dirhistory_future] != "$1" ]]; then
|
||||||
|
dirhistory_future+=($1)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called by zsh when directory changes
|
||||||
|
function chpwd() {
|
||||||
|
push_past `pwd`
|
||||||
|
# If DIRHISTORY_CD is not set...
|
||||||
|
if [[ -z "${DIRHISTORY_CD+x}" ]]; then
|
||||||
|
# ... clear future.
|
||||||
|
dirhistory_future=()
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function dirhistory_cd(){
|
||||||
|
DIRHISTORY_CD="1"
|
||||||
|
cd $1
|
||||||
|
unset DIRHISTORY_CD
|
||||||
|
}
|
||||||
|
|
||||||
|
# Move backward in directory history
|
||||||
|
function dirhistory_back() {
|
||||||
|
local cw=""
|
||||||
|
local d=""
|
||||||
|
# Last element in dirhistory_past is the cwd.
|
||||||
|
|
||||||
|
pop_past cw
|
||||||
|
if [[ "" == "$cw" ]]; then
|
||||||
|
# Someone overwrote our variable. Recover it.
|
||||||
|
dirhistory_past=(`pwd`)
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
pop_past d
|
||||||
|
if [[ "" != "$d" ]]; then
|
||||||
|
dirhistory_cd $d
|
||||||
|
push_future $cw
|
||||||
|
else
|
||||||
|
push_past $cw
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Move forward in directory history
|
||||||
|
function dirhistory_forward() {
|
||||||
|
local d=""
|
||||||
|
|
||||||
|
pop_future d
|
||||||
|
if [[ "" != "$d" ]]; then
|
||||||
|
dirhistory_cd $d
|
||||||
|
push_past $d
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Bind keys to history navigation
|
||||||
|
function dirhistory_zle_dirhistory_back() {
|
||||||
|
# Erase current line in buffer
|
||||||
|
zle kill-buffer
|
||||||
|
dirhistory_back
|
||||||
|
zle accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
function dirhistory_zle_dirhistory_future() {
|
||||||
|
# Erase current line in buffer
|
||||||
|
zle kill-buffer
|
||||||
|
dirhistory_forward
|
||||||
|
zle accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N dirhistory_zle_dirhistory_back
|
||||||
|
# xterm in normal mode
|
||||||
|
bindkey "\e[3D" dirhistory_zle_dirhistory_back
|
||||||
|
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
|
||||||
|
# Putty:
|
||||||
|
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
|
||||||
|
# GNU screen:
|
||||||
|
bindkey "\eO3D" dirhistory_zle_dirhistory_back
|
||||||
|
|
||||||
|
zle -N dirhistory_zle_dirhistory_future
|
||||||
|
bindkey "\e[3C" dirhistory_zle_dirhistory_future
|
||||||
|
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
|
||||||
|
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
|
||||||
|
bindkey "\eO3C" dirhistory_zle_dirhistory_future
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
# Florent Thoumie and Jonas Pfenniger
|
# Florent Thoumie and Jonas Pfenniger
|
||||||
#
|
#
|
||||||
|
|
||||||
local _plugin__ssh_env=$HOME/.ssh/environment-$HOST
|
local _plugin__ssh_env
|
||||||
local _plugin__forwarding
|
local _plugin__forwarding
|
||||||
|
|
||||||
function _plugin__start_agent()
|
function _plugin__start_agent()
|
||||||
|
@ -48,6 +48,14 @@ function _plugin__start_agent()
|
||||||
/usr/bin/ssh-add $HOME/.ssh/${^identities}
|
/usr/bin/ssh-add $HOME/.ssh/${^identities}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the filename to store/lookup the environment from
|
||||||
|
if (( $+commands[scutil] )); then
|
||||||
|
# It's OS X!
|
||||||
|
_plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)"
|
||||||
|
else
|
||||||
|
_plugin__ssh_env="$HOME/.ssh/environment-$HOST"
|
||||||
|
fi
|
||||||
|
|
||||||
# test if agent-forwarding is enabled
|
# test if agent-forwarding is enabled
|
||||||
zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
|
zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
|
||||||
if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
|
if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
|
||||||
|
|
|
@ -9,7 +9,7 @@ function svn_prompt_info() {
|
||||||
_DISPLAY=$(svn_get_repo_name)
|
_DISPLAY=$(svn_get_repo_name)
|
||||||
fi
|
fi
|
||||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
|
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
|
||||||
$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"
|
$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"
|
||||||
unset _DISPLAY
|
unset _DISPLAY
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -74,3 +74,22 @@ function svn_dirty_choose() {
|
||||||
function svn_dirty() {
|
function svn_dirty() {
|
||||||
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
|
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function svn_dirty_choose_pwd () {
|
||||||
|
if in_svn; then
|
||||||
|
root=`pwd`
|
||||||
|
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
|
||||||
|
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||||
|
echo $1
|
||||||
|
else
|
||||||
|
# Otherwise, no lines were found, or an error occurred. Return clean.
|
||||||
|
echo $2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function svn_dirty_pwd () {
|
||||||
|
svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue