]> git.wh0rd.org - home.git/blob - .profile.d/aliases.sh
cd_history: handle multiple args to `cd`
[home.git] / .profile.d / aliases.sh
1 alias axine='xine -A null'
2 alias b='bzr'
3 alias bc='bc -q'
4 #alias bittorrent-curses='bittorrent-curses --max_upload_rate 10'
5 #alias bt='bittorrent-curses --max_upload_rate 10 --save_in . --save_incomplete_in .'
6 alias cdrecord='cdrecord -vvv -eject driveropts=burnfree'
7 alias duh='du . --max-depth=1 -h'
8 alias eclipse='eclipse-3.2 -vmargs -Xmx512m'
9 alias g='git'
10 alias gdb='gdb --quiet'
11 alias gdbtui='gdbtui --quiet'
12 alias nohist='export HISTFILE=/dev/null'
13 alias kpdf='okular'
14 if command -v elinks >/dev/null ; then
15 alias links='elinks -default-mime-type text/html'
16 alias lynx=links
17 elif command -v lynx >/dev/null ; then
18 alias lynx='lynx -nopause -accept_all_cookies -use_mouse'
19 fi
20 alias minicom='minicom -w -c on'
21 alias nslookup='nslookup -sil'
22 alias p1='patch -p1'
23 alias p1d='patch -p1 --dry-run'
24 alias p1dr='patch -p1 --dry-run -R'
25 alias p1r='patch -p1 -R'
26 alias quake4='quake4 +set s_driver oss'
27 alias rrsync='rsync -Hav --inplace --progress'
28 alias s='aspell -a'
29 sss() { aspell -a <<<"$*"; }
30 smplayer() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec mplayer "$@" >/dev/null 2>&1' sh "$@" ; }
31 svlc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec vlc "$@" >/dev/null 2>&1' sh "$@" ; }
32 svnc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec x11vnc -q -nopw' ; }
33 alias trc=transmission-remote-cli
34 alias xine='xine -l'
35
36 alias wol-vapier='wakeonlan -i 192.168.1.255 00:25:22:64:19:79; wakeonlan -i 192.168.0.255 00:25:22:64:19:79'
37
38 _ipython() {
39 # These guys keep changing their CLI because they hate their users.
40 local cmd=$1; shift
41 local args=(
42 --no-banner
43 --no-confirm-exit
44 --pdb
45 --nosep
46 --term-title
47 --pprint
48 )
49
50 case $(command ${cmd} --version) in
51 0*) ;;
52 [123]*)
53 args+=(
54 --PromptManager.in_template='>>> '
55 --PromptManager.out_template=''
56 --PromptManager.justify=False
57 )
58 ;;
59 esac
60
61 command ${cmd} "${args[@]}" "$@"
62 }
63 ipython() { _ipython ${FUNCNAME}; }
64 ipython2() { _ipython ${FUNCNAME}; }
65 ipython3() { _ipython ${FUNCNAME}; }
66
67 adk_path() {
68 local adk=/usr/local/src/android/adk/current/sdk
69 PATH+=":${adk}/tools:${adk}/platform-tools"
70 }
71
72 pd() {
73 if [[ $# -eq 0 ]] ; then
74 popd
75 elif [[ $# -eq 1 && $1 == "--" ]] ; then
76 dirs -v
77 else
78 pushd "$@"
79 fi
80 }
81
82 cd_history() {
83 if [[ $# -eq 1 ]] ; then
84 case $1 in
85 -h)
86 command dirs "$1" |& tail -1
87 command cd "$1" |& tail -1
88 return
89 ;;
90 --help)
91 command dirs "$1"
92 command cd "$1"
93 return
94 ;;
95 -[clpv])
96 command dirs "$1"
97 return
98 ;;
99 -[0-9]*)
100 set -- "$(dirs "+${1:1}")"
101 ;;
102 esac
103 fi
104 if command cd "$@" ; then
105 pushd -n "${PWD}" >/dev/null
106 elif [[ $# -gt 1 ]] ; then
107 # The `cd` above should have shown an error message for us.
108 local arg first_arg="$1"
109 while [[ $# -gt 0 ]] ; do
110 arg="$1"
111 shift
112 if [[ -d ${arg} ]] ; then
113 if [[ $# -gt 0 ]] ; then
114 printf 'cd: remaining: %s\n' "$@" >&2
115 fi
116 printf 'cd: entering: %s\n' "${arg}" >&2
117 cd_history "${arg}"
118 return
119 else
120 printf 'cd: skipping: %s\n' "${arg}" >&2
121 fi
122 done
123 # If we're still here, then we didn't cd anywhere.
124 echo "cd: cwd is unchanged!" >&2
125 fi
126 }
127 alias cd='cd_history'
128
129 if [[ ${TERM} != "dumb" ]] ; then
130 export GREP_COLORS=ne #470810
131 alias grep='grep --colour=auto -d skip'
132 alias ls='ls --color=auto'
133 fi
134
135 scrub_patch() {
136 sed -i \
137 -e '/^index /d' \
138 -e '/^new file mode /d' \
139 -e '/^Index:/d' \
140 -e '/^=========/d' \
141 -e '/^RCS file:/d' \
142 -e '/^retrieving/d' \
143 -e '/^diff/d' \
144 -e '/^Files .* differ$/d' \
145 -e '/^Binary files .* differ$/d' \
146 -e '/^Only in /d' \
147 -e '/^Common subdirectories/d' \
148 -e '/^deleted file mode [0-9]*$/d' \
149 -e '/^+++/s:\t.*::' \
150 -e '/^---/s:\t.*::' \
151 "$@"
152 }
153
154 scrub_html() {
155 local a=(
156 'lt' '<'
157 'gt' '>'
158 'nbsp' ' '
159 'amp' '&'
160 'quot' '"'
161 )
162 [[ $# -gt 0 ]] && set -- "$@" -i
163 eval sed \"\$@\" $(printf -- ' -e "s|\&%s;|%q|g"' "${a[@]}")
164 }