-
-
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…
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
#!/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