From 1dfbca545f5027477ddded21052457483672b0ce Mon Sep 17 00:00:00 2001 From: k1574 Date: Mon, 21 Jun 2021 23:47:07 +0500 Subject: [PATCH] profile: upgraded cd history implementation. --- profile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/profile b/profile index 64fcb71..e6d2cf9 100644 --- a/profile +++ b/profile @@ -1,5 +1,6 @@ # k1574's rc configuration file. +oldifs = $ifs prompt = '% ' # The simplest possible prompt. fn % { switch($#*){ @@ -119,11 +120,26 @@ fn ll { goblin ls $* | finfo } -cds = (`{pwd}) + +cdfile = $tmp/cdfile +if(! test -r $cdfile) touch $cdfile + +fn ucds { + # Update history. +ifs = ' +' + cds = `{tac $cdfile | goblin uniq -U} +ifs = $oldifs + echo > $cdfile + {for(i in $cds) echo $i} | tac >> $cdfile +} +ucds + fn cd { # History implementation. if(builtin cd $1 && test -n $1){ pwd = `{pwd} + echo $pwd >> $cdfile cds = ($pwd $cds) } } @@ -140,11 +156,6 @@ fn cds { {for(i in $cds) echo $i } | nl } -fn ucds { - # Let be in history just unique notes. - cds = `{ {for(i in $cds) echo $i} | goblin uniq -U} -} - fn p { plumb $* }