commit e403c65313ba17aa8f4b3fac1c84a034e32357a3
parent e1b84cbaac75940734858f23527ef9c35d2d71ec
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 15 Feb 2021 01:04:05 -0800
Simplify shell functions
Remove compounds when possible or when it makes it more readable
and remove the redundent `local' when setting IFS in the `veronica'
function.
Diffstat:
9 files changed, 42 insertions(+), 46 deletions(-)
diff --git a/modules/shell/.config/shell/aliases b/modules/shell/.config/shell/aliases
@@ -1,15 +1,15 @@
# simple shell functions
-ap() { apropos "$@" ;}
-date() { command date "${@:-+%F %T %z}" ;}
-grep() { egrep "$@" ;}
-man() { command man "$@" ;}
-mtime() { stat -t '%F %T' -f%Sm%t%N "$@" ;}
-pkill() { command pkill -x "$@" ;}
-sed() { command sed -E "$@" ;}
+ap() apropos "$@"
+date() command date "${@:-+%F %T %z}"
+grep() egrep "$@"
+man() command man "$@"
+mtime() stat -t '%F %T' -f%Sm%t%N "$@"
+pkill() command pkill -x "$@"
+sed() command sed -E "$@"
-f() { $EDITOR "$@" ;}
-g() { git "$@" ;}
-l() { $PAGER "$@" ;}
-t() { tmux "$@" ;}
-d() { doas "$@" ;}
+f() $EDITOR "$@"
+g() git "$@"
+l() $PAGER "$@"
+t() tmux "$@"
+d() doas "$@"
diff --git a/modules/shell/.config/shell/cd b/modules/shell/.config/shell/cd
@@ -21,4 +21,4 @@ cdr() {
cd ${d:?No match}
}
-goto() { cd "`ets $1`/$2" ;}
+goto() cd "`ets $1`/$2"
diff --git a/modules/shell/.config/shell/fs b/modules/shell/.config/shell/fs
@@ -1,10 +1,6 @@
# filesystem shell functions
-ls() { command ls -1 "$@" ;}
+ls() command ls -1 "$@"
lsc() { ls "$@" | rs ;}
-sfind() { find . -maxdepth 1 "$@" ;}
-
-fp() {
- local bin=`which "$@" 2>/dev/null`
- f ${bin:?No path specified}
-}
+sfind() find . -maxdepth 1 "$@"
+fp() f `which "${@:?No path specified}" 2>/dev/null`
diff --git a/modules/shell/.config/shell/gopher b/modules/shell/.config/shell/gopher
@@ -1,4 +1,4 @@
# gopher shell functions
-veronica() (local IFS='?' && gawk "/v2/vs/?${@:?No query}" floodgap.com)
-vs() { veronica "$@" ;}
+veronica() (IFS='?' && gawk "/v2/vs/?${@:?No query}" floodgap.com)
+vs() veronica "$@"
diff --git a/modules/shell/.config/shell/hist b/modules/shell/.config/shell/hist
@@ -2,6 +2,6 @@
unalias r 2>/dev/null
-k() { fc -s ;}
-r() { fc -s ""$@"" ;}
+k() fc -s
+r() fc -s "$@"
hs() { fc -nl 0 | egrep "$@" ;}
diff --git a/modules/shell/.config/shell/mpc b/modules/shell/.config/shell/mpc
@@ -1,12 +1,12 @@
# mpc shell functions
-m() { mpc "$@" ;}
-mP() { m searchplay any "$@" ;}
-ma() { m add "$@" ;}
-mi() { m play "$@" ;}
-mj() { m next "$@" ;}
-ml() { m playlist "$@" ;}
-mo() { m prev "$@" ;}
-ms() { m search any "$@" ;}
-mt() { m toggle "$@" ;}
+m() mpc "$@"
+mP() m searchplay any "$@"
+ma() m add "$@"
+mi() m play "$@"
+mj() m next "$@"
+ml() m playlist "$@"
+mo() m prev "$@"
+ms() m search any "$@"
+mt() m toggle "$@"
mf() { m listall | egrep "$@" ;}
diff --git a/modules/shell/.config/shell/openbsd b/modules/shell/.config/shell/openbsd
@@ -1,12 +1,12 @@
# OpenBSD shell functions
-ncpu() { sysctl -n hw.ncpufound "$@" ;}
-load() { sysctl -n vm.loadavg "$@" ;}
+ncpu() sysctl -n hw.ncpufound "$@"
+load() sysctl -n vm.loadavg "$@"
# package management
-pa() { doas pkg_add -xV "$@" ;}
-pd() { doas pkg_delete -xV "$@" ;}
-pi() { pkg_info "$@" ;}
-pu() { doas pkg_add -u "$@" ;}
+pa() doas pkg_add -xV "$@"
+pd() doas pkg_delete -xV "$@"
+pi() pkg_info "$@"
+pu() doas pkg_add -u "$@"
pq() { egrep "$@" /usr/local/share/ports-INDEX | cut -d'|' -f1,4 | tr '|' '\t' ;}
-pQ() { pkg_locate "$@" ;}
+pQ() pkg_locate "$@"
diff --git a/modules/shell/.config/shell/sys b/modules/shell/.config/shell/sys
@@ -1,4 +1,4 @@
# system management shell functions
-doas() { command doas -- "$@" ;}
-dsu() { doas su "$@" ;}
+doas() command doas -- "$@"
+dsu() doas su "$@"
diff --git a/modules/shell/.config/shell/xorg b/modules/shell/.config/shell/xorg
@@ -1,6 +1,6 @@
# xorg shell functions
-grab() { xclip -selection clipboard "$@" ;}
-dump() { grab -out "$@" ;}
-pdf() { zathura "$@" ;}
-x() { startx "$@" ;}
+grab() xclip -selection clipboard "$@"
+dump() grab -out "$@"
+pdf() zathura "$@"
+x() startx "$@"