From a955f0c282c434fca0ceaeb71bedc84f8545ce39 Mon Sep 17 00:00:00 2001 From: Eder Ruiz Maria Date: Sat, 13 Oct 2012 05:08:56 -0400 Subject: [PATCH 1/4] improvement in git_prompt_status function --- lib/git.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index fb4ad8ca6..b2ff9726c 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -38,6 +38,9 @@ function git_prompt_long_sha() { # Get the status of the working tree git_prompt_status() { + if ! git status &> /dev/null; then + return + fi INDEX=$(git status --porcelain 2> /dev/null) STATUS="" if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then @@ -66,6 +69,8 @@ git_prompt_status() { if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi + STATUS="$ZSH_THEME_GIT_PROMPT_STATUS_PREFIX$STATUS" + STATUS+="$ZSH_THEME_GIT_PROMPT_STATUS_SUFFIX" echo $STATUS } From 3207e0a70c7b7d47449ce04779e5ac900a2c877c Mon Sep 17 00:00:00 2001 From: Eder Ruiz Maria Date: Sat, 13 Oct 2012 05:10:37 -0400 Subject: [PATCH 2/4] themes: add uhet theme --- themes/uhet.zsh-theme | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 themes/uhet.zsh-theme diff --git a/themes/uhet.zsh-theme b/themes/uhet.zsh-theme new file mode 100644 index 000000000..b57125139 --- /dev/null +++ b/themes/uhet.zsh-theme @@ -0,0 +1,31 @@ +function do_RPROMPT() +{ + RPROMPT='$(git_prompt_status)$(git_prompt_info)' +} + +function do_PROMPT() +{ + local user='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)' + local host='%m%{$reset_color%}' + local dir='%{$fg_bold[blue]%}%~%{$reset_color%}%(!.#.$) ' + PROMPT="${user}${host}:${dir}" +} + +ZSH_THEME_GIT_PROMPT_STATUS_PREFIX="%{$fg_bold[red]%}[" +ZSH_THEME_GIT_PROMPT_STATUS_SUFFIX="" + +ZSH_THEME_GIT_PROMPT_ADDED="✚%{$fg_bold[green]%}" +ZSH_THEME_GIT_PROMPT_MODIFIED="✹%{$fg_bold[blue]%}" +ZSH_THEME_GIT_PROMPT_DELETED="✖%{$fg_bold[red]%}" +ZSH_THEME_GIT_PROMPT_RENAMED="➜%{$fg_bold[magenta]%}" +ZSH_THEME_GIT_PROMPT_UNMERGED="═%{$fg_bold[yellow]%}" +ZSH_THEME_GIT_PROMPT_UNTRACKED="✭%{$fg_bold[cyan]%}" +ZSH_THEME_GIT_PROMPT_NOTHING="" + +ZSH_THEME_GIT_PROMPT_PREFIX="" +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[red]%}]%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +do_PROMPT +do_RPROMPT From a0db2d445588e9779ff9f9b2c18bf7dde8c0aa14 Mon Sep 17 00:00:00 2001 From: Eder Ruiz Maria Date: Sat, 13 Oct 2012 05:34:05 -0400 Subject: [PATCH 3/4] fix install.sh color working in bash --- tools/install.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index b080be3a1..494da805c 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,39 +1,45 @@ +ECHO="echo" +if echo ${SHELL} | grep -q bash +then + ECHO="echo -e" +fi + if [ -d ~/.oh-my-zsh ] then - echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install" + ${ECHO} "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install" exit fi -echo "\033[0;34mCloning Oh My Zsh...\033[0m" +${ECHO} "\033[0;34mCloning Oh My Zsh...\033[0m" hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh || { - echo "git not installed" + ${ECHO} "git not installed" exit } -echo "\033[0;34mLooking for an existing zsh config...\033[0m" +${ECHO} "\033[0;34mLooking for an existing zsh config...\033[0m" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] then - echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m"; + ${ECHO} "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m"; cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; rm ~/.zshrc; fi -echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" +${ECHO} "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc -echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" -echo "export PATH=$PATH" >> ~/.zshrc +${ECHO} "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" +${ECHO} "export PATH=$PATH" >> ~/.zshrc -echo "\033[0;34mTime to change your default shell to zsh!\033[0m" +${ECHO} "\033[0;34mTime to change your default shell to zsh!\033[0m" chsh -s `which zsh` -echo "\033[0;32m"' __ __ '"\033[0m" -echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" -echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" -echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" -echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" -echo "\033[0;32m"' /____/ '"\033[0m" +${ECHO} "\033[0;32m"' __ __ '"\033[0m" +${ECHO} "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" +${ECHO} "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" +${ECHO} "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" +${ECHO} "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" +${ECHO} "\033[0;32m"' /____/ '"\033[0m" -echo "\n\n \033[0;32m....is now installed.\033[0m" +${ECHO} "\n\n \033[0;32m....is now installed.\033[0m" /usr/bin/env zsh source ~/.zshrc From 99fc183e3d1c30b644a996839c05c70c8ea54980 Mon Sep 17 00:00:00 2001 From: Eder Ruiz Maria Date: Sat, 13 Oct 2012 21:45:01 -0400 Subject: [PATCH 4/4] fix: when in git directory and not in a branch, show (no branch) --- lib/git.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index b2ff9726c..c6ac372b6 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,7 +1,10 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + if ! git status &> /dev/null; then + return + fi + branch=$(git branch | grep ^\* | cut -d" " -f2-) + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${branch}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" }