]> git.wh0rd.org - home.git/blobdiff - .profile.d/aliases.sh
cros-board: update
[home.git] / .profile.d / aliases.sh
index 3ee83b7f206b561e5c1e5e1922b97fca2e6e8d3a..6c3a9b12837e38d047792f1eb4bbebed5397dac0 100644 (file)
@@ -11,7 +11,6 @@ alias gdb='gdb --quiet'
 alias gdbtui='gdbtui --quiet'
 alias nohist='export HISTFILE=/dev/null'
 alias kpdf='okular'
-alias ipython='ipython --no-banner --no-confirm-exit --pdb --nosep --PromptManager.in_template=">>> " --PromptManager.out_template="" --PromptManager.justify=False'
 if command -v elinks >/dev/null ; then
        alias links='elinks -default-mime-type text/html'
        alias lynx=links
@@ -28,14 +27,47 @@ alias quake4='quake4 +set s_driver oss'
 alias rrsync='rsync -Hav --inplace --progress'
 alias s='aspell -a'
 sss() { aspell -a <<<"$*"; }
-smplayer() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec mplayer "$@" >/dev/null 2>&1' sh "$@" ; }
-svlc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec vlc "$@" >/dev/null 2>&1' sh "$@" ; }
-svnc() { sudo -u smriti sh -c 'export DISPLAY=:0; xset s reset; exec x11vnc -q -nopw' ; }
-alias trc=transmission-remote-cli
+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"
@@ -73,8 +105,34 @@ cd_history() {
                        ;;
                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'