]> git.wh0rd.org - home.git/blobdiff - .profile.d/aliases.sh
cros-board: update
[home.git] / .profile.d / aliases.sh
index f93e5eb222861d3efb94cb7800e6aa39085b76eb..6c3a9b12837e38d047792f1eb4bbebed5397dac0 100644 (file)
@@ -1,10 +1,9 @@
-[[ $- != *i* ]] && return
-
 alias axine='xine -A null'
+alias b='bzr'
 alias bc='bc -q'
 #alias bittorrent-curses='bittorrent-curses --max_upload_rate 10'
 #alias bt='bittorrent-curses --max_upload_rate 10 --save_in . --save_incomplete_in .'
-alias cdrecord='cdrecord -vvv driveropts=burnfree'
+alias cdrecord='cdrecord -vvv -eject driveropts=burnfree'
 alias duh='du . --max-depth=1 -h'
 alias eclipse='eclipse-3.2 -vmargs -Xmx512m'
 alias g='git'
@@ -12,7 +11,12 @@ alias gdb='gdb --quiet'
 alias gdbtui='gdbtui --quiet'
 alias nohist='export HISTFILE=/dev/null'
 alias kpdf='okular'
-alias lynx='lynx -nopause -accept_all_cookies -use_mouse'
+if command -v elinks >/dev/null ; then
+       alias links='elinks -default-mime-type text/html'
+       alias lynx=links
+elif command -v lynx >/dev/null ; then
+       alias lynx='lynx -nopause -accept_all_cookies -use_mouse'
+fi
 alias minicom='minicom -w -c on'
 alias nslookup='nslookup -sil'
 alias p1='patch -p1'
@@ -20,40 +24,152 @@ alias p1d='patch -p1 --dry-run'
 alias p1dr='patch -p1 --dry-run -R'
 alias p1r='patch -p1 -R'
 alias quake4='quake4 +set s_driver oss'
-alias repoman='repoman -q -q'
-alias rrsync='rsync -av --inplace --progress'
+alias rrsync='rsync -Hav --inplace --progress'
 alias s='aspell -a'
-ss() { aspell -a <<<"$*"; }
+sss() { aspell -a <<<"$*"; }
+sdisp() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec "$0" "$@"' "$@" ; }
+smplayer() { sdisp mplayer "$@" ; }
+smpv() { sdisp mpv "$@" ; }
+svlc() { sdisp vlc "$@" ; }
+svnc() { sdisp x11vnc -q -nopw ; }
+sweb() { sdisp google-chrome-beta "$@" ; }
+sxdg() { sdisp xdg-open "$@" ; }
+alias trc=tremc
 alias xine='xine -l'
 
+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'
+
+_ipython() {
+       # These guys keep changing their CLI because they hate their users.
+       local cmd=$1; shift
+       local args=(
+               --no-banner
+               --no-confirm-exit
+               --pdb
+               --nosep
+               --term-title
+               --pprint
+       )
+
+       case $(command ${cmd} --version) in
+       0*) ;;
+       [123]*)
+               args+=(
+                       --PromptManager.in_template='>>> '
+                       --PromptManager.out_template=''
+                       --PromptManager.justify=False
+               )
+               ;;
+       esac
+
+       command ${cmd} "${args[@]}" "$@"
+}
+ipython()  { _ipython ${FUNCNAME}; }
+ipython2() { _ipython ${FUNCNAME}; }
+ipython3() { _ipython ${FUNCNAME}; }
+
+adk_path() {
+       local adk=/usr/local/src/android/adk/current/sdk
+       PATH+=":${adk}/tools:${adk}/platform-tools"
+}
+
+pd() {
+       if [[ $# -eq 0 ]] ; then
+               popd
+       elif [[ $# -eq 1 && $1 == "--" ]] ; then
+               dirs -v
+       else
+               pushd "$@"
+       fi
+}
+
+cd_history() {
+       if [[ $# -eq 1 ]] ; then
+               case $1 in
+               -h)
+                       command dirs "$1" |& tail -1
+                       command cd "$1" |& tail -1
+                       return
+                       ;;
+               --help)
+                       command dirs "$1"
+                       command cd "$1"
+                       return
+                       ;;
+               -[clpv])
+                       command dirs "$1"
+                       return
+                       ;;
+               -[0-9]*)
+                       set -- "$(dirs "+${1:1}")"
+                       ;;
+               esac
+       fi
+
+       if command cd "$@" ; then
+               pushd -n "${PWD}" >/dev/null
+       else
+               local ret=$?
+
+               if [[ $# -gt 1 ]] ; then
+                       # The `cd` above should have shown an error message for us.
+                       local arg first_arg="$1"
+                       while [[ $# -gt 0 ]] ; do
+                               arg="$1"
+                               shift
+                               if [[ -d ${arg} ]] ; then
+                                       if [[ $# -gt 0 ]] ; then
+                                               printf 'cd: remaining: %s\n' "$@" >&2
+                                       fi
+                                       printf 'cd: entering: %s\n' "${arg}" >&2
+                                       cd_history "${arg}"
+                                       return
+                               else
+                                       printf 'cd: skipping: %s\n' "${arg}" >&2
+                               fi
+                       done
+                       # If we're still here, then we didn't cd anywhere.
+                       echo "cd: cwd is unchanged!" >&2
+               fi
+
+               return ${ret}
+       fi
+}
+alias cd='cd_history'
+
 if [[ ${TERM} != "dumb" ]] ; then
-       alias grep='grep --colour=auto'
+       export GREP_COLORS=ne #470810
+       alias grep='grep --colour=auto -d skip'
        alias ls='ls --color=auto'
 fi
 
-grep-svn() { find '(' -wholename '*/.svn' -prune -o -type f -print0 ')' | xargs -0 grep "$@" ; }
-
 scrub_patch() {
-    sed -i \
-        -e '/^index /d' \
+       sed -i \
+               -e '/^index /d' \
                -e '/^new file mode /d' \
-        -e '/^Index:/d' \
+               -e '/^Index:/d' \
                -e '/^=========/d' \
                -e '/^RCS file:/d' \
                -e '/^retrieving/d' \
                -e '/^diff/d' \
                -e '/^Files .* differ$/d' \
+               -e '/^Binary files .* differ$/d' \
                -e '/^Only in /d' \
                -e '/^Common subdirectories/d' \
-        -e '/^+++/s:\t.*::' \
-        -e '/^---/s:\t.*::' \
-        "$@"
+               -e '/^deleted file mode [0-9]*$/d' \
+               -e '/^+++/s:\t.*::' \
+               -e '/^---/s:\t.*::' \
+               "$@"
 }
 
 scrub_html() {
-       sed -i \
-               -e 's:&lt;:<:g' -e 's:&gt;:>:g' \
-               -e 's:&nbsp;::g' -e 's:&amp;:\&:g' \
-               -e 's:&quot;:":g' \
-               "$@"
+       local a=(
+               'lt'    '<'
+               'gt'    '>'
+               'nbsp'  ' '
+               'amp'   '&'
+               'quot'  '"'
+       )
+       [[ $# -gt 0 ]] && set -- "$@" -i
+       eval sed \"\$@\" $(printf -- ' -e "s|\&%s;|%q|g"' "${a[@]}")
 }