commit 07aeb7706d11ce80888de9c0d5dd8ae126de0516
parent 59e10667606707704c24ef77aa1796340c68a7b4
Author: Jacob R. Edwards <n/a>
Date: Fri, 19 Nov 2021 15:20:06 -0800
Fix directory logging function
UNIX rcmain redefines the cd function, so unless you reload your
profile for every interactive instance of rc(1), a costom cd function
will be overwritten. This solution simply renames the cd with logging
to `cdl' and comes with the additional benifit of being able to be
selective in what directories are logged.
Diffstat:
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/local/rc/lib/profile b/local/rc/lib/profile
@@ -34,18 +34,13 @@ MANPREFIX = /usr/local/man
PREFIX = /usr/local
# Working Directory Functions
-fn cd {
- if (builtin cd $*) {
- if (flag i) {
- pwd >> $dirlog
- awd
- }
- status = ''
- }
+fn cdl {
+ if (cd $* && flag i)
+ pwd >> $dirlog
}
-fn cdr { cd ''^`{ egrep $* < $dirlog | tail -1 } }
-fn cds { cd ''^`{ pwd | sed s.$1.$2.g } }
-fn cdp { cd ''^`{ fgrep -vx `{ pwd } < $dirlog | tail -1 } }
+fn cdr { cdl ''^`{ egrep $* < $dirlog | tail -1 } }
+fn cds { cdl ''^`{ pwd | sed s.$1.$2.g } }
+fn cdp { cdl ''^`{ fgrep -vx `{ pwd } < $dirlog | tail -1 } }
# OpenBSD Package Management
if (~ `{ uname } OpenBSD) {