Skip to content

Instantly share code, notes, and snippets.

@etcadinfinitum
Last active November 28, 2018 00:58
Show Gist options
  • Save etcadinfinitum/7070272721422df1a59bc321f1e12c6c to your computer and use it in GitHub Desktop.
Save etcadinfinitum/7070272721422df1a59bc321f1e12c6c to your computer and use it in GitHub Desktop.
PS1 Fun
# fancy colored prompt
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_GRAY='\e[1;30m'
export COLOR_NC='\e[0m'
export COLOR_TEAL='\e[36m'
path () {
if [ $(pwd) == "/" ]; then
:
elif [ $(pwd) == ${HOME} ]; then
:
elif [ $(dirname $(pwd)) == "/" ]; then
echo -n "/"
else
VAR=`dirname $(pwd) && echo "/"`
echo -n "${VAR//[[:space:]]/}"
fi
}
PS1="\[${COLOR_LIGHT_PURPLE}\]\u\[${COLOR_GRAY}\]@\[${COLOR_LIGHT_GREEN}\]\h: \[${COLOR_GRAY}\]\$(path)\[${COLOR_TEAL}\]\W \[${COLOR_GRAY}\]\$\[${COLOR_NC}\] "
@etcadinfinitum
Copy link
Author

screenshot 2018-11-27 at 16 56 08

The time prompt is created by adding \t to the beginning of the line inside square bracket characters:
PS1="\[${COLOR_GRAY}\][\t] \[${COLOR_LIGHT_PURPLE}\]\u ... etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment