Merge remote-tracking branch 'blessed/master'

* blessed/master: (75 commits)
  added exec command to docker plugin
  Quote path in case $HOME has a space in it.
  Update the list of Heroku Postgres commands
  fix(tools/check_for_upgrade): Don't source profile
  Fix aws.plugins.zsh check rule
  Revert PR #3359 as this is breaking stuff for many folks. Need to rethink how we handle system defaults differently on this
  Updated Yii2 command completion
  added node- before node version for consistency
  mira theme shows active node, ruby and java versions
  Add yii2 readme
  Added Yii2 command completion
  Change to alias and remove deprecated GREP_COLOR
  Tidy up the grep.zsh library
  Use unaliased grep in flag check
  Ignore .bzr folders in grep too
  Extract VCS folders definition to avoid repetition
  Add itunes shuffle command to OSX plugin.
  Fixed output issues webith websearch plugin.
  Fix dircycle plugin
  add current bookmark to rkj-repos theme
  ...
This commit is contained in:
Carlos Cardoso 2014-12-29 12:06:52 -02:00
commit 2a58921469
69 changed files with 819 additions and 392 deletions

View file

@ -25,7 +25,12 @@ bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" if [ "$OSTYPE[0,7]" = "solaris" ]
then
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
else
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
fi
# disable named-directories autocompletion # disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories

View file

@ -1,5 +1,4 @@
# Changing/making/removing directory # Changing/making/removing directory
setopt auto_name_dirs
setopt auto_pushd setopt auto_pushd
setopt pushd_ignore_dups setopt pushd_ignore_dups
setopt pushdminus setopt pushdminus

View file

@ -10,23 +10,20 @@ function git_prompt_info() {
# Checks if working tree is dirty # Checks if working tree is dirty
parse_git_dirty() { parse_git_dirty() {
local SUBMODULE_SYNTAX='' local STATUS=''
local GIT_STATUS='' local FLAGS
local CLEAN_MESSAGE='nothing to commit (working directory clean)' FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty" FLAGS+='--ignore-submodules=dirty'
fi fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) FLAGS+='--untracked-files=no'
else
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
fi
if [[ -n $GIT_STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN" echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi fi
@ -81,7 +78,7 @@ function git_prompt_long_sha() {
git_prompt_status() { git_prompt_status() {
INDEX=$(command git status --porcelain -b 2> /dev/null) INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS="" STATUS=""
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
@ -135,17 +132,19 @@ function git_compare_version() {
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}); INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
for i in {1..3}; do for i in {1..3}; do
if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
echo 1
return 0
fi
if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
echo -1 echo -1
return 0 return 0
fi fi
done done
echo 1 echo 0
} }
#this is unlikely to change so make it all statically assigned #this is unlikely to change so make it all statically assigned
POST_1_7_2_GIT=$(git_compare_version "1.7.2") POST_1_7_2_GIT=$(git_compare_version "1.7.2")
#clean up the namespace slightly by removing the checker function #clean up the namespace slightly by removing the checker function
unset -f git_compare_version unset -f git_compare_version

View file

@ -1,24 +1,24 @@
# # is x grep argument available?
# Color grep results
# Examples: http://rubyurl.com/ZXv
#
GREP_OPTIONS="--color=auto"
# avoid VCS folders (if the necessary grep flags are available)
grep-flag-available() { grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1 echo | grep $1 "" >/dev/null 2>&1
} }
if grep-flag-available --exclude-dir=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude-dir=$PATTERN"
done
elif grep-flag-available --exclude=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude=$PATTERN"
done
fi
unfunction grep-flag-available
export GREP_OPTIONS="$GREP_OPTIONS" # color grep results
export GREP_COLOR='1;32' GREP_OPTIONS="--color=auto"
# ignore VCS folders (if the necessary grep flags are available)
VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
if grep-flag-available --exclude-dir=.cvs; then
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
elif grep-flag-available --exclude=.cvs; then
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
fi
# export grep settings
alias grep="grep $GREP_OPTIONS"
# clean up
unset GREP_OPTIONS
unset VCS_FOLDERS
unfunction grep-flag-available

View file

@ -1,7 +1,8 @@
## Command history configuration ## Command history configuration
if [ -z $HISTFILE ]; then if [ -z "$HISTFILE" ]; then
HISTFILE=$HOME/.zsh_history HISTFILE=$HOME/.zsh_history
fi fi
HISTSIZE=10000 HISTSIZE=10000
SAVEHIST=10000 SAVEHIST=10000

View file

@ -1,6 +1,6 @@
# get the node.js version # get the node.js version
function nvm_prompt_info() { function nvm_prompt_info() {
[ -f $HOME/.nvm/nvm.sh ] || return [ -f "$HOME/.nvm/nvm.sh" ] || return
local nvm_prompt local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null) nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return [[ "${nvm_prompt}x" == "x" ]] && return

View file

@ -8,18 +8,20 @@ fi
# add a function path # add a function path
fpath=($ZSH/functions $ZSH/completions $fpath) fpath=($ZSH/functions $ZSH/completions $fpath)
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
source $config_file
done
# Set ZSH_CUSTOM to the path where your custom config files # Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/ # and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom" ZSH_CUSTOM="$ZSH/custom"
fi fi
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
source $config_file
done
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1

View file

@ -1,6 +1,10 @@
if [ $commands[autojump] ]; then # check if autojump is installed if [ $commands[autojump] ]; then # check if autojump is installed
if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
. $HOME/.autojump/etc/profile.d/autojump.zsh . $HOME/.autojump/etc/profile.d/autojump.zsh
elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation
. $HOME/.autojump/share/autojump/autojump.zsh
elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
. $HOME/.nix-profile/etc/profile.d/autojump.zsh
elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
. /usr/share/autojump/autojump.zsh . /usr/share/autojump/autojump.zsh
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation

View file

@ -3,19 +3,17 @@ _homebrew-installed() {
} }
_awscli-homebrew-installed() { _awscli-homebrew-installed() {
brew --prefix awscli &> /dev/null brew list awscli &> /dev/null
} }
export AWS_HOME=~/.aws export AWS_HOME=~/.aws
function agp { function agp {
echo $AWS_DEFAULT_PROFILE echo $AWS_DEFAULT_PROFILE
} }
function asp { function asp {
export AWS_DEFAULT_PROFILE=$1 export AWS_DEFAULT_PROFILE=$1
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>" export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>"
} }
function aws_profiles { function aws_profiles {
reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/'))
@ -24,7 +22,10 @@ function aws_profiles {
compctl -K aws_profiles asp compctl -K aws_profiles asp
if _homebrew-installed && _awscli-homebrew-installed ; then if _homebrew-installed && _awscli-homebrew-installed ; then
source $(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh _aws_zsh_completer_path=$(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh
else else
source `which aws_zsh_completer.sh` _aws_zsh_completer_path=$(which aws_zsh_completer.sh)
fi fi
[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path

View file

@ -19,21 +19,18 @@ _brew_outdated_formulae() {
outdated_formulae=(`brew outdated`) outdated_formulae=(`brew outdated`)
} }
_brew_running_services() {
running_services=(`brew services list | awk '{print $1}'`)
}
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'audit:check formulae for Homebrew coding style' 'audit:check formulae for Homebrew coding style'
'bundle:look for a Brewfile and run each line as a brew command'
'cat:display formula file for a formula' 'cat:display formula file for a formula'
'cleanup:uninstall unused and old versions of packages' 'cleanup:uninstall unused and old versions of packages'
'commands:show a list of commands' 'commands:show a list of commands'
'create:create a new formula' 'create:create a new formula'
'deps:list dependencies and dependants of a formula' 'deps:list dependencies of a formula'
'doctor:audits your installation for common issues' 'doctor:audits your installation for common issues'
'edit:edit a formula' 'edit:edit a formula'
'fetch:download formula resources to the cache'
'gist-logs:generate a gist of the full build logs'
'home:visit the homepage of a formula or the brew project' 'home:visit the homepage of a formula or the brew project'
'info:information about a formula' 'info:information about a formula'
'install:install a formula' 'install:install a formula'
@ -44,32 +41,24 @@ _1st_arguments=(
'missing:check all installed formuale for missing dependencies.' 'missing:check all installed formuale for missing dependencies.'
'outdated:list formulae for which a newer version is available' 'outdated:list formulae for which a newer version is available'
'pin:pin specified formulae' 'pin:pin specified formulae'
'postinstall:perform post_install for a given formula'
'prune:remove dead links' 'prune:remove dead links'
'remove:remove a formula' 'remove:remove a formula'
'search:search for a formula (/regex/ or string)' 'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)' 'switch:switch linkage between installed versions of a formula'
'services:small wrapper around `launchctl` for supported formulae'
'tap:tap a new formula repository from GitHub, or list existing taps' 'tap:tap a new formula repository from GitHub, or list existing taps'
'test-bot:test a formula and build a bottle'
'uninstall:uninstall a formula' 'uninstall:uninstall a formula'
'unlink:unlink a formula' 'unlink:unlink a formula'
'unpin:unpin specified formulae' 'unpin:unpin specified formulae'
'untap:remove a tapped repository' 'untap:remove a tapped repository'
'update:freshen up links' 'update:pull latest repository'
'upgrade:upgrade outdated formulae' 'upgrade:upgrade outdated formulae'
'uses:show formulae which depend on a formula' 'uses:show formulae which depend on a formula'
) )
local -a _service_arguments
_service_arguments=(
'cleanup:get rid of stale services and unused plists'
'list:list all services managed by `brew services`'
'restart:gracefully restart selected service'
'start:start selected service'
'stop:stop selected service'
)
local expl local expl
local -a formulae installed_formulae installed_taps outdated_formulae running_services local -a formulae installed_formulae installed_taps outdated_formulae
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
@ -80,6 +69,7 @@ _arguments \
'(--version)--version[version information]' \ '(--version)--version[version information]' \
'(--prefix)--prefix[where brew lives on this system]' \ '(--prefix)--prefix[where brew lives on this system]' \
'(--cache)--cache[brew cache]' \ '(--cache)--cache[brew cache]' \
'(--force)--force[brew force]' \
'*:: :->subcmds' && return 0 '*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
@ -109,16 +99,6 @@ case "$words[1]" in
_arguments \ _arguments \
'(--macports)--macports[search the macports repository]' \ '(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;; '(--fink)--fink[search the fink repository]' ;;
services)
if [[ -n "$words[2]" ]]; then
case "$words[2]" in
restart|start|stop)
_brew_running_services
_wanted running_services expl 'running services' compadd -a running_services ;;
esac
else
_describe -t commands "brew services subcommand" _service_arguments
fi ;;
untap) untap)
_brew_installed_taps _brew_installed_taps
_wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;

View file

@ -24,7 +24,7 @@ _homebrew-installed() {
} }
_chruby-from-homebrew-installed() { _chruby-from-homebrew-installed() {
brew --prefix chruby &> /dev/null [ -r $(brew --prefix chruby)] &> /dev/null
} }
_ruby-build_installed() { _ruby-build_installed() {
@ -45,11 +45,11 @@ _source_from_omz_settings() {
zstyle -s :omz:plugins:chruby path _chruby_path zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto zstyle -s :omz:plugins:chruby auto _chruby_auto
if _chruby_path && [[ -r _chruby_path ]]; then if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then
source ${_chruby_path} source ${_chruby_path}
fi fi
if _chruby_auto && [[ -r _chruby_auto ]]; then if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto} source ${_chruby_auto}
fi fi
} }

View file

@ -1,3 +1,21 @@
if [ "$OSTYPE[0,7]" = "solaris" ]
then
if [ ! -x ${HOME}/bin/nroff ]
then
mkdir -p ${HOME}/bin
cat > ${HOME}/bin/nroff <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\${_NROFF_U} "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x ${HOME}/bin/nroff
fi
fi
man() { man() {
env \ env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \
@ -7,5 +25,8 @@ man() {
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \ LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \ LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER=/usr/bin/less \
_NROFF_U=1 \
PATH=${HOME}/bin:${PATH} \
man "$@" man "$@"
} }

View file

@ -46,7 +46,6 @@ alias ff='find . -type f -name'
alias h='history' alias h='history'
alias hgrep="fc -El 0 | grep" alias hgrep="fc -El 0 | grep"
alias help='man' alias help='man'
alias j='jobs'
alias p='ps -f' alias p='ps -f'
alias sortnr='sort -n -r' alias sortnr='sort -n -r'
alias unexport='unset' alias unexport='unset'

View file

@ -5,6 +5,6 @@
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }" eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
zle -N insert-cycledleft zle -N insert-cycledleft
bindkey "\e[1;6D" insert-cycledleft bindkey "\e[1;6D" insert-cycledleft
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }" eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
zle -N insert-cycledright zle -N insert-cycledright
bindkey "\e[1;6C" insert-cycledright bindkey "\e[1;6C" insert-cycledright

View file

@ -3,7 +3,7 @@
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
# #
dirhistory_past=(`pwd`) dirhistory_past=($PWD)
dirhistory_future=() dirhistory_future=()
export dirhistory_past export dirhistory_past
export dirhistory_future export dirhistory_future
@ -50,7 +50,7 @@ function push_future() {
# Called by zsh when directory changes # Called by zsh when directory changes
function chpwd() { function chpwd() {
push_past `pwd` push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...
if [[ -z "${DIRHISTORY_CD+x}" ]]; then if [[ -z "${DIRHISTORY_CD+x}" ]]; then
# ... clear future. # ... clear future.
@ -73,7 +73,7 @@ function dirhistory_back() {
pop_past cw pop_past cw
if [[ "" == "$cw" ]]; then if [[ "" == "$cw" ]]; then
# Someone overwrote our variable. Recover it. # Someone overwrote our variable. Recover it.
dirhistory_past=(`pwd`) dirhistory_past=($PWD)
return return
fi fi

View file

@ -4,6 +4,7 @@
# Requires: Docker installed # Requires: Docker installed
# Author: Azaan (@aeonazaan) # Author: Azaan (@aeonazaan)
# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
# Paul van den Berg (@bergvandenp) for Docker v1.3+
# ----- Helper functions # ----- Helper functions
@ -238,6 +239,14 @@ __wait() {
__docker_containers __docker_containers
} }
__exec() {
_arguments \
'(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
'(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
__docker_containers
}
# end commands --------- # end commands ---------
# ---------------------- # ----------------------
@ -276,6 +285,7 @@ _1st_arguments=(
"top":"Lookup the running processes of a container" "top":"Lookup the running processes of a container"
"version":"Show the docker version information" "version":"Show the docker version information"
"wait":"Block until a container stops, then print its exit code" "wait":"Block until a container stops, then print its exit code"
"exec":"Run a task inside a running container"
) )
_arguments '*:: :->command' _arguments '*:: :->command'
@ -353,4 +363,6 @@ case "$words[1]" in
__version ;; __version ;;
wait) wait)
__wait ;; __wait ;;
exec)
__exec ;;
esac esac

View file

@ -8,21 +8,25 @@
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
function emoji-clock() { function emoji-clock() {
hour=$(date -v '+15M' '+%I') # Add 15 minutes to the current time and save the value as $minutes.
minutes=$(date -v '+15M' '+%M') (( minutes = $(date '+%M') + 15 ))
(( hour = $(date '+%I') + minutes / 60 ))
# make sure minutes and hours don't exceed 60 nor 12 respectively
(( minutes %= 60 )); (( hour %= 12 ))
case $hour in case $hour in
01) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";; 0) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";;
02) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";; 1) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";;
03) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";; 2) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";;
04) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";; 3) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";;
05) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";; 4) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";;
06) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";; 5) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";;
07) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";; 6) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";;
08) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";; 7) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";;
09) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";; 8) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";;
9) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";;
10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";; 10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";;
11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";; 11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";;
12) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";;
*) clock="⌛";; *) clock="⌛";;
esac esac
echo $clock echo $clock

View file

@ -38,7 +38,7 @@ function extract() {
file_name="$( basename "$1" )" file_name="$( basename "$1" )"
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
case "$1" in case "$1" in
(*.tar.gz|*.tgz) tar xvzf "$1" ;; (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \ (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \ && tar --xz -xvf "$1" \
@ -47,7 +47,7 @@ function extract() {
&& tar --lzma -xvf "$1" \ && tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;; || lzcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;; (*.tar) tar xvf "$1" ;;
(*.gz) gunzip "$1" ;; (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;; (*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;; (*.lzma) unlzma "$1" ;;

View file

@ -1,4 +1,4 @@
# Open folder in ForkLift.app of ForkLift2.app from console # Open folder in ForkLift.app or ForkLift2.app from console
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
# Updated to support ForkLift2 by Johan Kaving # Updated to support ForkLift2 by Johan Kaving
# #

View file

@ -118,7 +118,7 @@ alias jquery='frontend jquery'
alias mdn='frontend mdn' alias mdn='frontend mdn'
# pre processors frameworks # pre processors frameworks
alias compass='frontend compass' alias compassdoc='frontend compass'
# important links # important links
alias html5please='frontend html5please' alias html5please='frontend html5please'

View file

@ -1,12 +1,12 @@
function gi() { curl http://www.gitignore.io/api/$@ ;} function gi() { curl -sL https://www.gitignore.io/api/$@ ;}
_gitignireio_get_command_list() { _gitignoreio_get_command_list() {
curl -s http://www.gitignore.io/api/list | tr "," "\n" curl -sL https://www.gitignore.io/api/list | tr "," "\n"
} }
_gitignireio () { _gitignoreio () {
compset -P '*,' compset -P '*,'
compadd -S '' `_gitignireio_get_command_list` compadd -S '' `_gitignoreio_get_command_list`
} }
compdef _gitignireio gi compdef _gitignoreio gi

View file

@ -27,8 +27,6 @@ _1st_arguments=(
"config\:push":"push local config vars to heroku" "config\:push":"push local config vars to heroku"
"config\:set":"set one or more config vars" "config\:set":"set one or more config vars"
"config\:unset":"unset one or more config vars" "config\:unset":"unset one or more config vars"
"db\:push":"push local data up to your app"
"db\:pull":"pull heroku data down into your local database"
"domains":"list custom domains for an app" "domains":"list custom domains for an app"
"domains\:add":"add a custom domain to an app" "domains\:add":"add a custom domain to an app"
"domains\:remove":"remove a custom domain from an app" "domains\:remove":"remove a custom domain from an app"
@ -43,12 +41,20 @@ _1st_arguments=(
"logs\:drains":"manage syslog drains" "logs\:drains":"manage syslog drains"
"maintenance\:on":"put the app into maintenance mode" "maintenance\:on":"put the app into maintenance mode"
"maintenance\:off":"take the app out of maintenance mode" "maintenance\:off":"take the app out of maintenance mode"
"pg\:credentials":"display the DATABASE credentials"
"pg\:diagnose":"run diagnostics report on DATABASE"
"pg\:info":"display database information" "pg\:info":"display database information"
"pg\:ingress":"allow direct connections to the database from this IP for one minute" "pg\:kill":"kill a query"
"pg\:killall":"terminates ALL connections"
"pg\:maintenance":"manage maintenance for DATABASE"
"pg\:promote":"sets DATABASE as your DATABASE_URL" "pg\:promote":"sets DATABASE as your DATABASE_URL"
"pg\:ps":"view active queries with execution time"
"pg\:psql":"open a psql shell to the database" "pg\:psql":"open a psql shell to the database"
"pg\:pull":"pull from REMOTE_SOURCE_DATABASE to LOCAL_TARGET_DATABASE"
"pg\:push":"push from LOCAL_SOURCE_DATABASE to REMOTE_TARGET_DATABASE"
"pg\:reset":"delete all data in DATABASE" "pg\:reset":"delete all data in DATABASE"
"pg\:unfollow":"stop a replica from following and make it a read/write database" "pg\:unfollow":"stop a replica from following and make it a read/write database"
"pg\:upgrade":"unfollow a database and upgrade it to the latest PostgreSQL version"
"pg\:wait":"monitor database creation, exit when complete" "pg\:wait":"monitor database creation, exit when complete"
"pgbackups":"list captured backups" "pgbackups":"list captured backups"
"pgbackups\:url":"get a temporary URL for a backup" "pgbackups\:url":"get a temporary URL for a backup"
@ -108,26 +114,6 @@ case "$words[1]" in
'(-s|--shell)'{-s,--shell}'[output config vars in shell format]' \ '(-s|--shell)'{-s,--shell}'[output config vars in shell format]' \
) )
;; ;;
db:push)
_command_args=(
'(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \
'(-d|--debug)'{-d,--debug}'[enable debugging output]' \
'(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the push]' \
'(-f|--filter)'{-f,--filter}'[only push certain tables]' \
'(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \
'(-t|--tables)'{-t,--tables}'[only push the specified tables]' \
)
;;
db:pull)
_command_args=(
'(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \
'(-d|--debug)'{-d,--debug}'[enable debugging output]' \
'(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the pull]' \
'(-f|--filter)'{-f,--filter}'[only pull certain tables]' \
'(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \
'(-t|--tables)'{-t,--tables}'[only pull the specified tables]' \
)
;;
keys) keys)
_command_args=( _command_args=(
'(-l|--long)'{-l,--long}'[display extended information for each key]' \ '(-l|--long)'{-l,--long}'[display extended information for each key]' \

View file

@ -14,12 +14,12 @@ jump() {
mark() { mark() {
if (( $# == 0 )); then if (( $# == 0 )); then
MARK=$(basename "$(pwd)") MARK=$(basename "$PWD")
else else
MARK="$1" MARK="$1"
fi fi
if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK" mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK"
fi fi
} }

View file

@ -42,7 +42,7 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SU
function hg_dirty_choose { function hg_dirty_choose {
if [ $(in_hg) ]; then if [ $(in_hg) ]; then
hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]' hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
if [ $pipestatus[-1] -eq 0 ]; then if [ $pipestatus[-1] -eq 0 ]; then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1

View file

@ -139,7 +139,7 @@ function man-preview() {
function trash() { function trash() {
local trash_dir="${HOME}/.Trash" local trash_dir="${HOME}/.Trash"
local temp_ifs=$IFS local temp_ifs="$IFS"
IFS=$'\n' IFS=$'\n'
for item in "$@"; do for item in "$@"; do
if [[ -e "$item" ]]; then if [[ -e "$item" ]]; then
@ -177,12 +177,43 @@ function itunes() {
vol) vol)
opt="set sound volume to $1" #$1 Due to the shift opt="set sound volume to $1" #$1 Due to the shift
;; ;;
shuf|shuff|shuffle)
# The shuffle property of current playlist can't be changed in iTunes 12,
# so this workaround uses AppleScript to simulate user input instead.
# Defaults to toggling when no options are given.
# The toggle option depends on the shuffle button being visible in the Now playing area.
# On and off use the menu bar items.
local state=$1
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
then
print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
return 1
fi
case "$state" in
on|off)
# Inspired by: http://stackoverflow.com/a/14675583
osascript 1>/dev/null 2>&1 <<-EOF
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
EOF
return 0
;;
toggle|*)
osascript 1>/dev/null 2>&1 <<-EOF
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
EOF
return 0
;;
esac
;;
""|-h|--help) ""|-h|--help)
echo "Usage: itunes <option>" echo "Usage: itunes <option>"
echo "option:" echo "option:"
echo "\tlaunch|play|pause|stop|rewind|resume|quit" echo "\tlaunch|play|pause|stop|rewind|resume|quit"
echo "\tmute|unmute\tcontrol volume set" echo "\tmute|unmute\tcontrol volume set"
echo "\tnext|previous\tplay next or previous track" echo "\tnext|previous\tplay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\tvol\tSet the volume, takes an argument from 0 to 100"
echo "\thelp\tshow this message and exit" echo "\thelp\tshow this message and exit"
return 0 return 0

View file

@ -1,13 +1,13 @@
_phing_does_target_list_need_generating () { _phing_does_target_list_need_generating () {
[ ! -f .phing_targets ] && return 0; [ ! -f .phing_targets ] && return 0;
[ .phing_targets -nt build.xml ] && return 0; [ build.xml -nt .phing_targets ] && return 0;
return 1; return 1;
} }
_phing () { _phing () {
if [ -f build.xml ]; then if [ -f build.xml ]; then
if _phing_does_target_list_need_generating; then if _phing_does_target_list_need_generating; then
phing -l |grep -v ":$" |grep -v "^-*$" > .phing_targets phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets
fi fi
compadd `cat .phing_targets` compadd `cat .phing_targets`
fi fi

View file

@ -18,8 +18,11 @@ function pj() {
file=$1 file=$1
if [[ "open" == "$file" ]] then if [[ "open" == "$file" ]] then
file=$2 shift
file=$*
cmd=(${(s: :)EDITOR}) cmd=(${(s: :)EDITOR})
else
file=$*
fi fi
for project in $PROJECT_PATHS; do for project in $PROJECT_PATHS; do
@ -36,7 +39,11 @@ function pj() {
alias pjo="pj open" alias pjo="pj open"
function _pj () { function _pj () {
compadd `/bin/ls -l $PROJECT_PATHS 2>/dev/null | awk '{ print $9 }'` # might be possible to improve this using glob, without the basename trick
typeset -a projects
projects=($PROJECT_PATHS/*)
projects=$projects:t
_arguments "*:file:($projects)"
} }
compdef _pj pj compdef _pj pj

View file

@ -21,13 +21,13 @@
rack_root(){ rack_root(){
setopt chaselinks setopt chaselinks
local orgdir="$(pwd)" local orgdir="$PWD"
local basedir="$(pwd)" local basedir="$PWD"
while [[ $basedir != '/' ]]; do while [[ $basedir != '/' ]]; do
test -e "$basedir/config.ru" && break test -e "$basedir/config.ru" && break
builtin cd ".." 2>/dev/null builtin cd ".." 2>/dev/null
basedir="$(pwd)" basedir="$PWD"
done done
builtin cd "$orgdir" 2>/dev/null builtin cd "$orgdir" 2>/dev/null
@ -56,7 +56,7 @@ kapow(){
compctl -W ~/.pow -/ kapow compctl -W ~/.pow -/ kapow
powit(){ powit(){
local basedir="$(pwd)" local basedir="$PWD"
local vhost=$1 local vhost=$1
[ ! -n "$vhost" ] && vhost=$(rack_root_detect) [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
if [ ! -h ~/.pow/$vhost ] if [ ! -h ~/.pow/$vhost ]

View file

@ -2,7 +2,7 @@
# This will look for a custom profile for the local machine and each domain or # This will look for a custom profile for the local machine and each domain or
# subdomain it belongs to. (e.g. com, example.com and foo.example.com) # subdomain it belongs to. (e.g. com, example.com and foo.example.com)
parts=(${(s:.:)$(hostname)}) parts=(${(s:.:)HOST})
for i in {${#parts}..1}; do for i in {${#parts}..1}; do
profile=${(j:.:)${parts[$i,${#parts}]}} profile=${(j:.:)${parts[$i,${#parts}]}}
file=$ZSH_CUSTOM/profiles/$profile file=$ZSH_CUSTOM/profiles/$profile

View file

@ -6,7 +6,7 @@ function _rails_command () {
elif [ -e "script/server" ]; then elif [ -e "script/server" ]; then
ruby script/$@ ruby script/$@
else else
rails $@ command rails $@
fi fi
} }
@ -14,7 +14,7 @@ function _rake_command () {
if [ -e "bin/rake" ]; then if [ -e "bin/rake" ]; then
bin/rake $@ bin/rake $@
else else
rake $@ command rake $@
fi fi
} }

View file

@ -11,12 +11,9 @@ the index. A selection menu is displayed in case of several matches, with a
preference given to recently visited paths. `scd` can create permanent preference given to recently visited paths. `scd` can create permanent
directory aliases, which appear as named directories in zsh session. directory aliases, which appear as named directories in zsh session.
## INSTALLATION ## INSTALLATION NOTES
For oh-my-zsh, add `scd` to the `plugins` array in the ~/.zshrc file as in the Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
[template file](../../templates/zshrc.zsh-template#L45).
Besides zsh, `scd` can be used with *bash*, *dash* or *tcsh*
shells and is also available as [Vim](http://www.vim.org/) plugin and shells and is also available as [Vim](http://www.vim.org/) plugin and
[IPython](http://ipython.org/) extension. For installation details, see [IPython](http://ipython.org/) extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory. https://github.com/pavoljuhas/smart-change-directory.
@ -34,7 +31,7 @@ scd [options] [pattern1 pattern2 ...]
add specified directories to the directory index.</dd><dt> add specified directories to the directory index.</dd><dt>
--unindex</dt><dd> --unindex</dt><dd>
remove specified directories from the index.</dd><dt> remove current or specified directories from the index.</dd><dt>
-r, --recursive</dt><dd> -r, --recursive</dt><dd>
apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt> apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt>
@ -47,6 +44,10 @@ scd [options] [pattern1 pattern2 ...]
remove ALIAS definition for the current or specified directory from remove ALIAS definition for the current or specified directory from
<em>~/.scdalias.zsh</em>.</dd><dt> <em>~/.scdalias.zsh</em>.</dd><dt>
-A, --all</dt><dd>
include all matching directories. Disregard matching by directory
alias and filtering of less likely paths.</dd><dt>
--list</dt><dd> --list</dt><dd>
show matching directories and exit.</dd><dt> show matching directories and exit.</dd><dt>
@ -70,7 +71,7 @@ scd doc
scd a b c scd a b c
# Change to a directory path that ends with "ts" # Change to a directory path that ends with "ts"
scd "ts(#e)" scd "ts$"
# Show selection menu and ranking of 20 most likely directories # Show selection menu and ranking of 20 most likely directories
scd -v scd -v

View file

@ -11,20 +11,22 @@ fi
local DOC='scd -- smart change to a recently used directory local DOC='scd -- smart change to a recently used directory
usage: scd [options] [pattern1 pattern2 ...] usage: scd [options] [pattern1 pattern2 ...]
Go to a directory path that contains all fixed string patterns. Prefer Go to a directory path that contains all fixed string patterns. Prefer
recently visited directories and directories with patterns in their tail recent or frequently visited directories as found in the directory index.
component. Display a selection menu in case of multiple matches. Display a selection menu in case of multiple matches.
Options: Options:
-a, --add add specified directories to the directory index -a, --add add specified directories to the directory index.
--unindex remove specified directories from the index --unindex remove current or specified directories from the index.
-r, --recursive apply options --add or --unindex recursively -r, --recursive apply options --add or --unindex recursively.
--alias=ALIAS create alias for the current or specified directory and --alias=ALIAS create alias for the current or specified directory and
store it in ~/.scdalias.zsh store it in ~/.scdalias.zsh.
--unalias remove ALIAS definition for the current or specified --unalias remove ALIAS definition for the current or specified
directory from ~/.scdalias.zsh directory from ~/.scdalias.zsh.
--list show matching directories and exit -A, --all include all matching directories. Disregard matching by
-v, --verbose display directory rank in the selection menu directory alias and filtering of less likely paths.
-h, --help display this message and exit --list show matching directories and exit.
-v, --verbose display directory rank in the selection menu.
-h, --help display this message and exit.
' '
local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory} local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory}
@ -35,9 +37,9 @@ local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT} local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
local SCD_ALIAS=~/.scdalias.zsh local SCD_ALIAS=~/.scdalias.zsh
local ICASE a d m p i tdir maxrank threshold local ICASE a d m p i maxrank threshold
local opt_help opt_add opt_unindex opt_recursive opt_verbose local opt_help opt_add opt_unindex opt_recursive opt_verbose
local opt_alias opt_unalias opt_list local opt_alias opt_unalias opt_all opt_list
local -A drank dalias local -A drank dalias
local dmatching local dmatching
local last_directory local last_directory
@ -56,7 +58,8 @@ zmodload -i zsh/zutil
zmodload -i zsh/datetime zmodload -i zsh/datetime
zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \ zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
r=opt_recursive -recursive=opt_recursive \ r=opt_recursive -recursive=opt_recursive \
-alias:=opt_alias -unalias=opt_unalias -list=opt_list \ -alias:=opt_alias -unalias=opt_unalias \
A=opt_all -all=opt_all -list=opt_list \
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \ v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|| $EXIT $? || $EXIT $?
@ -68,6 +71,11 @@ fi
# load directory aliases if they exist # load directory aliases if they exist
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS [[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
# Private internal functions are prefixed with _scd_Y19oug_.
# Clean them up when the scd function returns.
setopt localtraps
trap 'unfunction -m "_scd_Y19oug_*"' EXIT
# works faster than the (:a) modifier and is compatible with zsh 4.2.6 # works faster than the (:a) modifier and is compatible with zsh 4.2.6
_scd_Y19oug_abspath() { _scd_Y19oug_abspath() {
set -A $1 ${(ps:\0:)"$( set -A $1 ${(ps:\0:)"$(
@ -123,11 +131,52 @@ if [[ -n $opt_unalias ]]; then
$EXIT $? $EXIT $?
fi fi
# The "compress" function collapses repeated directories to
# one entry with a time stamp that gives equivalent-probability.
_scd_Y19oug_compress() {
awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
BEGIN { FS = "[:;]"; }
length($0) < 4096 && $2 > 0 {
tau = 1.0 * ($2 - epochseconds) / meanlife;
if (tau < -6.9078) tau = -6.9078;
prob = exp(tau);
sub(/^[^;]*;/, "");
if (NF) {
dlist[last[$0]] = "";
dlist[NR] = $0;
last[$0] = NR;
ptot[$0] += prob;
}
}
END {
for (i = 1; i <= NR; ++i) {
d = dlist[i];
if (d) {
ts = log(ptot[d]) * meanlife + epochseconds;
printf(": %.0f:0;%s\n", ts, d);
}
}
}
' $*
}
# Rewrite directory index if it is at least 20% oversized # Rewrite directory index if it is at least 20% oversized
if [[ -s $SCD_HISTFILE ]] && \ if [[ -s $SCD_HISTFILE ]] && \
(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then (( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
m=( ${(f)"$(<$SCD_HISTFILE)"} ) # compress repeated entries
print -lr -- ${m[-$SCD_HISTSIZE,-1]} >| ${SCD_HISTFILE} m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
# purge non-existent directories
m=( ${(f)"$(
for a in $m; do
if [[ -d ${a#*;} ]]; then print -r -- $a; fi
done
)"}
)
# cut old entries if still oversized
if [[ $#m -gt $SCD_HISTSIZE ]]; then
m=( ${m[-$SCD_HISTSIZE,-1]} )
fi
print -lr -- $m >| ${SCD_HISTFILE}
fi fi
# Determine the last recorded directory # Determine the last recorded directory
@ -135,7 +184,6 @@ if [[ -s ${SCD_HISTFILE} ]]; then
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;} last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
fi fi
# Internal functions are prefixed with "_scd_Y19oug_".
# The "record" function adds its arguments to the directory index. # The "record" function adds its arguments to the directory index.
_scd_Y19oug_record() { _scd_Y19oug_record() {
while [[ -n $last_directory && $1 == $last_directory ]]; do while [[ -n $last_directory && $1 == $last_directory ]]; do
@ -217,7 +265,7 @@ _scd_Y19oug_action() {
# set global arrays dmatching and drank # set global arrays dmatching and drank
_scd_Y19oug_match() { _scd_Y19oug_match() {
## single argument that is an existing directory or directory alias ## single argument that is an existing directory or directory alias
if [[ $# == 1 ]] && \ if [[ -z $opt_all && $# == 1 ]] && \
[[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]]; [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
then then
_scd_Y19oug_abspath dmatching $d _scd_Y19oug_abspath dmatching $d
@ -227,6 +275,8 @@ _scd_Y19oug_match() {
# ignore case unless there is an argument with an uppercase letter # ignore case unless there is an argument with an uppercase letter
[[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)' [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
# support "$" as an anchor for the directory name ending
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
# calculate rank of all directories in the SCD_HISTFILE and keep it as drank # calculate rank of all directories in the SCD_HISTFILE and keep it as drank
# include a dummy entry for splitting of an empty string is buggy # include a dummy entry for splitting of an empty string is buggy
@ -237,10 +287,10 @@ _scd_Y19oug_match() {
BEGIN { FS = "[:;]"; } BEGIN { FS = "[:;]"; }
length($0) < 4096 && $2 > 0 { length($0) < 4096 && $2 > 0 {
tau = 1.0 * ($2 - epochseconds) / meanlife; tau = 1.0 * ($2 - epochseconds) / meanlife;
if (tau < -4.61) tau = -4.61; if (tau < -6.9078) tau = -6.9078;
prec = exp(tau); prob = exp(tau);
sub(/^[^;]*;/, ""); sub(/^[^;]*;/, "");
if (NF) ptot[$0] += prec; if (NF) ptot[$0] += prob;
} }
END { for (di in ptot) { print di; print ptot[di]; } }' END { for (di in ptot) { print di; print ptot[di]; } }'
)"} )"}
@ -249,9 +299,12 @@ _scd_Y19oug_match() {
# filter drank to the entries that match all arguments # filter drank to the entries that match all arguments
for a; do for a; do
p=${ICASE}"*${a}*" p=${ICASE}"*(${a})*"
drank=( ${(kv)drank[(I)${~p}]} ) drank=( ${(kv)drank[(I)${~p}]} )
done done
# require at least one argument matches the directory name
p=${ICASE}"*(${(j:|:)argv})[^/]#"
drank=( ${(kv)drank[(I)${~p}]} )
# build a list of matching directories reverse-sorted by their probabilities # build a list of matching directories reverse-sorted by their probabilities
dmatching=( ${(f)"$( dmatching=( ${(f)"$(
@ -261,26 +314,6 @@ _scd_Y19oug_match() {
)"} )"}
) )
# if some directory paths match all patterns in order, discard all others
p=${ICASE}"*${(j:*:)argv}*"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match last pattern, discard all others
p=${ICASE}"*${(j:*:)argv}[^/]#"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match all patterns, discard all others
m=( $dmatching )
for a; do
p=${ICASE}"*/[^/]#${a}[^/]#"
m=( ${(M)m:#${~p}} )
done
[[ -d ${m[1]} ]] && dmatching=( $m )
# if some directory names match all patterns in order, discard all others
p=${ICASE}"/*${(j:[^/]#:)argv}[^/]#"
m=( ${(M)dmatching:#${~p}} )
[[ -d ${m[1]} ]] && dmatching=( $m )
# do not match $HOME or $PWD when run without arguments # do not match $HOME or $PWD when run without arguments
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
dmatching=( ${dmatching:#(${HOME}|${PWD})} ) dmatching=( ${dmatching:#(${HOME}|${PWD})} )
@ -302,6 +335,9 @@ _scd_Y19oug_match() {
# discard all directories below the rank threshold # discard all directories below the rank threshold
threshold=$(( maxrank * SCD_THRESHOLD )) threshold=$(( maxrank * SCD_THRESHOLD ))
if [[ -n ${opt_all} ]]; then
threshold=0
fi
dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) ) dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) )
} }
@ -339,6 +375,7 @@ fi
## here we have multiple matches - display selection menu ## here we have multiple matches - display selection menu
a=( {a-z} {A-Z} ) a=( {a-z} {A-Z} )
a=( ${a[1,${#dmatching}]} )
p=( ) p=( )
for i in {1..${#dmatching}}; do for i in {1..${#dmatching}}; do
[[ -n ${a[i]} ]] || break [[ -n ${a[i]} ]] || break

View file

@ -63,11 +63,11 @@ function svn_current_revision() {
function svn_status_info() { function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)"; local svn_status="$(svn status 2> /dev/null)";
if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi
if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi
if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi
if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
echo $svn_status_string echo $svn_status_string
} }

View file

@ -61,7 +61,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() { function svn_dirty_choose() {
if in_svn; then if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
@ -77,8 +77,8 @@ function svn_dirty() {
function svn_dirty_choose_pwd () { function svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
root=`pwd` root=$PWD
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else

View file

@ -5,7 +5,7 @@ _symfony_console () {
} }
_symfony2_get_command_list () { _symfony2_get_command_list () {
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
} }
_symfony2 () { _symfony2 () {

View file

@ -30,7 +30,7 @@ function retlog() {
} }
alias ping='ping -c 5' alias ping='ping -c 5'
alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."' alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."'
alias path='echo -e ${PATH//:/\\n}' alias path='echo -e ${PATH//:/\\n}'
alias mkdir='mkdir -pv' alias mkdir='mkdir -pv'
# get top process eating memory # get top process eating memory

View file

@ -5,6 +5,8 @@
alias ta='tmux attach -t' alias ta='tmux attach -t'
alias ts='tmux new-session -s' alias ts='tmux new-session -s'
alias tl='tmux list-sessions' alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
# Only run if tmux is actually installed # Only run if tmux is actually installed
if which tmux &> /dev/null if which tmux &> /dev/null

View file

@ -9,7 +9,7 @@ function resolveFile
if [ -f "$1" ]; then if [ -f "$1" ]; then
echo $(readlink -f "$1") echo $(readlink -f "$1")
elif [[ "${1#/}" == "$1" ]]; then elif [[ "${1#/}" == "$1" ]]; then
echo "$(pwd)/$1" echo "$PWD/$1"
else else
echo $1 echo $1
fi fi

View file

@ -1,7 +1,6 @@
function virtualenv_prompt_info(){ function virtualenv_prompt_info(){
if [[ -n $VIRTUAL_ENV ]]; then [[ -n ${VIRTUAL_ENV} ]] || return
printf "%s[%s] " "%{${fg[yellow]}%}" ${${VIRTUAL_ENV}:t} echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
fi
} }
# disables prompt mangling in virtual_env/bin/activate # disables prompt mangling in virtual_env/bin/activate

View file

@ -1,57 +1,63 @@
virtualenvwrapper='virtualenvwrapper.sh' virtualenvwrapper='virtualenvwrapper.sh'
if (( $+commands[$virtualenvwrapper] )); then if (( $+commands[$virtualenvwrapper] )); then
source ${${virtualenvwrapper}:c} source ${${virtualenvwrapper}:c}
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ "$WORKON_HOME" == "" ]]; then
# Automatically activate Git projects's virtual environments based on the echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work"
# directory name of the project. Virtual environment name can be overridden else
# 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 [ $CD_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 if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# http://zsh.sourceforge.net/Doc/Release/Functions.html # Automatically activate Git projects's virtual environments based on the
# TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 # directory name of the project. Virtual environment name can be overridden
if (( ${+chpwd_functions} )); then # by placing a .venv file in the project root with a virtualenv name in it
if (( $chpwd_functions[(I)workon_cwd] == 0 )); then function workon_cwd {
set -A chpwd_functions $chpwd_functions 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 [ $CD_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 fi
else }
# 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 set -A chpwd_functions workon_cwd
fi
fi fi
fi fi
else else

View file

@ -1,8 +1,60 @@
## wd wd
==
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path.
### Setup
### oh-my-zsh
`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
Just add the plugin in your `~/.zshrc` file:
plugins=(... wd)
#### Automatic
Run either in terminal:
* `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh`
* `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
#### Manual
* Clone this repo to your liking
* Add `wd` function to `.zshrc` (or `.profile` etc.):
wd() {
. ~/paht/to/wd/wd.sh
}
* Install manpage. From `wd`'s base directory (requires root permissions):
# cp wd.1 /usr/share/man/man1/wd.1
# chmod 644 /usr/share/man/man1/wd.1
Note, when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
#### Completion
If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utelize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
fpath=(~/path/to/wd $fpath)
Also, you may have to force a rebuild of `zcompdump` by running:
$ rm -f ~/.zcompdump; compinit
**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd)
### Usage ### Usage
@ -24,6 +76,7 @@
$ wd ... $ wd ...
This is a wrapper for the zsh `dirs` function. This is a wrapper for the zsh `dirs` function.
(You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)).
* Remove warp point test point: * Remove warp point test point:
@ -33,8 +86,55 @@
$ wd ls $ wd ls
* List warp points to current directory * List warp points to current directory, or optionally, path to given warp point:
$ wd show $ wd show
* Print usage with no opts or the `help` argument. * Remove warp points to non-existent directories.
$ wd clean
Use `clean!` to not be prompted with confirmation (force).
* Print usage with no opts or the `help` argument:
$ wd help
* Print the running version of `wd`:
$ wd --version
* Specifically set the config file (default `~/.warprc`), which is useful when testing:
$ wd --config ./file <action>
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required when testing/debugging.
$ wd --debug <action>
* Silence all output:
$ wd --quiet <action>
### Testing
`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as it should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
$ ./tests.sh
### License
The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
### Finally
If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. Explanation on how to run the tests, read the section "Testing" in this README.
Credit to [altschuler](https://github.com/altschuler) for awesome idea.
Hope you enjoy!

View file

@ -21,7 +21,8 @@ function _wd() {
'add!:Overwrites existing warp point' 'add!:Overwrites existing warp point'
'rm:Removes the given warp point' 'rm:Removes the given warp point'
'ls:Outputs all stored warp points' 'ls:Outputs all stored warp points'
'show:Outputs all warp points that point to the current directory' 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
'help:Show this extremely helpful text' 'help:Show this extremely helpful text'
'..:Go back to last directory' '..:Go back to last directory'
) )
@ -43,6 +44,9 @@ function _wd() {
add) add)
_message 'Write the name of your warp point' && ret=0 _message 'Write the name of your warp point' && ret=0
;; ;;
show)
_describe -t points "Warp points" warp_points && ret=0
;;
esac esac
;; ;;
esac esac

View file

@ -7,25 +7,301 @@
# #
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
# version
## variables readonly WD_VERSION=0.4
readonly CONFIG=$HOME/.warprc
# colors # colors
readonly BLUE="\033[96m" readonly WD_BLUE="\033[96m"
readonly GREEN="\033[92m" readonly WD_GREEN="\033[92m"
readonly YELLOW="\033[93m" readonly WD_YELLOW="\033[93m"
readonly RED="\033[91m" readonly WD_RED="\033[91m"
readonly NOC="\033[m" readonly WD_NOC="\033[m"
## functions
## init # helpers
wd_yesorno()
{
# variables
local question="${1}"
local prompt="${question} "
local yes_RETVAL="0"
local no_RETVAL="3"
local RETVAL=""
local answer=""
# read-eval loop
while true ; do
printf $prompt
read -r answer
case ${answer:=${default}} in
Y|y|YES|yes|Yes )
RETVAL=${yes_RETVAL} && \
break
;;
N|n|NO|no|No )
RETVAL=${no_RETVAL} && \
break
;;
* )
echo "Please provide a valid answer (y or n)"
;;
esac
done
return ${RETVAL}
}
wd_print_msg()
{
if [[ -z $wd_quiet_mode ]]
then
local color=$1
local msg=$2
if [[ $color == "" || $msg == "" ]]
then
print " ${WD_RED}*${WD_NOC} Could not print message. Sorry!"
else
print " ${color}*${WD_NOC} ${msg}"
fi
fi
}
wd_print_usage()
{
cat <<- EOF
Usage: wd [command] <point>
Commands:
add <point> Adds the current working directory to your warp points
add! <point> Overwrites existing warp point
rm <point> Removes the given warp point
show Print warp points to current directory
show <point> Print path to given warp point
ls Print all stored warp points
clean! Remove points warping to nonexistent directories
-v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
help Show this extremely helpful text
EOF
}
wd_exit_fail()
{
local msg=$1
wd_print_msg $WD_RED $1
WD_EXIT_CODE=1
}
wd_exit_warn()
{
local msg=$1
wd_print_msg $WD_YELLOW $msg
WD_EXIT_CODE=1
}
# core
wd_warp()
{
local point=$1
if [[ $point =~ "^\.+$" ]]
then
if [ $#1 < 2 ]
then
wd_exit_warn "Warping to current directory?"
else
(( n = $#1 - 1 ))
cd -$n > /dev/null
fi
elif [[ ${points[$point]} != "" ]]
then
cd ${points[$point]}
else
wd_exit_fail "Unknown warp point '${point}'"
fi
}
wd_add()
{
local force=$1
local point=$2
if [[ $point =~ "^[\.]+$" ]]
then
wd_exit_fail "Warp point cannot be just dots"
elif [[ $point =~ "[[:space:]]+" ]]
then
wd_exit_fail "Warp point should not contain whitespace"
elif [[ $point == *:* ]]
then
wd_exit_fail "Warp point cannot contain colons"
elif [[ $point == "" ]]
then
wd_exit_fail "Warp point cannot be empty"
elif [[ ${points[$2]} == "" ]] || $force
then
wd_remove $point > /dev/null
printf "%q:%s\n" "${point}" "${PWD}" >> $WD_CONFIG
wd_print_msg $WD_GREEN "Warp point added"
# override exit code in case wd_remove did not remove any points
# TODO: we should handle this kind of logic better
WD_EXIT_CODE=0
else
wd_exit_warn "Warp point '${point}' already exists. Use 'add!' to overwrite."
fi
}
wd_remove()
{
local point=$1
if [[ ${points[$point]} != "" ]]
then
local config_tmp=$WD_CONFIG.tmp
if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && mv $config_tmp $WD_CONFIG
then
wd_print_msg $WD_GREEN "Warp point removed"
else
wd_exit_fail "Something bad happened! Sorry."
fi
else
wd_exit_fail "Warp point was not found"
fi
}
wd_list_all()
{
wd_print_msg $WD_BLUE "All warp points:"
while IFS= read -r line
do
if [[ $line != "" ]]
then
arr=(${(s,:,)line})
key=${arr[1]}
val=${arr[2]}
if [[ -z $wd_quiet_mode ]]
then
printf "%20s -> %s\n" $key $val
fi
fi
done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG)
}
wd_show()
{
local name_arg=$1
# if there's an argument we look up the value
if [[ ! -z $name_arg ]]
then
if [[ -z $points[$name_arg] ]]
then
wd_print_msg $WD_BLUE "No warp point named $name_arg"
else
wd_print_msg $WD_GREEN "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
fi
else
# hax to create a local empty array
local wd_matches
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
if [[ ${points[(r)$PWD]} == $PWD ]]
then
for name in ${(k)points}
do
if [[ $points[$name] == $PWD ]]
then
wd_matches[$(($#wd_matches+1))]=$name
fi
done
wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
else
wd_print_msg $WD_YELLOW "No warp point to $(echo $PWD | sed "s:$HOME:~:")"
fi
fi
}
wd_clean() {
local force=$1
local count=0
local wd_tmp=""
while read line
do
if [[ $line != "" ]]
then
arr=(${(s,:,)line})
key=${arr[1]}
val=${arr[2]}
if [ -d "$val" ]
then
wd_tmp=$wd_tmp"\n"`echo $line`
else
wd_print_msg $WD_YELLOW "Nonexistent directory: ${key} -> ${val}"
count=$((count+1))
fi
fi
done < $WD_CONFIG
if [[ $count -eq 0 ]]
then
wd_print_msg $WD_BLUE "No warp points to clean, carry on!"
else
if $force || wd_yesorno "Removing ${count} warp points. Continue? (Y/n)"
then
echo $wd_tmp >! $WD_CONFIG
wd_print_msg $WD_GREEN "Cleanup complete. ${count} warp point(s) removed"
else
wd_print_msg $WD_BLUE "Cleanup aborted"
fi
fi
}
local WD_CONFIG=$HOME/.warprc
local WD_QUIET=0
local WD_EXIT_CODE=0
local WD_DEBUG=0
# Parse 'meta' options first to avoid the need to have them before
# other commands. The `-D` flag consumes recognized options so that
# the actual command parsing won't be affected.
zparseopts -D -E \
c:=wd_alt_config -config:=wd_alt_config \
q=wd_quiet_mode -quiet=wd_quiet_mode \
v=wd_print_version -version=wd_print_version \
d=wd_debug_mode -debug=wd_debug_mode
if [[ ! -z $wd_print_version ]]
then
echo "wd version $WD_VERSION"
fi
if [[ ! -z $wd_alt_config ]]
then
WD_CONFIG=$wd_alt_config[2]
fi
# check if config file exists # check if config file exists
if [ ! -e $CONFIG ] if [ ! -e $WD_CONFIG ]
then then
# if not, create config file # if not, create config file
touch $CONFIG touch $WD_CONFIG
fi fi
# load warp points # load warp points
@ -37,149 +313,26 @@ do
val=${arr[2]} val=${arr[2]}
points[$key]=$val points[$key]=$val
done < $CONFIG done < $WD_CONFIG
## functions
wd_warp()
{
local point=$1
if [[ $point =~ "^\.+$" ]]
then
if [ $#1 < 2 ]
then
wd_print_msg $YELLOW "Warping to current directory?"
else
(( n = $#1 - 1 ))
cd -$n > /dev/null
fi
elif [[ ${points[$point]} != "" ]]
then
cd ${points[$point]}
else
wd_print_msg $RED "Unknown warp point '${point}'"
fi
}
wd_add()
{
local force=$1
local point=$2
if [[ $point =~ "^[\.]+$" ]]
then
wd_print_msg $RED "Warp point cannot be just dots"
elif [[ $point =~ "(\s|\ )+" ]]
then
wd_print_msg $RED "Warp point should not contain whitespace"
elif [[ $point == *:* ]]
then
wd_print_msg $RED "Warp point cannot contain colons"
elif [[ $point == "" ]]
then
wd_print_msg $RED "Warp point cannot be empty"
elif [[ ${points[$2]} == "" ]] || $force
then
wd_remove $point > /dev/null
printf "%q:%q\n" "${point}" "${PWD}" >> $CONFIG
wd_print_msg $GREEN "Warp point added"
else
wd_print_msg $YELLOW "Warp point '${point}' already exists. Use 'add!' to overwrite."
fi
}
wd_remove()
{
local point=$1
if [[ ${points[$point]} != "" ]]
then
if sed -i.bak "s,^${point}:.*$,,g" $CONFIG
then
wd_print_msg $GREEN "Warp point removed"
else
wd_print_msg $RED "Something bad happened! Sorry."
fi
else
wd_print_msg $RED "Warp point was not found"
fi
}
wd_list_all()
{
wd_print_msg $BLUE "All warp points:"
while IFS= read -r line
do
if [[ $line != "" ]]
then
arr=(${(s,:,)line})
key=${arr[1]}
val=${arr[2]}
printf "%20s -> %s\n" $key $val
fi
done <<< $(sed "s:${HOME}:~:g" $CONFIG)
}
wd_show()
{
local cwd=$(print $PWD | sed "s:^${HOME}:~:")
wd_print_msg $BLUE "Warp points to current directory:"
wd_list_all | grep -e "${cwd}$"
}
wd_print_msg()
{
local color=$1
local msg=$2
if [[ $color == "" || $msg == "" ]]
then
print " ${RED}*${NOC} Could not print message. Sorry!"
else
print " ${color}*${NOC} ${msg}"
fi
}
wd_print_usage()
{
cat <<- EOF
Usage: wd [add|-a|--add] [rm|-r|--remove] <point>
Commands:
add Adds the current working directory to your warp points
add! Overwrites existing warp point
rm Removes the given warp point
show Outputs warp points to current directory
ls Outputs all stored warp points
help Show this extremely helpful text
EOF
}
## run
# get opts # get opts
args=$(getopt -o a:r:lhs -l add:,rm:,ls,help,show -- $*) args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,ls,help,show -- $*)
# check if no arguments were given # check if no arguments were given, and that version is not set
if [[ $? -ne 0 || $#* -eq 0 ]] if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
then then
wd_print_usage wd_print_usage
# check if config file is writeable # check if config file is writeable
elif [ ! -w $CONFIG ] elif [ ! -w $WD_CONFIG ]
then then
# do nothing # do nothing
# can't run `exit`, as this would exit the executing shell # can't run `exit`, as this would exit the executing shell
wd_print_msg $RED "\'$CONFIG\' is not writeable." wd_exit_fail "\'$WD_CONFIG\' is not writeable."
else else
# parse rest of options
for o for o
do do
case "$o" case "$o"
@ -205,7 +358,15 @@ else
break break
;; ;;
-s|--show|show) -s|--show|show)
wd_show wd_show $2
break
;;
-c|--clean|clean)
wd_clean false
break
;;
-c!|--clean!|clean!)
wd_clean true
break break
;; ;;
*) *)
@ -229,8 +390,19 @@ unset wd_remove
unset wd_show unset wd_show
unset wd_list_all unset wd_list_all
unset wd_print_msg unset wd_print_msg
unset wd_yesorno
unset wd_print_usage unset wd_print_usage
unset wd_alt_config
unset wd_quiet_mode
unset wd_print_version
unset args unset args
unset points unset points
unset val &> /dev/null # fixes issue #1 unset val &> /dev/null # fixes issue #1
if [[ ! -z $wd_debug_mode ]]
then
exit $WD_EXIT_CODE
else
unset wd_debug_mode
fi

View file

@ -37,8 +37,7 @@ function web_search() {
done done
url="${url%?}" # remove the last '+' url="${url%?}" # remove the last '+'
nohup $open_cmd "$url" nohup $open_cmd "$url" >/dev/null 2&>1
rm nohup.out
} }

View file

@ -16,4 +16,10 @@ function xcsel {
alias xcb='xcodebuild' alias xcb='xcodebuild'
alias xcp='xcode-select --print-path' alias xcp='xcode-select --print-path'
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'
else
alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app'
fi

7
plugins/yii2/README.md Normal file
View file

@ -0,0 +1,7 @@
# Yii2 autocomplete plugin
* Adds autocomplete commands and subcommands for yii.
## Requirements
Autocomplete works from directory where your `yii` file contains.

View file

@ -0,0 +1,29 @@
# Yii2 command completion
_yii2_format_command () {
awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }'
}
_yii2 () {
if [ -f ./yii ]; then
_arguments \
'1: :->command'\
'*: :->params'
case $state in
command)
local -a commands
local -a name
if [[ $words[2] == *\/ ]]; then
name=$words[2]
fi
commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"})
compadd -Q -S '' -a -- commands
esac
fi
}
compdef _yii2 yii

View file

@ -47,13 +47,13 @@ DISABLE_AUTO_UPDATE="true"
# Add wisely, as too many plugins slow down shell startup. # Add wisely, as too many plugins slow down shell startup.
plugins=(git) plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration # User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH export PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH" # export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
# You may need to manually set your language environment # You may need to manually set your language environment
# export LANG=en_US.UTF-8 # export LANG=en_US.UTF-8

View file

@ -89,9 +89,8 @@ function precmd {
# Context: user@directory or just directory # Context: user@directory or just directory
prompt_context () { prompt_context () {
local user=`whoami` if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
else else
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
fi fi

View file

@ -60,10 +60,8 @@ prompt_end() {
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
local user=`whoami` if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
fi fi
} }
@ -125,10 +123,10 @@ prompt_hg() {
st="" st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null) branch=$(hg id -b 2>/dev/null)
if `hg st | grep -Eq "^\?"`; then if `hg st | grep -q "^\?"`; then
prompt_segment red black prompt_segment red black
st='±' st='±'
elif `hg st | grep -Eq "^(M|A)"`; then elif `hg st | grep -q "^(M|A)"`; then
prompt_segment yellow black prompt_segment yellow black
st='±' st='±'
else else

View file

@ -31,7 +31,7 @@ bureau_git_status () {
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi fi
if $(echo "$_INDEX" | grep -E '^\?\? ' &> /dev/null); then if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi fi
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then

View file

@ -13,7 +13,7 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
} }
PROMPT=' PROMPT='

View file

@ -21,7 +21,7 @@ local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}"
# Hostname part. compressed and colorcoded per host_repr array # Hostname part. compressed and colorcoded per host_repr array
# if not found, regular hostname in default color # if not found, regular hostname in default color
local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}" local host="@${host_repr[$HOST]:-$HOST}%{$reset_color%}"
# Compacted $PWD # Compacted $PWD
local pwd="%{$fg[blue]%}%c%{$reset_color%}" local pwd="%{$fg[blue]%}%c%{$reset_color%}"

View file

@ -21,7 +21,7 @@ function prompt_char {
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
} }

View file

@ -17,7 +17,7 @@ function prompt_char {
} }
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s [ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
} }
local ruby_env='' local ruby_env=''

View file

@ -1,4 +1,4 @@
if [ "$(whoami)" = "root" ] if [ "$USER" = "root" ]
then CARETCOLOR="red" then CARETCOLOR="red"
else CARETCOLOR="blue" else CARETCOLOR="blue"
fi fi

View file

@ -11,19 +11,11 @@ git_custom_status() {
fi fi
} }
#RVM and git settings # RVM component of prompt
if [[ -s ~/.rvm/scripts/rvm ]] ; then ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}["
RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"
else
if which rbenv &> /dev/null; then # Combine it all into a final right-side prompt
RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1' RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1'
else
if [[ -n `which chruby_prompt_info` && -n `chruby_prompt_info` ]]; then
RPS1='$(git_custom_status)%{$fg[red]%}[`chruby_prompt_info`]%{$reset_color%} $EPS1'
else
RPS1='$(git_custom_status) $EPS1'
fi
fi
fi
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '

View file

@ -1,7 +1,7 @@
# Simple theme based on my old zsh settings. # Simple theme based on my old zsh settings.
function get_host { function get_host {
echo '@'`hostname`'' echo '@'$HOST
} }
PROMPT='> ' PROMPT='> '

View file

@ -17,7 +17,7 @@ USERNAME_NORMAL_COLOR=$WHITE
USERNAME_ROOT_COLOR=$RED USERNAME_ROOT_COLOR=$RED
HOSTNAME_NORMAL_COLOR=$BLUE HOSTNAME_NORMAL_COLOR=$BLUE
# uncomment next line if you want auto-generated hostname color # uncomment next line if you want auto-generated hostname color
#for i in `hostname`; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]] #for i in $HOST; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
HOSTNAME_ROOT_COLOR=$RED HOSTNAME_ROOT_COLOR=$RED
HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR) HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR)
CURRENT_DIR_COLOR=$CYAN CURRENT_DIR_COLOR=$CYAN

29
themes/mira.zsh-theme Normal file
View file

@ -0,0 +1,29 @@
# Based on bira zsh theme with nvm, rvm and jenv support
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rvm-prompt i v g)%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}'
fi
fi
local nvm_node=''
nvm_node='%{$fg[green]%}node-$(nvm_prompt_info)%{$reset_color%}'
local jenv_java=''
jenv_java='%{$fg[blue]%}$(jenv_prompt_info)%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
PROMPT="╭─${user_host} ${current_dir} ${nvm_node} ${rvm_ruby} ${jenv_java} ${git_branch}
╰─%B$%b "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"

View file

@ -10,12 +10,12 @@ function my_git_prompt() {
fi fi
# is anything staged? # is anything staged?
if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi fi
# is anything unstaged? # is anything unstaged?
if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi fi
@ -25,7 +25,7 @@ function my_git_prompt() {
fi fi
# is anything unmerged? # is anything unmerged?
if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi fi

View file

@ -1,4 +1,4 @@
if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"

View file

@ -1,4 +1,4 @@
if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})" local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"

View file

@ -4,7 +4,7 @@
function hg_prompt_info { function hg_prompt_info {
hg prompt --angle-brackets "\ hg prompt --angle-brackets "\
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}>\ <hg:%{$fg[magenta]%}<branch>%{$reset_color%}><:%{$fg[magenta]%}<bookmark>%{$reset_color%}>\
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\ </%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}< %{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null

View file

@ -7,6 +7,8 @@
# git untracked files modification from Brian Carper: # git untracked files modification from Brian Carper:
# http://briancarper.net/blog/570/git-info-in-your-zsh-prompt # http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
export VIRTUAL_ENV_DISABLE_PROMPT=1
function virtualenv_info { function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('$fg[blue]`basename $VIRTUAL_ENV`%{$reset_color%}') ' [ $VIRTUAL_ENV ] && echo '('$fg[blue]`basename $VIRTUAL_ENV`%{$reset_color%}') '
} }

View file

@ -10,7 +10,7 @@ Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue] B=$fg_no_bold[blue]
RESET=$reset_color RESET=$reset_color
if [ "$(whoami)" = "root" ]; then if [ "$USER" = "root" ]; then
PROMPTCOLOR="%{$R%}" PREFIX="-!-"; PROMPTCOLOR="%{$R%}" PREFIX="-!-";
else else
PROMPTCOLOR="" PREFIX="---"; PROMPTCOLOR="" PREFIX="---";

View file

@ -1,11 +1,5 @@
# Grab the current version of ruby in use (via RVM): [ruby-1.8.7] # Grab the current version of ruby in use: [ruby-1.8.7]
if [ -e ~/.rvm/bin/rvm-prompt ]; then JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(ruby_prompt_info)%{$fg[white]%}]%{$reset_color%}"
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
else
if which rbenv &> /dev/null; then
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
fi
fi
# Grab the current filepath, use shortcuts: ~/Desktop # Grab the current filepath, use shortcuts: ~/Desktop
# Append the current git branch, if in a git repository # Append the current git branch, if in a git repository

View file

@ -8,7 +8,7 @@
# Machine name. # Machine name.
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
} }
# Directory info. # Directory info.
@ -33,7 +33,7 @@ ${git_info} \
%{$fg[white]%}[%*] %{$fg[white]%}[%*]
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
if [[ "$(whoami)" == "root" ]]; then if [[ "$USER" == "root" ]]; then
PROMPT=" PROMPT="
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
%{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \ %{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \

View file

@ -1,7 +1,9 @@
#!/bin/sh #!/usr/bin/env zsh
zmodload zsh/datetime
function _current_epoch() { function _current_epoch() {
echo $(($(date +%s) / 60 / 60 / 24)) echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
} }
function _update_zsh_update() { function _update_zsh_update() {
@ -20,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then
epoch_target=13 epoch_target=13
fi fi
[ -f ~/.profile ] && source ~/.profile
# Cancel upgrade if the current user doesn't have write permissions for the # Cancel upgrade if the current user doesn't have write permissions for the
# oh-my-zsh directory. # oh-my-zsh directory.
[[ -w "$ZSH" ]] || return 0 [[ -w "$ZSH" ]] || return 0