2013-08-03 13:01:14 -07:00
|
|
|
# GIT Stuff
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
|
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}+%{$fg[white]%}"
|
|
|
|
# ZSH_THEME_GIT_PROMPT_CLEAN=""
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Build Prompt #
|
|
|
|
##################
|
|
|
|
|
2014-03-29 14:56:33 -07:00
|
|
|
function _prompt_pwd {
|
2013-03-16 11:29:30 -07:00
|
|
|
SHORTPWD=`print -Pn "%4~"`
|
2013-07-27 21:17:25 -07:00
|
|
|
|
|
|
|
if [[ -n "${ZSH_VERSION:-}" ]]
|
|
|
|
then _pwd="${SHORTPWD[0,1]}"
|
|
|
|
else _pwd="${SHORTPWD:0:1}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ $_pwd =~ "[^/~]" ]] && SHORTPWD=".../$SHORTPWD"
|
|
|
|
|
2013-03-20 16:55:09 -07:00
|
|
|
echo -n $SHORTPWD
|
|
|
|
}
|
2013-03-16 11:29:30 -07:00
|
|
|
|
2014-03-29 14:56:33 -07:00
|
|
|
function _prompt_git {
|
2013-12-17 02:42:44 -08:00
|
|
|
[ "`git_prompt_info`" ] && echo -n "$(git_prompt_info)"
|
2013-03-16 11:29:30 -07:00
|
|
|
}
|
|
|
|
|
2014-03-29 14:56:33 -07:00
|
|
|
function _prompt_vimode {
|
2013-08-03 13:01:14 -07:00
|
|
|
# The prompt turns green in command mode, and red in insert mode
|
2013-12-19 06:50:27 -08:00
|
|
|
PROMPT="$"
|
2013-12-17 02:42:44 -08:00
|
|
|
|
2013-12-19 06:50:27 -08:00
|
|
|
MODE_INDICATOR="%{$fg[green]%}%{$PROMPT%}"
|
2013-08-03 13:01:14 -07:00
|
|
|
MODE_PROMPT="${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
|
|
|
|
if [ $MODE_PROMPT ]; then
|
2013-12-17 02:42:44 -08:00
|
|
|
echo -n "$MODE_PROMPT "
|
2013-08-03 13:01:14 -07:00
|
|
|
else
|
2013-12-17 02:42:44 -08:00
|
|
|
echo -n "$PROMPT "
|
2013-08-03 13:01:14 -07:00
|
|
|
fi
|
2013-08-02 12:37:20 -07:00
|
|
|
}
|
|
|
|
|
2014-04-11 00:29:57 -07:00
|
|
|
function _prompt_rbenv {
|
|
|
|
local ruby_version
|
|
|
|
ruby_version="$(rbenv local 2>/dev/null)"
|
|
|
|
[ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[red]%}:$ruby_version"
|
|
|
|
}
|
|
|
|
|
|
|
|
function _prompt_pyenv {
|
|
|
|
local py_version
|
|
|
|
py_version="$(pyenv local 2>/dev/null)"
|
|
|
|
[ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[yellow]%}:$py_version"
|
|
|
|
}
|
|
|
|
|
2013-08-03 13:01:14 -07:00
|
|
|
# prompts
|
2014-03-29 14:56:33 -07:00
|
|
|
function _lprompt {
|
2013-08-03 13:01:14 -07:00
|
|
|
# Start each prompt with a newline
|
|
|
|
echo
|
|
|
|
|
2013-03-20 16:55:09 -07:00
|
|
|
# Show the hostname if this is an SSH session
|
2013-12-17 02:42:44 -08:00
|
|
|
if [ ! -z "$SSH_CLIENT" ]; then
|
2013-07-27 21:17:25 -07:00
|
|
|
echo -n "%{$fg[blue]%}"
|
2013-10-26 01:21:55 -07:00
|
|
|
if is_mac; then
|
2013-12-17 02:42:44 -08:00
|
|
|
echo -n "$(hostname | sed -e 's/\.local$//') "
|
2013-10-26 01:21:55 -07:00
|
|
|
else
|
2013-12-17 02:42:44 -08:00
|
|
|
echo -n "$(hostname) "
|
2013-10-26 01:21:55 -07:00
|
|
|
fi
|
2013-03-20 16:55:09 -07:00
|
|
|
fi
|
|
|
|
|
2013-12-17 02:42:44 -08:00
|
|
|
# Print the prompt
|
2014-03-29 14:56:33 -07:00
|
|
|
echo -n '%{$fg[red]%}%{$FX[bold]%}$(_prompt_vimode)%{$reset_color%}'
|
2013-03-20 16:55:09 -07:00
|
|
|
}
|
|
|
|
|
2014-03-29 14:56:33 -07:00
|
|
|
function _rprompt {
|
2013-03-20 16:55:09 -07:00
|
|
|
# Make the rprompt a bright grey to set it apart
|
|
|
|
echo -n "%{$FG[245]%}"
|
2014-03-29 14:56:33 -07:00
|
|
|
echo -n '$(_prompt_pwd)'
|
2013-03-20 16:55:09 -07:00
|
|
|
|
|
|
|
# Show the branch/status if in a git repo
|
2014-03-29 14:56:33 -07:00
|
|
|
echo -n '$(_prompt_git)'
|
2013-03-20 16:55:09 -07:00
|
|
|
|
2014-04-11 00:29:57 -07:00
|
|
|
# Display the local version of rb/pyenv
|
|
|
|
command_exists rbenv && echo -n '$(_prompt_rbenv)'
|
|
|
|
command_exists pyenv && echo -n '$(_prompt_pyenv)'
|
|
|
|
|
2013-03-20 16:55:09 -07:00
|
|
|
# Reset formatting for command output
|
|
|
|
echo -n "%{$reset_color%}"
|
|
|
|
}
|
|
|
|
|
2014-03-29 14:56:33 -07:00
|
|
|
PROMPT="$(_lprompt)"
|
|
|
|
RPROMPT="$(_rprompt)"
|
2013-03-22 18:10:59 -07:00
|
|
|
|
|
|
|
# vim:set ft=zsh:
|