4

使用CDPATH简化cd命令中的路径

 3 years ago
source link: https://www.lujun9972.win/blog/2018/03/02/%E4%BD%BF%E7%94%A8cdpath%E7%AE%80%E5%8C%96cd%E5%91%BD%E4%BB%A4%E4%B8%AD%E7%9A%84%E8%B7%AF%E5%BE%84/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用CDPATH简化cd命令中的路径

bash中有一个变量 CDPATH 能指定 cd 命令的搜索路径。

它的值是一个冒号分隔的目录列表,当执行 cd 命令时,bash会从这些搜索路径中查找目标目录,如果找到了的话就进入其中并显示出进入目录的全路径。

比如,我把所有的github项目都放在了 ~/github/ 目录中,那么我可以把 CDPATH 设置成 .:~/github

这样我在任何地方都可以通过 cd 项目名 来进入 ~/github/项目名 目录了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK