]> git.wh0rd.org Git - home.git/blob - .profile.d/aliases.sh
aliases: cd: fix return code with basic failures
[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 smpv() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec mpv "$@"' sh "$@" ; }
32 svlc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec vlc "$@" >/dev/null 2>&1' sh "$@" ; }
33 svnc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec x11vnc -q -nopw' ; }
34 alias trc=transmission-remote-cli
35 alias xine='xine -l'
36
37 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'
38
39 _ipython() {
40         # These guys keep changing their CLI because they hate their users.
41         local cmd=$1; shift
42         local args=(
43                 --no-banner
44                 --no-confirm-exit
45                 --pdb
46                 --nosep
47                 --term-title
48                 --pprint
49         )
50
51         case $(command ${cmd} --version) in
52         0*) ;;
53         [123]*)
54                 args+=(
55                         --PromptManager.in_template='>>> '
56                         --PromptManager.out_template=''
57                         --PromptManager.justify=False
58                 )
59                 ;;
60         esac
61
62         command ${cmd} "${args[@]}" "$@"
63 }
64 ipython()  { _ipython ${FUNCNAME}; }
65 ipython2() { _ipython ${FUNCNAME}; }
66 ipython3() { _ipython ${FUNCNAME}; }
67
68 adk_path() {
69         local adk=/usr/local/src/android/adk/current/sdk
70         PATH+=":${adk}/tools:${adk}/platform-tools"
71 }
72
73 pd() {
74         if [[ $# -eq 0 ]] ; then
75                 popd
76         elif [[ $# -eq 1 && $1 == "--" ]] ; then
77                 dirs -v
78         else
79                 pushd "$@"
80         fi
81 }
82
83 cd_history() {
84         if [[ $# -eq 1 ]] ; then
85                 case $1 in
86                 -h)
87                         command dirs "$1" |& tail -1
88                         command cd "$1" |& tail -1
89                         return
90                         ;;
91                 --help)
92                         command dirs "$1"
93                         command cd "$1"
94                         return
95                         ;;
96                 -[clpv])
97                         command dirs "$1"
98                         return
99                         ;;
100                 -[0-9]*)
101                         set -- "$(dirs "+${1:1}")"
102                         ;;
103                 esac
104         fi
105
106         if command cd "$@" ; then
107                 pushd -n "${PWD}" >/dev/null
108         else
109                 local ret=$?
110
111                 if [[ $# -gt 1 ]] ; then
112                         # The `cd` above should have shown an error message for us.
113                         local arg first_arg="$1"
114                         while [[ $# -gt 0 ]] ; do
115                                 arg="$1"
116                                 shift
117                                 if [[ -d ${arg} ]] ; then
118                                         if [[ $# -gt 0 ]] ; then
119                                                 printf 'cd: remaining: %s\n' "$@" >&2
120                                         fi
121                                         printf 'cd: entering: %s\n' "${arg}" >&2
122                                         cd_history "${arg}"
123                                         return
124                                 else
125                                         printf 'cd: skipping: %s\n' "${arg}" >&2
126                                 fi
127                         done
128                         # If we're still here, then we didn't cd anywhere.
129                         echo "cd: cwd is unchanged!" >&2
130                 fi
131
132                 return ${ret}
133         fi
134 }
135 alias cd='cd_history'
136
137 if [[ ${TERM} != "dumb" ]] ; then
138         export GREP_COLORS=ne #470810
139         alias grep='grep --colour=auto -d skip'
140         alias ls='ls --color=auto'
141 fi
142
143 scrub_patch() {
144         sed -i \
145                 -e '/^index /d' \
146                 -e '/^new file mode /d' \
147                 -e '/^Index:/d' \
148                 -e '/^=========/d' \
149                 -e '/^RCS file:/d' \
150                 -e '/^retrieving/d' \
151                 -e '/^diff/d' \
152                 -e '/^Files .* differ$/d' \
153                 -e '/^Binary files .* differ$/d' \
154                 -e '/^Only in /d' \
155                 -e '/^Common subdirectories/d' \
156                 -e '/^deleted file mode [0-9]*$/d' \
157                 -e '/^+++/s:\t.*::' \
158                 -e '/^---/s:\t.*::' \
159                 "$@"
160 }
161
162 scrub_html() {
163         local a=(
164                 'lt'    '<'
165                 'gt'    '>'
166                 'nbsp'  ' '
167                 'amp'   '&'
168                 'quot'  '"'
169         )
170         [[ $# -gt 0 ]] && set -- "$@" -i
171         eval sed \"\$@\" $(printf -- ' -e "s|\&%s;|%q|g"' "${a[@]}")
172 }