Guest User

Untitled

a guest
Jul 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. function cdb() {
  2. if [ -d "$PWD/$1" ]; then
  3. command cd "$1"
  4. return
  5. fi
  6.  
  7. if [ "$1" = '-' ]; then
  8. command cd -
  9. return
  10. fi
  11.  
  12. START_DIR="$PWD"
  13.  
  14. while [[ $PWD != '/' && $PWD != **"/$1" ]]; do
  15. command cd ..;
  16. done
  17.  
  18. if [ "$PWD" = '/' ]; then
  19. command cd "$START_DIR"
  20. command cd "$1"
  21. fi
  22. }
  23.  
  24. alias cd=cdb
Add Comment
Please, Sign In to add comment