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 user-dirs.dirs
dot/file/vim/pack dot/file/vim/pack
dot/file/vim/autoload dot/file/vim/autoload
cds
cmds

View file

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

View file

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

View file

@ -1,10 +1,56 @@
#!/bin/sh #!/bin/sh
. $HOME/.profile
q(){ q(){
echo $SHLVL - 1 | bc echo $SHLVL - 1 | bc
exit 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" test -r "$LOGIN" && . "$LOGIN"
PS1="% "
test -r "$SETENV" && . "$SETENV" && setenv sh test -r "$SETENV" && . "$SETENV" && setenv sh

View file

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

View file

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