Guest User

Untitled

a guest
Sep 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. # Go upwards the path until the basename is equal
  2. # to your argument.
  3. function cdp {
  4. CURRENT=$(basename $PWD)
  5. until [ $CURRENT == "$*" ]; do
  6. cd ..
  7. CURRENT=$(basename $PWD)
  8. done
  9. }
  10.  
  11. _cdp() {
  12. local cur=${COMP_WORDS[COMP_CWORD]}
  13. COMPREPLY=( $(compgen -W "${PWD//\// }" $cur) )
  14. }
  15. complete -F _cdp cdp
Add Comment
Please, Sign In to add comment