Created
April 12, 2012 13:57
-
-
Save marcinwyszynski/2367469 to your computer and use it in GitHub Desktop.
Shell function to skip to a parent directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go upwards the path until the basename is equal | |
# to your argument. | |
function cdp { | |
CURRENT=$(basename $PWD) | |
until [ $CURRENT == "$*" ]; do | |
cd .. | |
CURRENT=$(basename $PWD) | |
done | |
} | |
_cdp() { | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=( $(compgen -W "${PWD//\// }" $cur) ) | |
} | |
complete -F _cdp cdp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment