dirspersist.zsh 527 B

12345678910111213141516171819202122
  1. #!/bin/zsh
  2. #
  3. # Make the dirstack more persistant
  4. #
  5. # Run dirpersiststore in ~/.zlogout
  6. dirpersiststore () {
  7. dirs -p | tail -r | perl -ne 'chomp;s/([& ])/\\$1/g ;print "if [ -d $_ ]; then pushd -q $_; fi\n"' > ~/.zdirstore
  8. }
  9. dirpersistrestore () {
  10. if [ -f ~/.zdirstore ]; then
  11. source ~/.zdirstore
  12. fi
  13. }
  14. DIRSTACKSIZE=10
  15. setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
  16. dirpersistrestore
  17. # Make popd changes permanent without having to wait for logout
  18. alias popd="popd;dirpersiststore"