summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2016-10-10 20:33:40 +0200
committerMarc Cornellà <marc.cornella@live.com>2016-10-14 00:24:30 +0200
commit015598b8a82457a03ab9d75f770bbd333599a601 (patch)
tree3d74725fc782bfdda9cd0c1db973e2c936d3f88b
parentc1ee74e7e38018ca9d2b2ffa77365366676fd82b (diff)
downloadzsh-015598b8a82457a03ab9d75f770bbd333599a601.tar.gz
zsh-015598b8a82457a03ab9d75f770bbd333599a601.tar.bz2
zsh-015598b8a82457a03ab9d75f770bbd333599a601.zip
Display suvash prompt w/o Ruby; refactor code
-rw-r--r--themes/suvash.zsh-theme38
1 files changed, 21 insertions, 17 deletions
diff --git a/themes/suvash.zsh-theme b/themes/suvash.zsh-theme
index c87f64558..1680973df 100644
--- a/themes/suvash.zsh-theme
+++ b/themes/suvash.zsh-theme
@@ -5,26 +5,30 @@ function prompt_char {
}
function virtualenv_info {
- [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
+ [[ -n "$VIRTUAL_ENV" ]] && echo '('${VIRTUAL_ENV:t}') '
}
-function collapse_pwd {
- echo $(pwd | sed -e "s,^$HOME,~,")
+function ruby_prompt {
+ if (( $+commands[rvm-prompt] )); then
+ print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
+ print -n $(~/.rvm/bin/rvm-prompt)
+ print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
+ elif (( $+commands[rbenv] )); then
+ print -n $ZSH_THEME_RUBY_PROMPT_PREFIX
+ print -n $(rbenv version | sed -e "s/ (set.*$//")
+ print -n $ZSH_THEME_RUBY_PROMPT_SUFFIX
+ fi
+ return 0
}
-if which rvm-prompt &> /dev/null; then
- PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
-$(virtualenv_info)$(prompt_char) '
-else
- if which rbenv &> /dev/null; then
- PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}
-$(virtualenv_info)$(prompt_char) '
- fi
-fi
+PROMPT='%F{magenta}%n%f at %F{yellow}%m%f in %B%F{green}%~%f%b$(git_prompt_info)$(ruby_prompt)
+$(virtualenv_info) $(prompt_char) '
+ZSH_THEME_GIT_PROMPT_PREFIX=' on %F{magenta}'
+ZSH_THEME_GIT_PROMPT_SUFFIX='%f'
+ZSH_THEME_GIT_PROMPT_DIRTY='%F{green}!'
+ZSH_THEME_GIT_PROMPT_UNTRACKED='%F{green}?'
+ZSH_THEME_GIT_PROMPT_CLEAN=''
-ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
-ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
-ZSH_THEME_GIT_PROMPT_CLEAN=""
+ZSH_THEME_RUBY_PROMPT_PREFIX=' using %F{red}'
+ZSH_THEME_RUBY_PROMPT_SUFFIX='%f'