diff options
-rw-r--r-- | README.textile | 2 | ||||
-rw-r--r-- | lib/git.zsh | 28 | ||||
-rw-r--r-- | lib/termsupport.zsh | 4 | ||||
-rw-r--r-- | plugins/debian/debian.plugin.zsh | 4 | ||||
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 4 | ||||
-rw-r--r-- | plugins/postgres/postgres.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/virtualenv/virtualenv.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 25 | ||||
-rw-r--r-- | themes/rkj-repos.zsh-theme | 2 | ||||
-rw-r--r-- | themes/rkj.zsh-theme | 3 |
10 files changed, 51 insertions, 34 deletions
diff --git a/README.textile b/README.textile index 5f8067499..1916d9f4e 100644 --- a/README.textile +++ b/README.textile @@ -72,6 +72,8 @@ To disable updates entirely, put this in your ~/.zshrc @DISABLE_AUTO_UPDATE=true@ +To upgrade directly from the command line, just run @upgrade_oh_my_zsh@ + h3. Uninstalling If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config). diff --git a/lib/git.zsh b/lib/git.zsh index c4b5b5d62..df0fcedbb 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,7 +1,7 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(git rev-parse --short HEAD 2> /dev/null) || return + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" } @@ -11,14 +11,14 @@ parse_git_dirty() { local SUBMODULE_SYNTAX='' local GIT_STATUS='' local CLEAN_MESSAGE='nothing to commit (working directory clean)' - if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then SUBMODULE_SYNTAX="--ignore-submodules=dirty" fi if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then - GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) else - GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) + 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" @@ -32,10 +32,10 @@ parse_git_dirty() { # get the difference between the local and remote branches git_remote_status() { - remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} + remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} if [[ -n ${remote} ]] ; then - ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) if [ $ahead -eq 0 ] && [ $behind -gt 0 ] then @@ -52,24 +52,24 @@ git_remote_status() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { - SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha() { - SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Get the status of the working tree git_prompt_status() { - INDEX=$(git status --porcelain -b 2> /dev/null) + INDEX=$(command git status --porcelain -b 2> /dev/null) STATUS="" if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" @@ -96,7 +96,7 @@ git_prompt_status() { elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then + if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then @@ -121,7 +121,7 @@ function git_compare_version() { local INPUT_GIT_VERSION=$1; local INSTALLED_GIT_VERSION INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION}); - INSTALLED_GIT_VERSION=($(git --version 2>/dev/null)); + INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)); INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}); for i in {1..3}; do diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e3828da14..80319e1a8 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -27,7 +27,9 @@ function omz_termsupport_preexec { emulate -L zsh setopt extended_glob local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd - title "$CMD" "%100>...>${2:gs/%/%%}%<<" + local LINE="${2:gs/$/\\$}" + LINE="${LINE:gs/%/%%}" + title "$CMD" "%100>...>$LINE%<<" } autoload -U add-zsh-hook diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 55b90e379..b51d0cd37 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -6,14 +6,14 @@ # Use aptitude if installed, or apt-get if not. # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which aptitude 2>&1 ) ]]; then +if [[ -e $( which -p aptitude 2>&1 ) ]]; then apt_pref='aptitude' else apt_pref='apt-get' fi # Use sudo by default if it's installed -if [[ -e $( which sudo 2>&1 ) ]]; then +if [[ -e $( which -p sudo 2>&1 ) ]]; then use_sudo=1 fi diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 51cd7c143..dd785f911 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -6,7 +6,7 @@ # ------------------------------------------------------------------------------ function tab() { - local command="cd \\\"$PWD\\\"" + local command="cd \\\"$PWD\\\"; clear; " (( $# > 0 )) && command="${command}; $*" the_app=$( @@ -34,7 +34,7 @@ EOF launch session "Default Session" set current_session to current session tell current_session - write text "${command}; clear;" + write text "${command}" end tell end tell end tell diff --git a/plugins/postgres/postgres.plugin.zsh b/plugins/postgres/postgres.plugin.zsh new file mode 100644 index 000000000..cdd142e92 --- /dev/null +++ b/plugins/postgres/postgres.plugin.zsh @@ -0,0 +1,6 @@ +# Aliases to stop, start and restart Postgres +# Paths noted below are for Postgress installed via Homebrew on OSX + +alias startpost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' +alias stoppost='pg_ctl -D /usr/local/var/postgres stop -s -m fast' +alias restartpost='stoppost && sleep 1 && startpost'
\ No newline at end of file diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh index e8458389f..8e06450b1 100644 --- a/plugins/virtualenv/virtualenv.plugin.zsh +++ b/plugins/virtualenv/virtualenv.plugin.zsh @@ -1,9 +1,8 @@ function virtualenv_prompt_info(){ - local virtualenv_path="$VIRTUAL_ENV" - if [[ -n $virtualenv_path ]]; then - local virtualenv_name=`basename $virtualenv_path` - printf "%s[%s] " "%{${fg[yellow]}%}" $virtualenv_name + if [[ -n $VIRTUAL_ENV ]]; then + printf "%s[%s] " "%{${fg[yellow]}%}" ${${VIRTUAL_ENV}:t} fi } +# disables prompt mangling in virtual_env/bin/activate export VIRTUAL_ENV_DISABLE_PROMPT=1 diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 35de50874..670c287bd 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,10 +1,9 @@ -wrapsource=`which virtualenvwrapper_lazy.sh` - -if [[ -f "$wrapsource" ]]; then - source $wrapsource +virtualenvwrapper='virtualenvwrapper_lazy.sh' +if (( $+commands[$virtualenvwrapper] )); then + source ${${virtualenvwrapper}:c} if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then - # Automatically activate Git projects' virtual environments based on the + # Automatically activate Git projects's virtual environments based on the # directory name of the project. Virtual environment name can be overridden # by placing a .venv file in the project root with a virtualenv name in it function workon_cwd { @@ -40,11 +39,17 @@ if [[ -f "$wrapsource" ]]; then fi } - # New cd function that does the virtualenv magic - function cd { - builtin cd "$@" && workon_cwd - } + # Append workon_cwd to the chpwd_functions array, so it will be called on cd + # http://zsh.sourceforge.net/Doc/Release/Functions.html + # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 + if (( ${+chpwd_functions} )); then + if (( $chpwd_functions[(I)workon_cwd] == 0 )); then + set -A chpwd_functions $chpwd_functions workon_cwd + fi + else + set -A chpwd_functions workon_cwd + fi fi else - print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with \`pip install virtualenvwrapper\`." + print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`." fi diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme index 46b8e83a0..4ab3bc757 100644 --- a/themes/rkj-repos.zsh-theme +++ b/themes/rkj-repos.zsh-theme @@ -22,6 +22,8 @@ function mygit() { echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX" } +function retcode() {} + # alternate prompt with git & hg PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b ' diff --git a/themes/rkj.zsh-theme b/themes/rkj.zsh-theme index 80122d5c6..fe06161c8 100644 --- a/themes/rkj.zsh-theme +++ b/themes/rkj.zsh-theme @@ -2,7 +2,8 @@ # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 +function retcode() {} + PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B]%{\e[0m%}%b ' - |