commit 03097795e74a60f12c11f7ff5e34b8d8e0c01dc2
parent 994ce6967e53a00db7940f94da9c17596089d98e
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 28 Sep 2020 21:09:15 -0700
Rename, remove, sort, move, and edit functions
move cd and xorg aliases to their respective files.
sort aliases and includes in main.
rename fe to fp and handle which(1) not finding an executable.
rename load to reload and source profile.
Diffstat:
3 files changed, 55 insertions(+), 53 deletions(-)
diff --git a/aliases/.config/aliases/cd b/aliases/.config/aliases/cd
@@ -0,0 +1,22 @@
+# cd functions to record directories visited and revisit them
+
+# record directories visited.
+cd() { builtin cd $@ && echo $PWD >> $PWDLOG ;}
+
+# filter chdir history keeping original line numbers.
+lcd() {
+ awk -vhome="^$HOME" '$0 != last && $0 != ENVIRON["HOME"] {last=$0; \
+ sub(home, "~", $0); printf "%d\t%s\n", FNR, $0 }' $PWDLOG
+}
+
+# redo specified chdir with it's index.
+rcdi() {
+ local dir=`head -n ${1:?No index specified} $PWDLOG | tail -1`
+ cd ${dir:?Non-existent entry} && echo "$dir"
+}
+
+# redo last chdir which matches regex.
+rcd() {
+ local d="$(egrep $@ $PWDLOG | tail -1)"
+ cd ${d:?No match}
+}
diff --git a/aliases/.config/aliases/main b/aliases/.config/aliases/main
@@ -2,78 +2,49 @@
. $ALIASES/util
-include private
-include mpc
+include cd
include git
+include mpc
include pkg
+include private
+include xorg
-# reload aliases
-alias load="include main"
-
-# add flags, change name, etc:
-alias pkill="pkill -x"
-alias la="ls -A"
+# aliases
alias cmd="command"
-alias mupdf="mupdf -I"
alias doas="doas -- "
-alias man="man "
-alias vim="vim -p"
-alias startx="startx -- -retard"
+alias f="$EDITOR"
alias gps="command gp"
-
-# use EREs:
-alias sed="sed -E"
alias grep="egrep"
-
-# short:
-alias f="$EDITOR"
+alias k="fc -s"
alias l="$PAGER"
-alias x="startx"
+alias la="ls -A"
+alias man="man "
+alias mupdf="mupdf -I"
+alias pkill="pkill -x"
+alias sed="sed -E"
+alias vim="vim -p"
-# clipboard:
-alias grab="xclip -selection clipboard"
-alias push="grab -out"
+# edit executable file in PATH
+fp() {
+ local bin=`which $@ 2>/dev/null`
+ f ${bin:?No such file or directory}
+}
-# search all history for `regex`
+# history search
hs() { fc -nl 0 | egrep "$1" ;}
# unset proxy variables
np() { unset ALL_PROXY; unset HTTP_PROXY ;}
-# sort human readable du output by size
-dush() { du -sh $@ | sort -h ;}
-
-# redo last command when typing out of order
-k() { fc -s ;}
-
-wQ() { webq "$*" ;}
-
unalias r 2>/dev/null
+# use all arguments for history search
r() { fc -s "$*" ;}
-# edit executable in PATH
-fe() { f `which $@` ;}
-
# use feed within FEED_DIR.
fed() { (builtin cd $FEED_DIR && feed $@) ;}
-# record directories visited.
-cd() { builtin cd $@ && echo $PWD >> $PWDLOG ;}
-
-# filter chdir history keeping original line numbers.
-lcd() {
- awk -vhome="^$HOME" '$0 != last && $0 != ENVIRON["HOME"] {last=$0; \
- sub(home, "~", $0); printf "%d\t%s\n", FNR, $0 }' $PWDLOG
-}
-
-# redo specified chdir with it's index.
-rcdi() {
- local dir=`head -n ${1:?No index specified} $PWDLOG | tail -1`
- cd ${dir:?Non-existent entry} && echo "$dir"
-}
-
-# redo last chdir which matches regex.
-rcd() {
- local d="$(egrep $@ $PWDLOG | tail -1)"
- cd ${d:?No match}
+# reload shell
+reload() {
+ . ~/.profile
+ include main
}
diff --git a/aliases/.config/aliases/xorg b/aliases/.config/aliases/xorg
@@ -0,0 +1,9 @@
+# xorg aliases
+
+# startx
+alias startx="startx -- -retard"
+alias x="startx"
+
+# xclip
+alias grab="xclip -selection clipboard"
+alias push="grab -out"