Created
October 6, 2011 01:28
-
-
Save ryo1kato/1266247 to your computer and use it in GitHub Desktop.
bash prompt with current working directory, shorten the if it's long.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .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