Guest User

Untitled

a guest
Jun 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. cd () {
  2.  
  3. emulate -LR zsh
  4.  
  5. if [[ $# -ge 3 ]]; then
  6. echo cd: too many arguments >&2
  7. return 1
  8. elif [[ $# -eq 2 ]]; then
  9. ## builtin cd $1 $2
  10. local newdir=${(S)PWD//$1/$2}
  11. echo $newdir
  12. builtin cd $newdir
  13. elif [[ $# -eq 1 ]]; then
  14. if [[ ! -d $1 && -d $1:h ]]; then
  15. echo $1:h
  16. builtin cd $1:h
  17. else
  18. builtin cd $1
  19. fi
  20. else
  21. builtin cd
  22. fi
  23. }
Add Comment
Please, Sign In to add comment