Skip to content

Instantly share code, notes, and snippets.

@jesstess
Created November 25, 2010 03:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesstess/714837 to your computer and use it in GitHub Desktop.
Save jesstess/714837 to your computer and use it in GitHub Desktop.
cycle through colors with each new shell prompt
export colorvar=31; export PROMPT_COMMAND='export PS1="\e[""$colorvar"";40m\w> "; colorvar=$(((colorvar + 1) % 7 + 31));'
@jesstess
Copy link
Author

andersk educates me, as usual:

export PROMPT_COMMAND='export PS1="[\e[$(($LINENO % 7 + 31))m]\w> "'

"The [ ~ ] tells bash where the non-printing escape sequence is so that it can correctly calculate the width of the prompt, to avoid display bugs when you type a command longer than the terminal width."

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