Skip to content

Instantly share code, notes, and snippets.

@carlsednaoui
Forked from jkosoy/.bash_profile
Created March 16, 2013 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsednaoui/5177151 to your computer and use it in GitHub Desktop.
Save carlsednaoui/5177151 to your computer and use it in GitHub Desktop.
alias ls='ls -GFh'
export CLICOLOR=1
# From Andrzej Szelachowski's ~/.bash_profile:
# Note that a variable may require special treatment
#+ if it will be exported.
DARKGRAY='\[\e[1;30m\]'
LIGHTRED='\[\e[1;31m\]'
GREEN='\[\e[32m\]'
YELLOW='\[\e[1;33m\]'
LIGHTBLUE='\[\e[1;34m\]'
NC='\[\e[m\]'
# PCT="\`if [[ \$EUID -eq 0 ]]; then T='$LIGHTRED' ; else T='$LIGHTBLUE'; fi;
# echo \$T \`"
# For "literal" command substitution to be assigned to a variable,
#+ use escapes and double quotes:
#+ PCT="\` ... \`" . . .
# Otherwise, the value of PCT variable is assigned only once,
#+ when the variable is exported/read from .bash_profile,
#+ and it will not change afterwards even if the user ID changes.
# PS1="\n$GREEN[\w] \n$DARKGRAY($PCT\t$DARKGRAY)-($PCT\u$DARKGRAY)-($PCT\!
# $DARKGRAY)$YELLOW-> $NC"
# Escape a variables whose value changes:
# if [[ \$EUID -eq 0 ]],
# Otherwise the value of the EUID variable will be assigned only once,
#+ as above.
# When a variable is assigned, it should be called escaped:
#+ echo \$T,
# Otherwise the value of the T variable is taken from the moment the PCT
#+ variable is exported/read from .bash_profile.
# So, in this example it would be null.
# When a variable's value contains a semicolon it should be strong quoted:
# T='$LIGHTRED',
# Otherwise, the semicolon will be interpreted as a command separator.
# Variables PCT and PS1 can be merged into a new PS1 variable:
PS1="\`if [[ \$EUID -eq 0 ]]; then PCT='$LIGHTRED';
else PCT='$YELLOW'; fi;
echo '\n$DARKGRAY-------------------------\n$GREEN\w \n$DARKGRAY'\$PCT'\t$DARKGRAY \
'\$PCT'$LIGHTBLUE\u$DARKGRAY@$LIGHTRED\h $DARKGRAY\$ $NC'\`"
# The trick is to use strong quoting for parts of old PS1 variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment