【问题标题】:launch sublime text 3 in terminal with zsh使用 zsh 在终端中启动 sublime text 3
【发布时间】:2014-08-10 21:22:42
【问题描述】:

我最近购买了一台新 MacBook,我正在尝试重新配置我的系统。

应用程序位于 Applications 文件夹中,名为“Sublime Text.app”

我已经通过我在网上找到的其他建议将 sublime.plugin.zsh 文件编辑为“Sublime Text 3.app”以及“Sublime Text.app”,但都没有运气:

elif  [[ $('uname') == 'Darwin' ]]; then
local _sublime_darwin_paths > /dev/null 2>&1
_sublime_darwin_paths=(
    "/usr/local/bin/subl"
    "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
    "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
    "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
    "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
    "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
    "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
)

for _sublime_path in $_sublime_darwin_paths; do
    if [[ -a $_sublime_path ]]; then
        alias subl="'$_sublime_path'"
        alias st=subl
        break
    fi
done
fi

alias stt='st .'

我还是得到了

zsh: command not found: st

我只是不知道下一步该去哪里

【问题讨论】:

  • apropos sublime 有什么有用的东西吗?

标签: command-line zsh sublimetext3 sublime-text-plugin


【解决方案1】:

我在使用 zsh 时遇到了同样的问题,但它完成了工作:

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

然后你用 Sublime 启动一个打开文件 my_file.txt:

subl ./my_file.txt

如果您只想打开 Sublime,请不要指定任何文件。我希望这会有所帮助;)

【讨论】:

    【解决方案2】:

    首先,尝试首先通过 zsh 手动(交互)启动 sublime 二进制文件。

    为此,您必须找到该二进制文件的位置。这里有两个实用的选项,选择你最喜欢的:

    1. 手动检查那些列出的二进制文件,看看它们中的哪些存在。
    2. 稍微修改你的脚本到你的echoif里面的东西:

      if [[ -a $_sublime_path ]]; then
          echo "Sublime found: $_sublime_path"
          alias subl="'$_sublime_path'"
          alias st=subl
          break
      fi
      

    找到正确的之后,在您的.zshrc 文件中创建st 别名:

    alias st="/correct/path/to/subl"
    

    如果您在第一步中没有找到任何东西,那么您的原始脚本确实不应该工作。

    【讨论】:

      【解决方案3】:
      1. 刚移到 Mac 中的 App
      2. 检查您当前的路径
      echo $PATH
      
      1. 将 Sublime App 中的符号链接添加到您的路径之一。以/usr/local/bin为例
      ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime 
      
      1. 然后返回终端并运行sublime。你应该通过终端打开 sublime

      【讨论】:

        【解决方案4】:

        为mac用户设置别名;

        使用以下命令打开~/.zshrc

        vi ~/.zshrc
        

        添加以下别名

        alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"

        运行subl . 命令应该可以正常工作。

        【讨论】:

          猜你喜欢
          • 2014-11-01
          • 1970-01-01
          • 1970-01-01
          • 2018-02-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-04-09
          • 2017-05-10
          相关资源
          最近更新 更多