Implemented cd history also for shell shit.

This commit is contained in:
Andrey Parhomenko 2022-11-08 23:27:59 +05:00
parent 048d886a14
commit 960c63576a
6 changed files with 59 additions and 17 deletions

2
.gitignore vendored
View file

@ -6,4 +6,6 @@ rcmain
user-dirs.dirs
dot/file/vim/pack
dot/file/vim/autoload
cds
cmds

View file

@ -1,10 +1,5 @@
. $HOME/.profile
q(){
echo $SHLVL - 1 | bc
exit
}
export PS1="% "
. $HOME/.shrc
test -r "$LOGIN" && . "$LOGIN"
test -r "$SETENV" && . "$SETENV" && setenv bash

View file

@ -6,7 +6,7 @@ export_loop(){
# Standard "export" command takes arguments
# from variables from the start, but I want to
# use other variables in definition for next of them.
while [ ! -z "$1" ] ; do
while test ! -z "$1" ; do
# Doing until we have arguments.
value="$(eval echo $2)"
name="$1"
@ -15,14 +15,10 @@ export_loop(){
done
}
q(){
exit
}
# Standard variables.
export_loop \
ENV '$HOME/.shrc' \
PS1 '"; "' \
PROMPT '"; "' \
SUDO_PROMPT '"#"' \
EDITOR 'vi' \
VISUAL 'vi' \
@ -30,6 +26,9 @@ export_loop \
PAGER 'less' \
MANPAGER '$PAGER' \
\
CDHIST '$HOME/lib/cds' \
CDHISTMAX '50' \
\
CMDHIST '$HOME/lib/cmds' \
CMDHISTMAX '100' \
PROFILE '$HOME/.profile' \

View file

@ -1,10 +1,56 @@
#!/bin/sh
. $HOME/.profile
q(){
echo $SHLVL - 1 | bc
exit
}
tmpcdfile=`mktemp`
c() {
oldpwd=`pwd`
if command cd $@ && test -n $1 ; then
cat $CDHIST > $tmpcdfile
{ pwd ; goblin cat $tmpcdfile ; } | \
sed $CDHISTMAX'q' | \
goblin uniq -U > $CDHIST
fi
pwd
}
l() {
ls $@
}
la() {
ls -al $@
}
cds() {
acds | sed 10q | goblin quote | nl
}
acds() {
cat $CDHIST
}
bcd() {
num=$1
if test "$1" = "" ; then
num=1
fi
backcd=`sed -n $num'p' "$CDHIST"`
echo $backcd
command cd "$backcd"
}
PS1=$PROMPT
test -r "$LOGIN" && . "$LOGIN"
PS1="% "
test -r "$SETENV" && . "$SETENV" && setenv sh

View file

@ -1,5 +1,6 @@
#!/bin/sh
. $HOME/.profile
. $HOME/.shrc
#autoload -Uz compinit promptinit
#compinit
#promptinit
@ -31,6 +32,5 @@ setopt noglobdots
setopt noshwordsplit
test -r "$LOGIN" && . "$LOGIN"
export PROMPT="%# "
q(){echo $SHLVL - 1 | bc ; exit}
test -r "$SETENV" && . "$SETENV" && setenv zsh

View file

@ -130,7 +130,7 @@ fn cd {
if(builtin cd $1 && test -n $1){
cat $cdfile > $tmpcdfile
{pwd ; cat $tmpcdfile } | \
sed $maxcds^q | goblin uniq -U > $cdfile
sed $CDHISTMAX^q | goblin uniq -U > $cdfile
}
}