From 05452f4ea3bf677b3a3c3a1a05dffbbcab36dc24 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Wed, 5 Jun 2013 11:21:43 +0200 Subject: [PATCH 1/3] stibbons is a clean, one-lined, git-optimized prompt Signed-off-by: Gaetan Semet --- themes/stibbons.zsh-theme | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 themes/stibbons.zsh-theme diff --git a/themes/stibbons.zsh-theme b/themes/stibbons.zsh-theme new file mode 100644 index 000000000..1ee8c5bd9 --- /dev/null +++ b/themes/stibbons.zsh-theme @@ -0,0 +1,25 @@ +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" +ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +#Customized git status, oh-my-zsh currently does not allow render dirty status before branch +git_custom_status() { + local cb=$(current_branch) + if [ -n "$cb" ]; then + echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX$(git_prompt_rebase_state)" + fi +} + +#RVM and git settings +if [[ -s ~/.rvm/scripts/rvm ]] ; then + RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' +else + if which rbenv &> /dev/null; then + RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1' + else + RPS1='$(git_custom_status) $EPS1' + fi +fi + +PROMPT='%{$fg[cyan]%}[%{$fg[yellow]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg[cyan]%}:%{$fg[magenta]%}%~% %{$fg[cyan]%}]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' From 3c63e773a2b11a4cd1efae1f7ced13a3d5acc3a7 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Wed, 5 Jun 2013 12:06:42 +0200 Subject: [PATCH 2/3] stibbons is a clean, one-lined, git-optimized prompt Signed-off-by: Gaetan Semet --- lib/git.zsh | 19 +++++++++++++++++++ themes/stibbons.zsh-theme | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 themes/stibbons.zsh-theme diff --git a/lib/git.zsh b/lib/git.zsh index c4b5b5d62..842ce0755 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -114,6 +114,25 @@ git_prompt_status() { echo $STATUS } +# Checks if there is a bisect, merge or rebase currently going on +git_prompt_rebase_state() { + STATUS="" + + if [ -f ".git/BISECT_LOG" ] ; then + STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_BISECT" + elif [ -f ".git/MERGE_HEAD" ] ; then + STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_MERGE" + else + for dir in rebase rebase-apply rebase-merge ; do + if [ -d ".git/$dir" ] ; then + STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_REBASE" + break + fi + done + fi + echo $STATUS +} + #compare the provided version of git to the version installed and on path #prints 1 if input version <= installed version #prints -1 otherwise diff --git a/themes/stibbons.zsh-theme b/themes/stibbons.zsh-theme new file mode 100644 index 000000000..946420f89 --- /dev/null +++ b/themes/stibbons.zsh-theme @@ -0,0 +1,25 @@ +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" +ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +#Customized git status, oh-my-zsh currently does not allow render dirty status before branch +git_custom_status() { + local cb=$(current_branch) + if [ -n "$cb" ]; then + echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX$(git_prompt_rebase_state)" + fi +} + +#RVM and git settings +if [[ -s ~/.rvm/scripts/rvm ]] ; then + RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' +else + if which rbenv &> /dev/null; then + RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1' + else + RPS1='$(git_custom_status) $EPS1' + fi +fi + +PROMPT='%{$fg[cyan]%}[%{$fg[yellow]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg[cyan]%}:%{$fg[magenta]%}%~% %{$fg[cyan]%}]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' From e2146d05624f77c5264f4f17aa1b4cb9896b26f4 Mon Sep 17 00:00:00 2001 From: Gaetan Semet Date: Wed, 5 Jun 2013 14:35:24 +0200 Subject: [PATCH 3/3] Modified version of git remote completion script Signed-off-by: Gaetan Semet --- plugins/git/_git-remote | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 plugins/git/_git-remote diff --git a/plugins/git/_git-remote b/plugins/git/_git-remote new file mode 100644 index 000000000..4ba62a357 --- /dev/null +++ b/plugins/git/_git-remote @@ -0,0 +1,74 @@ +#compdef git-remote + +# NOTE: --track is undocumented. +# TODO: --track, -t, --master, and -m should take remote branches, I guess. +# NOTE: --master is undocumented. +# NOTE: --fetch is undocumented. +_git-remote () { + local curcontext=$curcontext state line + declare -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' && ret=0 + + case $state in + (command) + declare -a commands + + commands=( + 'add:add a new remote' + 'show:show information about a given remote' + 'prune:delete all stale tracking branches for a given remote' + 'update:fetch updates for a set of remotes' + 'rm:remove a remote from .git/config and all associated tracking branches' + 'rename:rename a remote from .git/config and update all associated tracking branches' + 'set-head:sets or deletes the default branch' + 'set-branches:changes the list of branches tracked by the named remote.' + 'set-url:changes URL remote points to.' + ) + + _describe -t commands 'sub-command' commands && ret=0 + ;; + (options) + case $line[1] in + (add) + _arguments \ + '*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \ + '(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \ + '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \ + ':branch name:__git_remotes' \ + ':url:_urls' && ret=0 + ;; + (show) + _arguments \ + '-n[do not contact the remote for a list of branches]' \ + ':remote:__git_remotes' && ret=0 + ;; + (prune) + _arguments \ + '(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \ + ':remote:__git_remotes' && ret=0 + ;; + (update) + __git_remote-groups && ret=0 + ;; + (rm) + __git_remotes && ret=0 + ;; + (rename) + __git_remotes && ret=0 + ;; + (set-url) + _arguments \ + '*--push[manipulate push URLs]' \ + '(--add)--add[add URL]' \ + '(--delete)--delete[delete URLs]' \ + ':branch name:__git_remotes' \ + ':url:_urls' && ret=0 + ;; + + esac + ;; + esac +}