Skip to content

Instantly share code, notes, and snippets.

@techwizrd
Created February 1, 2010 07:14
Show Gist options
  • Save techwizrd/291512 to your computer and use it in GitHub Desktop.
Save techwizrd/291512 to your computer and use it in GitHub Desktop.
## Fish shell prompt for bash
## Make your bash shell's prompt look like Fish
##
## Changes color based on whether last command was succesful
## Shows shortened path names in prompt (like fish)
##
## .bashrc snippet by techwizrd
function _short_pwd {
_dir_abbr=$(temp=$(echo "${PWD/$HOME/~}" |sed -r 's/(\/.)[^/]*/\1/g'); echo ${temp:0:$(( ${#temp} - 1 ))})
_ps1="$(basename "${PWD/$HOME/~}")"
if [ ${#_ps1} -gt 25 ]; then
_ps1="${_ps1:0:7}...${_ps1: -7}"
fi
echo -n "$_dir_abbr$_ps1"
}
function _tuna_prompt {
PS1='`if [ \$? = 0 ]; then echo \u@\h\[\e[33m\] $(_short_pwd)\[\e[0m\]; else echo \u@\h\[\e[31m\] $(_short_pwd)\[\e[0m\]; fi`> '
export PS1
}
_tuna_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment