commit 4f8e617d62f8cc758075c35c7bfd7c7d055f369a
parent 79d61b5645748358c4a351d93cf742d3f56dea0a
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Fri, 25 Sep 2020 20:16:14 -0700
Add and rename aliases
rename cds to lcd.
add rcd alias to repeat the last chdir matching a regular expression.
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/aliases/.config/aliases b/aliases/.config/aliases
@@ -112,7 +112,7 @@ fed() { (builtin cd $FEED_DIR && feed $@) ;}
cd() { builtin cd $@ && echo $PWD >> $PWDLOG ;}
# filter chdir history keeping original line numbers.
-cds() {
+lcd() {
awk -vhome="^$HOME" '$0 != last && $0 != ENVIRON["HOME"] {last=$0; \
sub(home, "~", $0); printf "%d\t%s\n", FNR, $0 }' $PWDLOG
}
@@ -122,3 +122,9 @@ rcd() {
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}
+}