Skip to content

Instantly share code, notes, and snippets.

@olvlvl
Created July 28, 2015 10:40
Show Gist options
  • Save olvlvl/0a9770ba65854a08ce7c to your computer and use it in GitHub Desktop.
Save olvlvl/0a9770ba65854a08ce7c to your computer and use it in GitHub Desktop.
Shell prompt
_short_pwd ()
{
local PRE= NAME="$1" LENGTH="$2";
[[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
echo "$PRE$NAME"
}
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
PS1='\[\e[36m\]$(_short_pwd "$PWD" 32):\[\e[96m\]\$\[\e[0m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment