-
-
Save hitode909/607290 to your computer and use it in GitHub Desktop.
上に行くcd
This file contains hidden or 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
#compdef up | |
segments=$(perl -le '$p=$ENV{PWD};$p =~ tr/\// /; print $p') | |
_arguments "1:first:($segments)" |
This file contains hidden or 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 up() | |
{ | |
to=$(perl -le '$p=$ENV{PWD}."/";$d="/".$ARGV[0]."/";$r=rindex($p,$d);$r>=0 && print substr($p, 0, $r+length($d))' $1) | |
if [ "$to" = "" ]; then | |
echo "no such file or directory: $1" 1>&2 | |
return 1 | |
fi | |
cd $to | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment