From 14a1ce80bbf7362ab2856cdd050714f02649fe3f Mon Sep 17 00:00:00 2001 From: James Adam Date: Tue, 20 Oct 2009 06:24:21 +0800 Subject: [PATCH 01/10] Added my prompt theme, with a tweak to the core oh-my-zsh to support it. My git_prompt_info function not only reports the branch and dirty status, but also whether or not the branch is ahead or behind of the remote, or both. It also switches the prompt colour from green to red if the previous command exited with a non-zero value (i.e. failed). --- lib/termsupport.zsh | 2 ++ themes/lazyatom.zsh-theme | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 themes/lazyatom.zsh-theme diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index fef97874..ec828c28 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -4,6 +4,7 @@ case "$TERM" in print -Pn "\e]0;%n@%m: $1\a" # xterm } precmd () { + oh_my_zsh_theme_precmd print -Pn "\e]0;%n@%m: %~\a" # xterm } ;; @@ -14,6 +15,7 @@ case "$TERM" in print -Pn "\e]0;%n@%m: $1\a" # xterm } precmd () { + oh_my_zsh_theme_precmd echo -ne "\ekzsh\e\\" print -Pn "\e]0;%n@%m: %~\a" # xterm } diff --git a/themes/lazyatom.zsh-theme b/themes/lazyatom.zsh-theme new file mode 100644 index 00000000..6263bc2b --- /dev/null +++ b/themes/lazyatom.zsh-theme @@ -0,0 +1,40 @@ +git_prompt_info() { + branch=$(git symbolic-ref HEAD 2> /dev/null) || return + git_status="$(git status 2> /dev/null)" + state="" + case $git_status in + *Changed\ but\ not\ updated*) + state="%{$fg[red]%}⚡" + ;;; + *Untracked\ files*) + state="%{$fg[red]%}⚡" + ;;; + esac + + remote="" + case $git_status in + *Your\ branch\ is\ ahead*) + remote="%{$fg[yellow]%}↑" + ;;; + + *Your\ branch\ is\ behind*) + remote="%{$fg[yellow]%}↓" + ;;; + + "Your branch and") + remote="%{$fg[yellow]%}" + ;;; + esac + echo " %{$fg[yellow]%}(${branch#refs/heads/})${remote}${state}" +} + +function oh_my_zsh_theme_precmd() { + local previous_return_value=$?; + prompt="%{$fg[light_gray]%}%c%{$fg[yellow]%}$(git_prompt_info)%{$fg[white]%}" + if test $previous_return_value -eq 0 + then + export PROMPT="%{$fg[green]%}➜ %{$fg[white]%}${prompt}%{$fg[green]%} $%{$fg[white]%} " + else + export PROMPT="%{$fg[red]%}➜ %{$fg[white]%}${prompt}%{$fg[red]%} $%{$fg[white]%} " + fi +} \ No newline at end of file From a21525ba0ccbdf35a0524f6cf7f2025fef578c78 Mon Sep 17 00:00:00 2001 From: James Adam Date: Tue, 20 Oct 2009 06:26:06 +0800 Subject: [PATCH 02/10] Whoops, forgot to include this dummy precmd implementation. --- lib/prompt.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/prompt.zsh b/lib/prompt.zsh index 39689684..19bacac9 100644 --- a/lib/prompt.zsh +++ b/lib/prompt.zsh @@ -22,4 +22,8 @@ setopt prompt_subst export LSCOLORS="Gxfxcxdxbxegedabagacad" +function oh_my_zsh_theme_precmd() { + # Blank function; override this in your themes +} + source "$ZSH/themes/$ZSH_THEME.zsh-theme" From e24709a2b80c8f829c8ceb66130a4b3a6cb86261 Mon Sep 17 00:00:00 2001 From: meh Date: Sun, 1 Nov 2009 06:16:24 +0800 Subject: [PATCH 03/10] Fixed darkblood theme as in issue #23. --- themes/darkblood.zsh-theme | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/themes/darkblood.zsh-theme b/themes/darkblood.zsh-theme index 8a00c345..33508fbd 100644 --- a/themes/darkblood.zsh-theme +++ b/themes/darkblood.zsh-theme @@ -1,9 +1,9 @@ # meh. Dark Blood Rewind, a new beginning. -PROMPT=$'${fg[red]}┌[${fg_bold[white]}%n${reset_color}${fg[red]}@${fg_bold[white]}%m${reset_color}${fg[red]}] [${fg_bold[white]}/dev/%y${reset_color}${fg[red]}] $(git_prompt_info)%(?,,${fg[red]}[${fg_bold[white]}%?${reset_color}${fg[red]}]) -${fg[red]}└[${fg_bold[white]}%~${reset_color}${fg[red]}]>${reset_color} ' -PS2=$' ${fg[red]}|>${reset_color} ' +PROMPT=$'%{$fg[red]%}┌[%{$fg_bold[white]%}%n%{$reset_color%}%{$fg[red]%}@%{$fg_bold[white]%}%m%{$reset_color%}%{$fg[red]%}] [%{$fg_bold[white]%}/dev/%y%{$reset_color%}%{$fg[red]%}] %{$(git_prompt_info)%}%(?,,%{$fg[red]%}[%{$fg_bold[white]%}%?%{$reset_color%}%{$fg[red]%}]) +%{$fg[red]%}└[%{$fg_bold[white]%}%~%{$reset_color%}%{$fg[red]%}]>%{$reset_color%} ' +PS2=$' %{$fg[red]%}|>%{$reset_color%} ' -ZSH_THEME_GIT_PROMPT_PREFIX="${fg[red]}[${fg_bold[white]}" -ZSH_THEME_GIT_PROMPT_SUFFIX="${reset_color}${fg[red]}] " -ZSH_THEME_GIT_PROMPT_DIRTY=" ${fg[red]}⚡${reset_color}" +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}[%{$fg_bold[white]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}%{$fg[red]%}] " +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}⚡%{$reset_color%}" From 8f33231823dbf6c68ccc65fbb028fce6ff1efd74 Mon Sep 17 00:00:00 2001 From: meh Date: Fri, 6 Nov 2009 20:55:08 +0800 Subject: [PATCH 04/10] Fixed issue #25. --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index 9409c92d..7b7b3700 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -16,7 +16,7 @@ function git_prompt_info() { } parse_git_dirty () { - if [[ $(git status | tail -n1) != "nothing to commit (working directory clean)" ]]; then + if [[ $((git status &> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" From 97c66649485e227aba86b6006a6058a981da5092 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Fri, 16 Oct 2009 12:07:02 +0800 Subject: [PATCH 05/10] Added initial jnrowe theme. --- themes/jnrowe.zsh-theme | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 themes/jnrowe.zsh-theme diff --git a/themes/jnrowe.zsh-theme b/themes/jnrowe.zsh-theme new file mode 100644 index 00000000..7c8a7082 --- /dev/null +++ b/themes/jnrowe.zsh-theme @@ -0,0 +1,31 @@ +autoload -U add-zsh-hook +autoload -Uz vcs_info + +zstyle ':vcs_info:*' actionformats \ + '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats \ + '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' +zstyle ':vcs_info:*' enable git + +add-zsh-hook precmd prompt_jnrowe_precmd + +prompt_jnrowe_precmd () { + vcs_info + + if [ "${vcs_info_msg_0_}" = "" ]; then + dir_status="%F{2}→%f" + elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then + dir_status="%F{1}▶%f" + elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then + dir_status="%F{3}▶%f" + else + dir_status="%F{2}▶%f" + fi +} + +local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)" + +PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} ' + +# vim: set ft=zsh ts=4 sw=4 et: From 286559d18016f0aeaaed96dbea39c71b52c374eb Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 8 Nov 2009 15:24:20 -0800 Subject: [PATCH 06/10] Revert "Fixed issue #19 'Rake not auto completing'. The stat command syntax that was being used was not correct. Or at least on my machine. See man page for the stat command" This reverts commit 83907294d640d910968cf9152d11c6a5ab3205f5. --- lib/rake_completion.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rake_completion.zsh b/lib/rake_completion.zsh index 9ee8213a..c425a625 100644 --- a/lib/rake_completion.zsh +++ b/lib/rake_completion.zsh @@ -1,8 +1,8 @@ _rake_does_task_list_need_generating () { if [ ! -f .rake_tasks~ ]; then return 0; else - accurate=$(stat -c "%n" .rake_tasks~) - changed=$(stat -c "%n" Rakefile) + accurate=$(stat -f%m .rake_tasks~) + changed=$(stat -f%m Rakefile) return $(expr $accurate '>=' $changed) fi } From eb05b61483a9e03866404c903468360cb8df370b Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 8 Nov 2009 15:27:17 -0800 Subject: [PATCH 07/10] Removing gdb alias as it conflicts with an actual command for gdb. Closes #17 --- lib/aliases.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/aliases.zsh b/lib/aliases.zsh index 6667a672..ff43e640 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -37,7 +37,6 @@ alias gc='git commit -v' alias gca='git commit -v -a' alias gb='git branch' alias gba='git branch -a' -alias gdb='git branch -d' alias gcount='git shortlog -sn' alias gcp='git cherry-pick' From fc3a3c72b17c0e12ea85094cd8b2575ccf1f2d44 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 8 Nov 2009 15:34:02 -0800 Subject: [PATCH 08/10] Only using the contents of .ssh/known_hosts when the file exists for ssh/scp auto-completion. Closes issue #20 --- lib/completion.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index deeb5282..c231ee21 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -22,7 +22,7 @@ else fi zstyle ':completion:*' list-colors '' -zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) + unsetopt MENU_COMPLETE #setopt AUTO_MENU @@ -35,7 +35,12 @@ zstyle ':completion:*:*:*:*:*' menu yes select 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" -zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts` + +# Load known hosts file for auto-completion with ssh and scp commands +if [ -f ~/.ssh/known_hosts ]; then + zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) + zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts` +fi # Complete on history # zstyle ':completion:*:history-words' stop yes From 5c13930832b3e3bfcfd7b8ea99283ef477903bfd Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Mon, 9 Nov 2009 07:33:38 -0800 Subject: [PATCH 09/10] Revert "Whoops, forgot to include this dummy precmd implementation." This reverts commit a21525ba0ccbdf35a0524f6cf7f2025fef578c78. --- lib/prompt.zsh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/prompt.zsh b/lib/prompt.zsh index 19bacac9..39689684 100644 --- a/lib/prompt.zsh +++ b/lib/prompt.zsh @@ -22,8 +22,4 @@ setopt prompt_subst export LSCOLORS="Gxfxcxdxbxegedabagacad" -function oh_my_zsh_theme_precmd() { - # Blank function; override this in your themes -} - source "$ZSH/themes/$ZSH_THEME.zsh-theme" From c620408962dd93fe920414eedd8e8e38b241eb08 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Mon, 9 Nov 2009 07:33:51 -0800 Subject: [PATCH 10/10] Revert "Added my prompt theme, with a tweak to the core oh-my-zsh to support it. My git_prompt_info function not only reports the branch and dirty status, but also whether or not the branch is ahead or behind of the remote, or both. It also switches the prompt colour from green to red if the previous command exited with a non-zero value (i.e. failed)." This reverts commit 14a1ce80bbf7362ab2856cdd050714f02649fe3f. --- lib/termsupport.zsh | 2 -- themes/lazyatom.zsh-theme | 40 --------------------------------------- 2 files changed, 42 deletions(-) delete mode 100644 themes/lazyatom.zsh-theme diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index ec828c28..fef97874 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -4,7 +4,6 @@ case "$TERM" in print -Pn "\e]0;%n@%m: $1\a" # xterm } precmd () { - oh_my_zsh_theme_precmd print -Pn "\e]0;%n@%m: %~\a" # xterm } ;; @@ -15,7 +14,6 @@ case "$TERM" in print -Pn "\e]0;%n@%m: $1\a" # xterm } precmd () { - oh_my_zsh_theme_precmd echo -ne "\ekzsh\e\\" print -Pn "\e]0;%n@%m: %~\a" # xterm } diff --git a/themes/lazyatom.zsh-theme b/themes/lazyatom.zsh-theme deleted file mode 100644 index 6263bc2b..00000000 --- a/themes/lazyatom.zsh-theme +++ /dev/null @@ -1,40 +0,0 @@ -git_prompt_info() { - branch=$(git symbolic-ref HEAD 2> /dev/null) || return - git_status="$(git status 2> /dev/null)" - state="" - case $git_status in - *Changed\ but\ not\ updated*) - state="%{$fg[red]%}⚡" - ;;; - *Untracked\ files*) - state="%{$fg[red]%}⚡" - ;;; - esac - - remote="" - case $git_status in - *Your\ branch\ is\ ahead*) - remote="%{$fg[yellow]%}↑" - ;;; - - *Your\ branch\ is\ behind*) - remote="%{$fg[yellow]%}↓" - ;;; - - "Your branch and") - remote="%{$fg[yellow]%}" - ;;; - esac - echo " %{$fg[yellow]%}(${branch#refs/heads/})${remote}${state}" -} - -function oh_my_zsh_theme_precmd() { - local previous_return_value=$?; - prompt="%{$fg[light_gray]%}%c%{$fg[yellow]%}$(git_prompt_info)%{$fg[white]%}" - if test $previous_return_value -eq 0 - then - export PROMPT="%{$fg[green]%}➜ %{$fg[white]%}${prompt}%{$fg[green]%} $%{$fg[white]%} " - else - export PROMPT="%{$fg[red]%}➜ %{$fg[white]%}${prompt}%{$fg[red]%} $%{$fg[white]%} " - fi -} \ No newline at end of file