]> code.delx.au - dotfiles/blob - .bash/interactive
bash: ps aliases
[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 f='find . -iname'
39 alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test()"'
40 alias rm='rm -i'
41 alias less='less -R'
42 alias grep='grep --color=auto --exclude "*.svn-base"'
43 alias scp='scp -o ControlPath=none'
44 alias bc='bc -ql'
45 alias vv='vncviewer -encodings "tight hextile copyrect"'
46 alias watch='watch -n1'
47 alias sudo='sudo ' # ability to use aliases with sudo
48 alias sudosu='sudo su -l -s /bin/bash'
49 alias _psresources='ps -weo pid,user:16,%cpu,%mem,stat,start_time,bsdtime,args'
50 alias pscpu='_psresources --sort -%cpu|less -S'
51 alias psmem='_psresources --sort -%mem|less -S'
52 alias pstree='ps --forest -weo pid,user:16,args --sort start_time|less -S'
53 alias pstime='ps -weo pid,user:16,lstart,args --sort start_time|less -S'
54
55
56 # Colorful man pages
57 function man {
58 env \
59 LESS_TERMCAP_md=$'\E[01;38;5;74m' \
60 LESS_TERMCAP_me=$'\E[0m' \
61 LESS_TERMCAP_us=$'\E[04;38;5;146m' \
62 LESS_TERMCAP_ue=$'\E[0m' \
63 man "$@"
64 }
65
66 # Sets colours to be appropriate for a light on dark terminal
67 function darkterm {
68 DARK=1
69 source "${HOME}/.bash/colors"
70 }
71
72 # Sets the colours to be appropriate for a dark on light terminal
73 function lightterm {
74 DARK=0
75 source "${HOME}/.bash/colors"
76 }
77
78 # Usage: mcd somedir
79 # Creates the directory if it doesn't exist, and changes into it
80 function mcd {
81 mkdir -p "${1}" &&
82 cd "${1}"
83 }
84
85 # Usage: vimf somefile
86 # Does a recursive search of the current directory for somefile, then edits it
87 function vimf {
88 find . -name "${1}" -exec vim '{}' +
89 }
90
91 # Sets the nice and ionice priorities for the current shell to the lowest values
92 function slowshell {
93 ionice -c 3 -p $$
94 renice -n 19 -p $$
95 }
96
97
98 # Bash should check the terminal size after every command terminates
99 shopt -s checkwinsize
100
101 # Don't attempt to tab-complete an empty line
102 shopt -s no_empty_cmd_completion
103
104 # Local customisations
105 [ -r "${HOME}/.bash/interactive_local" ] && source "${HOME}/.bash/interactive_local"
106
107 # Load bash completion if available
108 [ -r "/etc/bash_completion" ] && source "/etc/bash_completion"
109