Skip to content

Instantly share code, notes, and snippets.

@nautilebleu
Created January 20, 2011 08:48
Show Gist options
  • Save nautilebleu/787597 to your computer and use it in GitHub Desktop.
Save nautilebleu/787597 to your computer and use it in GitHub Desktop.
Customize your shell (copy this in .bashrc)
### CURSOR ###
if [ "`id -u`" -eq 0 ]; then
CURSOR='#'
else
CURSOR='$'
fi
#### COLORS ###
black="\[\033[0;30m\]"
red="\[\033[0;31m\]"
green="\[\033[0;32m\]"
yellow="\[\033[0;33m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
cyan="\[\033[0;36m\]"
white="\[\033[0;37m\]"
bblack="\[\033[01;30m\]"
bred="\[\033[01;31m\]"
bgreen="\[\033[01;32m\]"
byellow="\[\033[01;33m\]"
bblue="\[\033[01;34m\]"
bpurple="\[\033[01;35m\]"
bcyan="\[\033[01;36m\]"
bwhite="\[\033[01;37m\]"
#
### pre prompt ###
function pre_prompt {
MY_PWD=`pwd`
let N_PWD=$(echo -n $MY_PWD | wc -c | tr -d " ")
let N_HOME=$(echo -n $HOME | wc -c | tr -d " ")
if [ "$MY_PWD" = "$HOME" ]
then
let radd=${COLUMNS}-17
elif [[ "$MY_PWD" == $HOME* ]]
then
let radd=${COLUMNS}-${N_PWD}+${N_HOME}-17
else
#echo "$MY_PWD "
let radd=${COLUMNS}-${N_PWD}-16
fi
fill=""
while [ "$radd" -gt "0" ]
do
fill="${fill}─"
let radd=${radd}-1
done
CLOCK=`date +%R:%S`
}
PROMPT_COMMAND=pre_prompt
### PS1 ###
PS1="──($cyan\w$white)\${fill}($bcyan\${CLOCK}$white)──\
\n > $cyan\u$white@$bcyan\h$white$CURSOR "
# bash_history settings: size and no duplicates and no lines w/ lead spaces
export HISTCONTROL="ignoreboth"
export HISTSIZE=1024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment