Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export WDHIST=( $(pwd) )
  4.  
  5. function cd {
  6. builtin cd $*
  7. if [ $? -eq 0 ]; then
  8. WDHIST[${#WDHIST[*]}]=$(pwd)
  9. fi
  10. }
  11.  
  12. function cdhist {
  13. local len=${#WDHIST[*]}
  14. for (( i = 0; i < $len; i++ )); do
  15. printf " %4d %s\n" $i ${WDHIST[$i]}
  16. done
  17. }
  18.  
  19. function cd_ {
  20. if [ $# -ne 1 ]; then
  21. echo "Usage: cd_ <#> (# from cdhist)"
  22. return
  23. fi
  24.  
  25. builtin cd ${WDHIST[$1]}
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement