commit 591f5b64ae242f614b1de81b70ab42ee0003aecb
parent 9edf0926195eb70f49af057caccc0679cdfd0182
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Thu, 19 Nov 2020 11:35:02 -0800
Revise cd shell alias module
Rename the lcd, rcdi, and rcd functions to cdl, cdi, and cdr
respectively.
Replace the cdc function with the ksh directory aliases and remove the
d{set,get,do} functions, ddo could more easily and simply be
reimplemented to work with directory aliases.
Diffstat:
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/modules/aliases/.config/aliases/cd b/modules/aliases/.config/aliases/cd
@@ -1,36 +1,29 @@
# cd builtin shell aliases and functions
-# record directories visited.
+# record directories visited into the PWDLOG file.
cd() { builtin cd $@ && echo $PWD >> $PWDLOG ;}
-# filter chdir history keeping original line numbers.
-lcd() {
+# list unique entries in PWDLOG.
+cdl() {
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() {
+# cd to entry $1 of PWDLOG
+cdi() {
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() {
+# cd to the latest entry of PWDLOG which matches a regex.
+cdr() {
local d="$(egrep $@ $PWDLOG | tail -1)"
cd ${d:?No match}
}
-# chdir into curated directories
-cdc() {
- # When using a `local' variable the exit status is always 0.
- # This ocours in the dash shell aswell as ksh, so, I don't
- # know if it's actually a bug. Perhaps an old bug which became
- # a standard?
- _=`smatch -d $@ <${XDG_CONFIG_HOME:?unset}/cdc` && eval cd $_
-}
-
-# set a directory to do things in other than the wd.
-dset() { export DDIR="${1:?No directory}" ;}
-dget() { echo ${DDIR:?Directory} ;}
-ddo() { dget && (cd $DDIR && $@) ;}
+# This seems to only be in ksh(1), perhaps put these in kshrc. Note
+# that without a trailing slash a space is inserted for <tab>.
+alias -d c=$HOME/own/src/c/
+alias -d config=$HOME/own/config/
+alias -d fork=$HOME/own/src/fork/
+alias -d src=$HOME/own/src/