【发布时间】:2018-04-20 15:27:48
【问题描述】:
我正在尝试在 Mac 中的 bash_profile 中添加别名。我试图创建别名的文件的实际路径是
amar@admin:~/Library/Application Support/com.bohemiancoding.sketch3/Plugins
$pwd
/Users/amar/Library/Application Support/com.bohemiancoding.sketch3/Plugins
我已经尝试了 2 个选项
选项#1
export sketch="/Users/amar/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins"
这有类似的错误
amar@admin:~$ echo $sketch
/Users/amar/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins
amar@admin:~$ cd $sketch
-bash: cd: /Users/amar/Library/Application\: No such file or directory
选项#2
export sketch="/Users/amar/Library/Application Support/com.bohemiancoding.sketch3/Plugins"
这显示了类似的错误
amar@admin:~$ echo $sketch
/Users/amar/Library/Application Support/com.bohemiancoding.sketch3/Plugins
amar@admin:~$ cd $sketch
-bash: cd: /Users/amar/Library/Application: No such file or directory
此文件名附近有问题Application Support
【问题讨论】:
-
有一个简洁的选项
shopt -s cdable_vars,它允许将目录路径保存在变量中,例如export sketch='/path/with space/',然后您可以在文件系统中的任何位置使用cd sketch。见the manual 和this Q&A。
标签: bash