Skip to content

Instantly share code, notes, and snippets.

@paddycarver
Created April 3, 2016 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paddycarver/4bc55b5d62310466c4880285939dc2be to your computer and use it in GitHub Desktop.
Save paddycarver/4bc55b5d62310466c4880285939dc2be to your computer and use it in GitHub Desktop.
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '%' && return
echo '$'
}
function get_directory {
DIR=${PWD/#$HOME/\~}
if [[ ! -f ~/.specialdirs || ! -r ~/.specialdirs ]]; then
echo $DIR && return
fi
while read line
do
[[ $line = "#"* ]] && continue
variable=${line[(ws:=:)1]} | sed -e 's/^ *//' | sed -e 's/ *$//'
dir=${line[(ws:=:)2]} | sed -e 's/^ *//' | sed -e 's/ *$//'
[[ $DIR = $dir* ]] && echo ${DIR/#$dir/\$$variable} && return
done < ~/.specialdirs
echo $DIR && return
}
PROMPT='%{$fg[blue]%}$(hostname -s)%{$reset_color%} > %{$fg_bold[green]%}$(get_directory)%{$reset_color%}$(git_prompt_info) $(prompt_char) '
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_GET_PROMPT_CLEAN=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment