在终端中安装 Sublime Text 的命令行工具“subl",权限被拒绝? [英] Installing Sublime Text's command line tool 'subl' in terminal, permission denied?

查看:125
本文介绍了在终端中安装 Sublime Text 的命令行工具“subl",权限被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从终端使用 Sublime Text,例如通过键入 subl.

I'm tryng to use Sublime Text from the terminal, for example by typing subl.

我正在按照 Sublime Text 网站上的步骤操作:

I'm following the steps from Sublime Text's website:

设置

第一个任务是创建一个指向 subl 的符号链接.假设您已将 Sublime Text 2 放在 Applications 文件夹中,并且您的路径中有一个 ~/bin 目录,您可以运行:

The first task is to make a symlink to subl. Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

我不断收到权限被拒绝:~/bin/subl:权限被拒绝

我一直在寻找类似的问题,但找不到适用的问题.有人能指出我正确的方向吗?

I have been searching around for a similar problem but can't find one that's applicable. Can someone point me to the right direction?

推荐答案

我假设您没有 bin 目录.您可以执行以下操作:

I am assuming that you don't have the bin directory. You can do the following:

cd 
mkdir bin
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

ln -s 将在您的 bin 目录中创建 subl 文件的别名,您将能够运行该命令.

ln -s will create a alias of the subl file in your bin directory and you will be able to run the command.

如果这仍然不起作用,您将不得不编辑您的 .bash_profile.您可以通过以下命令来完成:(注意:为此,您需要已经完成上述步骤.)

If this still doesn't work you will have to edit your .bash_profile. You can do it by following commands: (NOTE: For this to work you need to have done the above steps already.)

  1. 打开您的 .bash_profile:

  1. Open your .bash_profile:

cd                  // this will get you back to home directory
vim .bash_profile   // this will open your .bash_profile file

  • 编辑 .bash_profile:按 I 进入插入"模式并添加以下内容:

  • Edit .bash_profile: press I to get into "insert" mode and add following:

    export PATH=$PATH:~/bin
    

  • 保存并退出.按 Esc 进入命令模式:

  • Save and exit. Press Esc to get into command mode:

    :wq   // saves and close file
    exit  // exits terminal
    

  • 重新打开终端:

  • Reopen the terminal:

    subl --help
    

  • 这应该会显示 Sublime Text 的帮助.

    That should bring up the help for Sublime Text.

    这篇关于在终端中安装 Sublime Text 的命令行工具“subl",权限被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆