pushd
并且popd
在使用多个目录时很方便。有时我想推送一个目录以便以后使用,而不必立即去那里,这似乎正是要pushd -n
用于的目录
只有一个小问题-尝试这样做通常会导致产生No such file or directory
最多的消息,而在最坏的情况下会出现以下情况:
$ ls foo
Files I Want
$ pushd -n foo # I'll want to go there later
~ foo
$ cd bar # But I have other things to do first
$ # ... doing other things ...
$ # Done! Now, I want to go back to foo
$ popd # Fortunately I placed that on the dir stack earlier
~/bar/foo
$ ls
"Wait, this isn't where I wanted to end up"
是否有一种变通方法,可以将目录存储在堆栈上,而不必等到popd
以后再将其移动到该目录中,并且即使我同时移动到另一个目录,也可以执行该操作?
指定绝对路径:
pushd -n $PWD/foo
pd() { pushd -n "$(realpath "$1")"; }
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句