Last active
December 14, 2015 05:49
-
-
Save ashmoran/5038235 to your computer and use it in GitHub Desktop.
My oh-my-zsh theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My theme - ash.moran@patchspace.co.uk | |
# Based on Fino theme with bits from dallas and robbyrussell | |
# Fino notes: | |
# Use with a dark background and 256-color terminal! | |
# Meant for people with RVM and git. Tested only on OS X 10.7. | |
# You can set your computer name in the ~/.box-name file if you want. | |
# Borrowing shamelessly from these oh-my-zsh themes: | |
# bira | |
# robbyrussell | |
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ | |
function virtualenv_info { | |
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' | |
} | |
# Replace the fino prompt chars with dallas | |
function prompt_char { | |
echo "%{$fg[white]%}%(!.#.%%)%{$reset_color%}" | |
} | |
function box_name { | |
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s | |
} | |
function rvm_ruby { | |
if which rvm-prompt &> /dev/null; then | |
echo "‹$(rvm-prompt i v g)›%{$reset_color%}" | |
else | |
if which rbenv &> /dev/null; then | |
echo "‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}" | |
fi | |
fi | |
} | |
local current_dir='${PWD/#$HOME/~}' | |
function ret_val { | |
RETVAL=$? | |
} | |
function last_status { | |
if [[ $RETVAL -ne 0 ]]; then | |
echo "%{%F{red}%}$RETVAL✘%{$reset_color%}" | |
else | |
echo "$RETVAL" | |
fi | |
} | |
function darcs_prompt_info { | |
repo_info=$(darcs show repo 2> /dev/null) || return | |
remote=$(echo $repo_info | sed -En '/Default Remote: /s/^[^:]+: //p' | sed -En 's/^[^@]+@//p') | |
echo "$ZSH_THEME_DARCS_PROMPT_PREFIX${remote}$(parse_darcs_dirty)$ZSH_THEME_DARCS_PROMPT_SUFFIX" | |
} | |
function parse_darcs_dirty { | |
if [[ $(darcs whatsnew -l 2> /dev/null) == "No changes!" ]] | |
then | |
echo "$ZSH_THEME_DARCS_PROMPT_CLEAN" | |
else | |
echo "$ZSH_THEME_DARCS_PROMPT_DIRTY" | |
fi | |
} | |
build_prompt() { | |
RETVAL=$? | |
echo "╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}–%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%}%{$FG[239]%}:%{$reset_color%}%{$terminfo[bold]$FG[226]%}%c%{$reset_color%}`git_prompt_info`%{$reset_color%}`darcs_prompt_info` %{$FG[239]%}–%{$FG[243]%} `rvm_ruby` %{$FG[239]%}–%{$reset_color%} `last_status` | |
╰─$(virtualenv_info)$(prompt_char) " | |
} | |
# Replace fino git with a combination of fino+robbyrussell git: | |
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}–%{$reset_color%} %{$fg_bold[blue]%}git:(%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%}%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%})%{$FG[202]%}✗" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})%{$FG[040]%}✔" # ✓ | |
# My darcs hack based on the git prompt stuff | |
ZSH_THEME_DARCS_PROMPT_PREFIX=" %{$FG[239]%}–%{$reset_color%} %{$fg_bold[blue]%}darcs:(%{$fg[red]%}" | |
ZSH_THEME_DARCS_PROMPT_SUFFIX="%{$fg_bold[blue]%}%{$reset_color%}" | |
ZSH_THEME_DARCS_PROMPT_DIRTY="%{$fg[blue]%})%{$FG[202]%}✗" | |
ZSH_THEME_DARCS_PROMPT_CLEAN="%{$fg[blue]%})%{$FG[040]%}✔" # ✓ | |
PROMPT='$(build_prompt)' |
Prompt looks like this:
╭─ashmoran – hostname:current_dir – git:(branch)✗ – darcs:(default_remote)✗ – ‹2.0.0-p0› – 0
╰─%
Crosses and ticks indicate whether source control is dirty or clean.
Final two elements are the Ruby version from RVM/rbenv, and the status code of the last command ( thanks @workmad3 for that last one :) )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.bash suffix is just to trick the syntax highlighter