Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create a persistent directory stack in zsh' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a persistent directory stack in zsh
Authored by: ra5ul on May 28, '07 12:11:57AM

nice ideas. i've come up with another working solution:

in ~/dirstack:
dirstack()

in ~/.zlogout:
cd
tempstack=()
for ((i=1; i<=$#dirstack; i++)); do tempstack[i]=\"$dirstack[i]\"; done
source $ZDOTDIR/dirstack
for ((i=1; i<=$#tempstack; i++)); do dirstack[i]=$tempstack[i]; done
echo "dirstack=($dirstack)" >| $ZDOTDIR/dirstack

in ~/.zshrc:
source $ZDOTDIR/dirstack
setopt autopushd pushdsilent pushdignoredups

this solves the three problems of:
a. repeated ~ entries in the stack
b. directories with spaces in them
c. erasing the stack on a quick login - logout



[ Reply to This | # ]
Create a persistent directory stack in zsh
Authored by: ra5ul on Jun 04, '07 04:36:37PM
it's probably better to put the source $ZDOTDIR/dirstack line in ~/.zprofile. that way you can still source ~/.zshrc during your session.

[ Reply to This | # ]