Simplified cd history implementation.
This commit is contained in:
parent
00da83a751
commit
2c873ec77a
1 changed files with 13 additions and 16 deletions
29
profile
29
profile
|
@ -117,42 +117,39 @@ fn ll {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
maxcds = 50
|
||||||
cdfile = $tmp/cdfile
|
cdfile = $tmp/cdfile
|
||||||
if(! test -d `{dirname $cdfile}) mkdir `{dirname $cdfile}
|
if(! test -d `{dirname $cdfile}) mkdir `{dirname $cdfile}
|
||||||
if(! test -r $cdfile) touch $cdfile
|
if(! test -r $cdfile) touch $cdfile
|
||||||
|
|
||||||
fn ucds {
|
tmpcdfile = `{mktemp}
|
||||||
# Update history.
|
|
||||||
ifs = '
|
|
||||||
'
|
|
||||||
cds = `{tac $cdfile | goblin uniq -U}
|
|
||||||
ifs = $oldifs
|
|
||||||
echo > $cdfile
|
|
||||||
{for(i in $cds) echo $i} | tac >> $cdfile
|
|
||||||
}
|
|
||||||
ucds
|
|
||||||
|
|
||||||
fn cd {
|
fn c {
|
||||||
# History implementation.
|
# History implementation.
|
||||||
if(builtin cd $1 && test -n $1){
|
if(builtin cd $1 && test -n $1){
|
||||||
pwd = `{pwd}
|
pwd = `{pwd}
|
||||||
echo $pwd >> $cdfile
|
cat $cdfile > $tmpcdfile
|
||||||
cds = ($pwd $cds)
|
{echo $pwd ; cat $tmpcdfile } | \
|
||||||
|
sed $maxcds^q | goblin uniq -U > $cdfile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cd {
|
||||||
|
c $*
|
||||||
|
}
|
||||||
|
|
||||||
fn - {
|
fn - {
|
||||||
# Move back in history for $1 notes.
|
# Move back in history for $1 notes.
|
||||||
num = $1
|
num = $1
|
||||||
if(~ $#* 0)
|
if(~ $#* 0)
|
||||||
num = 1
|
num = 1
|
||||||
builtin cd $cds($num)
|
backcd = `{sed -n $num^p $"cdfile}
|
||||||
|
builtin cd $backcd
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cds {
|
fn cds {
|
||||||
# Print history.
|
# Print history.
|
||||||
goblin echo -d '
|
cat $cdfile | nl >[2]/dev/null
|
||||||
' $cds | nl >[2]/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hcds {
|
fn hcds {
|
||||||
|
|
Loading…
Reference in a new issue