Last active
November 15, 2016 08:28
-
-
Save wataken44/5fe3a04529667ca0ccb7c5ed75956acc to your computer and use it in GitHub Desktop.
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
function upto() { | |
if [ $# -eq 0 ]; then | |
cd ~ | |
else | |
ptn=$(echo -n $1 | sed -e 's/\/$//g;s/\//\\\//g;') | |
exp='s/\(.*'$ptn'[^/]*\/\).*/\1/g' | |
dir=$(pwd)"/" | |
cd $(echo $dir | sed -e "$exp") | |
fi | |
} | |
function upto_completion() { | |
COMPREPLY=( $(compgen -W "$(pwd|sed -e 's/\// /g')" ${COMP_WORDS[COMP_CWORD]} ) ) | |
} | |
complete -F upto_completion upto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment