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\]'
47 # Display return codes on error
48 function print_exit_code {
49 _exit_msg="\033[01;33mexit code: $?\033[00m"
50 if [ -z "${BASH_SOURCE[1]}" ]; then
55 trap print_exit_code ERR
60 eval $(TERM=xterm dircolors 2> /dev/null)
62 if [ "${DARKTERM:-1}" -eq 1 ]; then
64 # Sets colour scheme in apps like Vim
65 export COLORFGBG="15;0"
68 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/00;/01;/g')"
69 LSCOLORS="ExFxCxDxBxEGEDABAGACAD" # BSD ls
70 PS1="$(echo "${PS1}" | sed 's/00;/01;/g')"
74 # Sets colour scheme in apps like Vim
75 export COLORFGBG="0;15"
78 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/01;/00;/g')"
79 LSCOLORS="exfxcxdxbxegedabagacad" # BSD ls
83 # xterm titlebar displays 'hostname:workingdir'
84 if tput hs || tput tsl &> /dev/null; then
85 PROMPT_COMMAND='tput tsl; echo -n "$(hostname| cut -d. -f1):${PWD/$HOME/~}"; tput fsl;'
88 # screen window displays current command
91 PROMPT_COMMAND="$PROMPT_COMMAND echo -ne '\033k\033\\'"
96 alias ls='ls --color=auto'
100 alias f='find . -iname'
101 alias webshare='python3 -mhttp.server'
104 alias grep='grep --color=auto --exclude "*.svn-base"'
105 alias scp='scp -o ControlPath=none'
107 alias watch='watch -n1'
108 alias sudo='sudo ' # ability to use aliases with sudo
109 alias sudosu='sudo su -l -s /bin/bash'
110 alias _psresources='ps -weo pid,user:16,%cpu,%mem,stat,start_time,bsdtime,args'
111 alias pscpu='_psresources --sort -%cpu|less -S'
112 alias psmem='_psresources --sort -%mem|less -S'
113 alias pstree='ps --forest -weo pid,user:16,args --sort start_time|less -S'
114 alias pstime='ps -weo pid,user:16,lstart,args --sort start_time|less -S'
121 tput tsl; echo "man $@"; tput fsl
124 LESS_TERMCAP_md=$'\E[01;38;5;74m' \
125 LESS_TERMCAP_me=$'\E[0m' \
126 LESS_TERMCAP_us=$'\E[04;38;5;146m' \
127 LESS_TERMCAP_ue=$'\E[0m' \
132 # Creates the directory if it doesn't exist, and changes into it
138 # Usage: vimf somefile
139 # Does a recursive search of the current directory for somefile, then edits it
141 find . -iname "${1}" -exec vim '{}' +
144 # Sets the nice and ionice priorities for the current shell to the lowest values
150 # SSH to an unknown host and print the new known_hosts entry
152 local new_known_hosts_file="$(mktemp)"
153 ssh -o UserKnownHostsFile="$new_known_hosts_file" "$1" echo Connection ok
154 cat "$new_known_hosts_file"
155 rm -f "$new_known_hosts_file"
159 # Bash should check the terminal size after every command terminates
160 shopt -s checkwinsize
162 # Don't attempt to tab-complete an empty line
163 shopt -s no_empty_cmd_completion
167 # Local customisations
168 [ -r "${HOME}/.bash/interactive_local" ] && source "${HOME}/.bash/interactive_local"
170 # Load bash completion if available
171 [ -r "/etc/bash_completion" ] && source "/etc/bash_completion"