#! bash # Sets up the shell for interactive commands # Use the terminfo backspace character as the erase character. This is not # enabled by default because terminfo is often broken. #stty erase $(tput kbs) # Basic prompt only: user@host:directory$ PS1='\u@\h:\w\n\$ ' # Check for unsupported TERM variable if ! tput init &> /dev/null; then echo "Warning! TERM=$TERM unsupported, using TERM=xterm" export TERM=xterm fi # The all important colours! [ "${HOME}/.bash/colors" ] && source "${HOME}/.bash/colors" # xterm titlebar displays 'hostname:workingdir' if tput hs || tput tsl &> /dev/null; then PROMPT_COMMAND='tput tsl; echo -n "$(hostname| cut -d. -f1):${PWD/$HOME/~}"; tput fsl;' fi # screen window displays current command case "${TERM}" in screen*) PROMPT_COMMAND="$PROMPT_COMMAND echo -ne '\033k\033\\'" ;; esac # Useful aliases alias ls='ls --color=auto' alias ll='ls -hlF' alias la='ls -ha' alias l='ls -halF' alias f='find . -iname' alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test()"' alias rm='rm -i' alias less='less -R' alias grep='grep --color=auto --exclude "*.svn-base"' alias scp='scp -o ControlPath=none' alias bc='bc -ql' alias vv='vncviewer -encodings "tight hextile copyrect"' alias watch='watch -n1' alias sudo='sudo ' # ability to use aliases with sudo alias sudosu='sudo su -l -s /bin/bash' alias _psresources='ps -weo pid,user:16,%cpu,%mem,stat,start_time,bsdtime,args' alias pscpu='_psresources --sort -%cpu|less -S' alias psmem='_psresources --sort -%mem|less -S' alias pstree='ps --forest -weo pid,user:16,args --sort start_time|less -S' alias pstime='ps -weo pid,user:16,lstart,args --sort start_time|less -S' # Colorful man pages function man { env \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ LESS_TERMCAP_me=$'\E[0m' \ LESS_TERMCAP_us=$'\E[04;38;5;146m' \ LESS_TERMCAP_ue=$'\E[0m' \ man "$@" } # Sets colours to be appropriate for a light on dark terminal function darkterm { DARK=1 source "${HOME}/.bash/colors" } # Sets the colours to be appropriate for a dark on light terminal function lightterm { DARK=0 source "${HOME}/.bash/colors" } # Usage: mcd somedir # Creates the directory if it doesn't exist, and changes into it function mcd { mkdir -p "${1}" && cd "${1}" } # Usage: vimf somefile # Does a recursive search of the current directory for somefile, then edits it function vimf { find . -name "${1}" -exec vim '{}' + } # Sets the nice and ionice priorities for the current shell to the lowest values function slowshell { ionice -c 3 -p $$ renice -n 19 -p $$ } # Bash should check the terminal size after every command terminates shopt -s checkwinsize # Don't attempt to tab-complete an empty line shopt -s no_empty_cmd_completion # Local customisations [ -r "${HOME}/.bash/interactive_local" ] && source "${HOME}/.bash/interactive_local" # Load bash completion if available [ -r "/etc/bash_completion" ] && source "/etc/bash_completion"