简体   繁体   English

如何从OSX中的符号链接上移一个级别

[英]How to move up a level from an symbolic link in OSX

I've created a symbolic link to my WordPress theme root from my system root - so in / I have 我已经从系统根目录创建了指向WordPress主题根目录的符号链接-所以在/

mytheme -> /Applications/MAMP/htdocs-wordpress/wp-content/themes/mytheme

I use this all the time to quickly get to my theme root in Terminal. 我一直都用这个来快速进入终端的主题根。 But I very often also want to navigate from there up to a higher directory in the WordPress hierarchy, like wp-content . 但是我经常也想从那里导航到WordPress层次结构中的更高目录,例如wp-content When I run cd .. Terminal takes me back up to / . 当我运行cd .. Terminal时,我将回到/ Is there any easy way to jump up the file hierarchy instead of to the "parent" of the symbolic link? 有什么简单的方法可以跳到文件层次结构,而不是跳到符号链接的“父级”? Or any way to get an alias of my theme root that will allow this? 或以其他任何方式获取主题根的别名都可以吗?

I would go with an alias, it makes things easier. 我会用一个别名,它使事情变得更容易。 Put this into your $HOME/.bashrc or $HOME/.bash_profile file: 将其放入$HOME/.bashrc$HOME/.bash_profile文件中:

alias mytheme="cd /Applications/MAMP/htdocs-wordpress/wp-content/themes/mytheme"

After that, either source it in your current terminal source $HOME/.bashrc or open a new Terminal window. 之后,可以在当前终端source $HOME/.bashrc或者打开一个新的终端窗口。 This is available for any Terminal window you open and you can navigate easily from there. 此功能可用于您打开的任何“终端”窗口,并且可以从那里轻松导航。 Another advantage is, that you don't have this symlink in your / directory. 另一个优点是,您的/目录中没有此符号链接。

Jumping into the directory of your theme is done by calling the name of the alias: 通过调用别名的名称可以跳入主题的目录:

user@machine> mytheme

And if you want to navigate one directory back, just do it the usual way: 如果要向后浏览一个目录,只需按照通常的方式进行即可:

user@machine> cd ..
user@machine> pwd
/Applications/MAMP/htdocs-wordpress/wp-content/themes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM