Skip to content

Instantly share code, notes, and snippets.

@yabberyabber
Forked from anonymous/.bashrc
Last active July 15, 2016 18:12
Show Gist options
  • Save yabberyabber/b482c847cc42368cb62754d4aba043ff to your computer and use it in GitHub Desktop.
Save yabberyabber/b482c847cc42368cb62754d4aba043ff to your computer and use it in GitHub Desktop.
if [ -z "$WP" ]; then
# $WP is empty... you are not in a chroot workspace
export PS1="\[\033[0;31m\]"$PS1"\[\033[0m\]"
else
# $WP contains the name of the project you're currently in
export PS1="\[\033[0;37m\]"$WP": "$PS1"\[\033[0m\]"
fi
@yabberyabber
Copy link
Author

Non printable characters (like \033[0;37m) must be wrapped in \[ blah blah blah \].

If not, bash doesn't know how many characters long the prompt is and when you type long commands they won't wrap properly.

If your terminal has a light background, consider different colors. I have PS1="[\033[0;42m]"$WP": "$PS1"[\033[0m]" because my background is white and I couldn't read gray against white.

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