Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zsh theme
autoload -U add-zsh-hook
autoload colors
colors
function zsh_prompt_command() {
local pwdmaxlen=25
local trunc_symbol=".."
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
fi
}
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
turquoise="%F{81}"
orange="%F{166}"
purple="%F{135}"
hotpink="%F{161}"
limegreen="%F{118}"
else
turquoise="$fg[cyan]"
orange="$fg[yellow]"
purple="$fg[magenta]"
hotpink="$fg[red]"
limegreen="$fg[green]"
fi
add-zsh-hook precmd zsh_prompt_command
HOST=${$(hostname -s)/Lambda/λ}
PROMPT=$'%{$orange%}${HOST}:%{$reset_color%} %{$purple%}%n%{$reset_color%} %{$limegreen%}${NEW_PWD}%{$reset_color%} '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment