pushd.elv 394 B

1234567891011121314151617181920
  1. var dir-stack = [$pwd]
  2. fn on-chdir {|_dir|
  3. var last = $dir-stack[0]
  4. if (not-eq $pwd $last) {
  5. set dir-stack = [ $pwd $@dir-stack ]
  6. }
  7. }
  8. edit:add-var popd~ {||
  9. if (> (count $dir-stack) 1) {
  10. set dir-stack = $dir-stack[1..]
  11. var last = $dir-stack[0]
  12. cd $last
  13. } else {
  14. edit:notify "Reached bottom of directory stack"
  15. }
  16. }
  17. set after-chdir = [$on-chdir~ $@after-chdir]