3 # Check for unsupported TERM variable
4 if ! tput init &> /dev/null; then
5 echo "Warning! TERM=$TERM unsupported, using TERM=xterm"
11 # Fancy PS1 with revision control status for git, hg, svn
13 [ -r /usr/share/git/completion/git-prompt.sh ] && source /usr/share/git/completion/git-prompt.sh
15 find_up_recurse .git || return
16 GIT_PS1_SHOWDIRTYSTATE=1 \
17 GIT_PS1_SHOWUNTRACKEDFILES=1 \
18 __git_ps1 2> /dev/null
22 find_up_recurse .hg || return
23 b="$(hg branch 2>/dev/null)" || return
24 s="$(hg status | cut -c1 | sort -u | tr -d " \n")"
26 [ -n "$s" ] && echo -n " $s"
31 find_up_recurse .svn || return
32 s="$(svn status --ignore-externals 2>/dev/null | cut -c1 | sort -u | tr -d " \n")"
37 if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then
38 debian_chroot=$(cat /etc/debian_chroot)
40 PS1='${debian_chroot:+($debian_chroot)}'
41 PS1="$PS1"'\[\033[00;31m\]\u@\h\[\033[00m\]:\[\033[00;34m\]\w\[\033[00m\]'
42 PS1="$PS1"'\[\033[00;36m\]$(my_git_ps1 ; my_hg_ps1 ; my_svn_ps1)\[\033[00m\]'
49 eval $(TERM=xterm dircolors 2> /dev/null)
51 if [ "${DARKTERM:-1}" -eq 1 ]; then
53 # Sets colour scheme in apps like Vim
54 export COLORFGBG="15;0"
57 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/00;/01;/g')"
58 LSCOLORS="ExFxCxDxBxEGEDABAGACAD" # BSD ls
59 PS1="$(echo "${PS1}" | sed 's/00;/01;/g')"
63 # Sets colour scheme in apps like Vim
64 export COLORFGBG="0;15"
67 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/01;/00;/g')"
68 LSCOLORS="exfxcxdxbxegedabagacad" # BSD ls
72 # xterm titlebar displays 'hostname:workingdir'
73 if tput hs || tput tsl &> /dev/null; then
74 PROMPT_COMMAND='tput tsl; echo -n "$(hostname| cut -d. -f1):${PWD/$HOME/~}"; tput fsl;'
77 # screen window displays current command
80 PROMPT_COMMAND="$PROMPT_COMMAND echo -ne '\033k\033\\'"
85 alias ls='ls --color=auto'
89 alias f='find . -iname'
90 alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test()"'
93 alias grep='grep --color=auto --exclude "*.svn-base"'
94 alias scp='scp -o ControlPath=none'
96 alias vv='vncviewer -encodings "tight hextile copyrect"'
97 alias watch='watch -n1'
98 alias sudo='sudo ' # ability to use aliases with sudo
99 alias sudosu='sudo su -l -s /bin/bash'
100 alias _psresources='ps -weo pid,user:16,%cpu,%mem,stat,start_time,bsdtime,args'
101 alias pscpu='_psresources --sort -%cpu|less -S'
102 alias psmem='_psresources --sort -%mem|less -S'
103 alias pstree='ps --forest -weo pid,user:16,args --sort start_time|less -S'
104 alias pstime='ps -weo pid,user:16,lstart,args --sort start_time|less -S'
110 LESS_TERMCAP_md=$'\E[01;38;5;74m' \
111 LESS_TERMCAP_me=$'\E[0m' \
112 LESS_TERMCAP_us=$'\E[04;38;5;146m' \
113 LESS_TERMCAP_ue=$'\E[0m' \
118 # Creates the directory if it doesn't exist, and changes into it
124 # Usage: vimf somefile
125 # Does a recursive search of the current directory for somefile, then edits it
127 find . -iname "${1}" -exec vim '{}' +
130 # Sets the nice and ionice priorities for the current shell to the lowest values
137 # Bash should check the terminal size after every command terminates
138 shopt -s checkwinsize
140 # Don't attempt to tab-complete an empty line
141 shopt -s no_empty_cmd_completion
144 # Display return codes on error
145 function print_exit_code {
146 _exit_msg="\033[01;33mexit code: $?\033[00m"
147 if [ -z "${BASH_SOURCE[1]}" ]; then
152 trap print_exit_code ERR
156 # Local customisations
157 [ -r "${HOME}/.bash/interactive_local" ] && source "${HOME}/.bash/interactive_local"
159 # Load bash completion if available
160 [ -r "/etc/bash_completion" ] && source "/etc/bash_completion"