Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created October 6, 2011 01:28
Show Gist options
  • Save ryo1kato/1266247 to your computer and use it in GitHub Desktop.
Save ryo1kato/1266247 to your computer and use it in GitHub Desktop.
bash prompt with current working directory, shorten the if it's long.
# .bash_profile
pwd_prompt () {
maxlen=50
if (( ${#PWD} > maxlen ))
then
(( offset = ${#PWD} - maxlen ))
echo "...${PWD:offset}"
else
echo "${PWD}"
fi
}
PS1='---- [\u@\h:$(pwd_prompt)] ----\n\$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment