BASH Modification

From Indie IT Wiki

HOWTO: MODIFY:

Colours

For reference...

export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[0;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'

At the end of ~/.bashrc...

Normal User (yellow)...

# Set up a decent prompt giving you the full hostname!
HOST=$( hostname -f )
if [[ $TERM =~ screen ]] ; then
    PS1="\[\033[01;33m\]\u@$HOST\[\033[01;34m\] \w \$\[\033[00m\] (screen) (laptop) "
else
    PS1="\[\033[01;33m\]\u@$HOST\[\033[01;34m\] \w \$\[\033[00m\] (laptop) "
fi

Root User (red)...

# Set up a decent prompt giving you the full hostname!
HOST=$( hostname -f )
if [[ $TERM =~ screen ]] ; then
    PS1="\[\033[01;31m\]\u@$HOST\[\033[01;34m\] \w \$\[\033[00m\] (screen) (laptop) "
else
    PS1="\[\033[01;31m\]\u@$HOST\[\033[01;34m\] \w \$\[\033[00m\] (laptop) "
fi

Aliases

Open a terminal and edit the .bashrc file:

nano ~/.bashrc

Edit or add the following lines:

alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias get='get_iplayer/get_iplayer'
alias grep='grep --color=auto'
alias hg='history |grep'
alias install='sudo aptitude -v install'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -lah'
alias ls='ls --color=auto'
alias myip='curl ifconfig.me'
alias ping='ping -c3 -n -i 0.2 -W1'
alias pingg='ping www.google.co.uk'
alias pingp='ping www.paully.co.uk'
alias pingm='ping 10.0.0.1'
alias pings='ping 192.168.0.1'
alias rav='rsync -a -v'
alias remove='sudo apt-get autoremove'
alias rm='rm -iv'
alias search='sudo apt-cache search'
alias ss='gksudo software-properties-gtk'
alias sshg='ssh username@server1.indie-it.com'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias uu='sudo apt-get update && sudo apt-get upgrade'
alias uuf='sudo apt-get update && sudo apt-get dist-upgrade'

Reload the file:

source ~/.bashrc

To confirm the entries:

alias

Title of X Terminals

Add the following lines in your .bashrc file:

nano ~/.bashrc

# Change the window title of X terminals 
case $TERM in
        xterm*|rxvt*|Eterm)
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
                ;;
        screen)
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
                ;;
esac