Skip to content

Instantly share code, notes, and snippets.

@Gisleburt
Last active December 28, 2015 07:59
Show Gist options
  • Save Gisleburt/c560f99d9e9ada359934 to your computer and use it in GitHub Desktop.
Save Gisleburt/c560f99d9e9ada359934 to your computer and use it in GitHub Desktop.
We have a management serve that governs both Live and Stage servers. To visually remind people which they are using use this script to change colours depending on current directory. The important part is just the \e[0;#m at the start of the string which changes the prompt to color code # To use, add to .bashrc: alias cd="source /path/to/script/c…
#!/bin/bash
if [[ $# -gt 0 ]]
then
pushd "$1" >> /dev/null
fi
if [[ "$PWD" == *'/live/'* ]]
then
# red
PS1='\[\e[0;31m\]\u@\h:\w\$ \[\e[m\]';
elif [[ "$PWD" == *'/stage/'* ]]
then
# green
PS1='\[\e[0;32m\]\u@\h:\w\$ \[\e[m\]';
else
# white
PS1='\[\e[0;37m\]\u@\h:\w\$ \[\e[m\]';
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment