vai*_*han 5 shell directory cd-command
cd ~/scripts. 这将进入我家中的脚本目录。与此类似,我想要一些“别名”类型的设置,这将允许我进入其他目录,以便
cd xxx/mywork-> 进入“mywork”目录 /home/work/software。我希望命令设置xxx为/home/work/software.
听起来设置CDPATH可以让你接近你所想的\nasking:
cd\n\n cd [-L|[-P [-e]] [-@] [directory]\n\n Change the current working directory to directory. [...] If\n the shell variable CDPATH exists, it is used as a search path:\n each directory name in CDPATH is searched for directory, with\n alternative directory names in CDPATH separated by a colon\n (\xe2\x80\x98:\xe2\x80\x99). If directory begins with a slash, CDPATH is not used.\nRun Code Online (Sandbox Code Playgroud)\n\n这样,如果您在/home/work中CDPATH,那么cd\nsoftware就会让您进入/home/work/software。
如果您需要更接近特定问题的内容,也许\n设置一个带有符号链接的目录并放置该目录\n会更好。例如,mkdir ~/.links,然后CDPATH=~/.links,\n,然后在 内部创建到\n 的~/.links符号链接。那么应该送你到那里。mywork/home/work/softwarecd mywork