bash下快速cd到上层路径

忘了是在commandlinefu还是哪里看到的,zsh下也适用,我在.zshrc里增加了这个函数。

[bash toolbar=”false” light=”true”]
$ which upto
upto () {
cd “${PWD/\/$@\/*//$@}”
}
[/bash]

[bash toolbar=”false” light=”true”]
$ pwd
/a/very/long/cumbersome/directory
$ upto very
$ pwd
/a/very
[/bash]

Leave a Reply

Your email address will not be published. Required fields are marked *