]> code.delx.au - dotfiles/blob - .bash/interactive
bash: sudosu alias, works with nologin accounts
[dotfiles] / .bash / interactive
1 #! bash
2
3 # Sets up the shell for interactive commands
4
5 # Use the terminfo backspace character as the erase character. This is not
6 # enabled by default because terminfo is often broken.
7 #stty erase $(tput kbs)
8
9 # Basic prompt only: user@host:directory$
10 PS1='\u@\h:\w\n\$ '
11
12 # Check for unsupported TERM variable
13 if ! tput init &> /dev/null; then
14 echo "Warning! TERM=$TERM unsupported, using TERM=xterm"
15 export TERM=xterm
16 fi
17
18 # The all important colours!
19 [ "${HOME}/.bash/colors" ] && source "${HOME}/.bash/colors"
20
21 # xterm titlebar displays 'hostname:workingdir'
22 if tput hs || tput tsl &> /dev/null; then
23 PROMPT_COMMAND='tput tsl; echo -n "$(hostname| cut -d. -f1):${PWD/$HOME/~}"; tput fsl;'
24 fi
25
26 # screen window displays current command
27 case "${TERM}" in
28 screen*)
29 PROMPT_COMMAND="$PROMPT_COMMAND echo -ne '\033k\033\\'"
30 ;;
31 esac
32
33 # Useful aliases
34 alias ls='ls --color=auto'
35 alias ll='ls -hlF'
36 alias la='ls -ha'
37 alias l='ls -halF'
38 alias ld='ls -ld'
39 alias f='find . -iname'
40 alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test()"'
41 alias rm='rm -i'
42 alias less='less -R'
43 alias grep='grep --color=auto --exclude "*.svn-base"'
44 alias scp='scp -o ControlPath=none'
45 alias bc='bc -ql'
46 alias vv='vncviewer -encodings "tight hextile copyrect"'
47 alias watch='watch -n1'
48 alias sudo='sudo ' # ability to use aliases with sudo
49 alias sudosu='sudo su -l -s /bin/bash'
50
51
52 # Colorful man pages
53 function man {
54 env \
55 LESS_TERMCAP_md=$'\E[01;38;5;74m' \
56 LESS_TERMCAP_me=$'\E[0m' \
57 LESS_TERMCAP_us=$'\E[04;38;5;146m' \
58 LESS_TERMCAP_ue=$'\E[0m' \
59 man "$@"
60 }
61
62 # Sets colours to be appropriate for a light on dark terminal
63 function darkterm {
64 DARK=1
65 source "${HOME}/.bash/colors"
66 }
67
68 # Sets the colours to be appropriate for a dark on light terminal
69 function lightterm {
70 DARK=0
71 source "${HOME}/.bash/colors"
72 }
73
74 # Usage: mcd somedir
75 # Creates the directory if it doesn't exist, and changes into it
76 function mcd {
77 mkdir -p "${1}" &&
78 cd "${1}"
79 }
80
81 # Usage: vimf somefile
82 # Does a recursive search of the current directory for somefile, then edits it
83 function vimf {
84 find . -name "${1}" -exec vim '{}' +
85 }
86
87 # Sets the nice and ionice priorities for the current shell to the lowest values
88 function slowshell {
89 ionice -c 3 -p $$
90 renice -n 19 -p $$
91 }
92
93
94 # Bash should check the terminal size after every command terminates
95 shopt -s checkwinsize
96
97 # Don't attempt to tab-complete an empty line
98 shopt -s no_empty_cmd_completion
99
100 # Local customisations
101 [ -r "${HOME}/.bash/interactive_local" ] && source "${HOME}/.bash/interactive_local"
102
103 # Load bash completion if available
104 [ -r "/etc/bash_completion" ] && source "/etc/bash_completion"
105