Skip to content

Instantly share code, notes, and snippets.

@ghawkgu
Created December 24, 2013 01:28
Show Gist options
  • Save ghawkgu/8107499 to your computer and use it in GitHub Desktop.
Save ghawkgu/8107499 to your computer and use it in GitHub Desktop.
A simple 2-line theme for oh-my-zsh.
function _update_ruby_version()
{
typeset -g ruby_version=''
if which rvm-prompt &> /dev/null; then
ruby_version="$(rvm-prompt i v g)"
rvm-prompt i v g
else
if which rbenv &> /dev/null; then
ruby_version="$(rbenv version | sed -e "s/ (set.*$//")"
fi
fi
}
chpwd_functions+=(_update_ruby_version)
_update_ruby_version
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}●"
ZSH_THEME_GIT_PROMPT_CLEAN=""
function prompt_char {
if [ $UID -eq 0 ]; then echo "%{$fg[red]%}#%{$reset_color%}"; else echo $; fi
}
PROMPT='%(?, ,%{$fg[red]%}FAIL: $?%{$reset_color%}
)
%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) %{$fg_bold[red]%}(Ruby: $ruby_version)%{$reset_color%}
%_$(prompt_char) '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
@bartdorlandt
Copy link

bartdorlandt commented Sep 11, 2016

Hi, i'm trying to understand the following piece of code:
PROMPT='%(?, ,%{$fg[red]%}FAIL: $?%{$reset_color%})
Here i understand the part: %{$fg[red]%} making the text red and $? for providing the return code. And after that the reset of the color.
that taken out it would leave:
PROMPT='%(?, ,FAIL: $?)

Could you explain what this part means?
Thanks in advance.

[Answer found]
Always good to find your own answer. Finding this part: "%(x.true-text.false-text)".
thanks anyway for providing a nice theme. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment