Customise Your Shell
noorbeast — Sat, 2010-06-26 20:51
Some people love a command-line shell, others avoid it as much as possible. But if you are going to use a terminal shell even casually, then add to functionality and dress it up.
To start customising your shell prompt check out: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
Here is the content of my .bashrc file for my custom shell prompt:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
########## Custom Prompt (courtesy of "Linux Desktop Hacks") ##########
function prompt_command
{
# Save current cursor position
tput sc
# backwash is where to set cursor (upper right side)
# to write CWD [col=screen width - (CWD +2) for brackets]
let backwash=$(tput cols)-$(echo $(pwd) | wc -m)-2
#position cursor at Y=0, X=calculated columr (see above)
tput cup 0 ${backwash}
#set foreground color and bold
tput setaf 4; tput bold
#Wrap path in brackets
echo -n "["
# show path
echo -n "$(pwd)"
#show closing bracket
echo -n "]"
#return cursor to saved position
tput rc
}
# Set prompt via function above
PROMPT_COMMAND=prompt_command
PURPLE="\[$(tput setaf 5 ; tput bold)\]"
BLACK="\[$(tput setaf 0 ; tput bold)\]"
NO_COLUR="\[$tput sgr0)\]"
case "$TERM" in
xterm*|rxvt*)
TITLEBAR='\[\033]0;\u@\h \007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1='\T \d: '
PS2='>'
PS4='+'
########## Custom Prompt (courtesy of "Linux Desktop Hacks") ##########
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi