2011-07-25

useful bash shell

useful bash shell with colors to hint at importance
  • user@host
    (helpful when logged to several hosts simultaneously)
  • PWD above prompt
    (so as not to make the prompt appear at a variable column)
  • 24 hour time and date
    (helpful to know when you last used the shell, rough timer of statements)
  • History and jobs
    (a bit more context, shaded to denote less importance)
  • sectioned with '[' and ']' characters


On a Unix command line, input the following:

$ cat <<HEREDOC1

# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

# set a useful login prompt
PS1="\n\[\033[1;37m\][\u@\h:\w]\[\033[0m\] \[\033[1;35m\][\t on \d]\[\033[0m\] [history \!] [jobs \j]\n\[\033[1;37m\]$\[\033[0m\] "

# Add other directorys

PATH="${PATH}:${HOME}/bin"
export PATH

my_nano="$(which nano)"

my_clear="$(which clear)"
my_ps="$(which ps)"
my_ls="$(which ls)"
my_rm="$(which rm)"

alias l="${my_ls} -laspF"

alias lr="${my_ls} -lasFR"
alias lt="${my_ls} -lastF"
alias cls="${my_clear}"
alias clr="${my_clear}"
alias delete="${my_rm} --verbose --recursive --preserve-root --force"
alias psA="${my_ps} -aAdeflc"
alias psa="${my_ps} -ef"
alias e="${my_nano}"
HEREDOC1 > ~/.bashrc

$ cat <<HEREDOC2. .bashrc
HEREDOC2 > ~/.bash_profile

using putty, logged to an Amazon EC2 instance