OS X Sublime Text3 to use zsh shell

2019-08-02 08:03发布

I want to build a python file I get the following error:

/bin/bash: python: command not found

The reason is that I'm using zsh instead of bash. So how to let Sublime to look at /bin/zsh?

3条回答
Animai°情兽
2楼-- · 2019-08-02 08:32

This is indicative of your path not being correct and not what shell you normally use. In the case of OSX the path for GUI applications is set via different means than that of terminal programs (which you know based on your comments in your question above).

Regardless, to answer your question (and for future reference) the exec command in Sublime, which is used to execute tasks including build systems, is what is specifying that things be executed via bash.

Using PackageResourceViewer you can extract the file exec.py from the Default package and modify it's use of "/bin/bash" to "/bin/zsh" (or whatever other shell you want) as you see fit.

[EDIT]

While the above will work, when you override a file from a package like this, your override persists forever. That is to say, if a newer version of Sublime includes a different version of exec.py with bug fixes or newer features, you won't see them because you've overridden the file.

So something to keep in mind is that if you take this route the onus is on you to always keep your override up to date with the current released version. Bug reports of exec problems are probably also going to fall on deaf ears or cause tears when it's discovered you've overridden the file.

查看更多
时光不老,我们不散
3楼-- · 2019-08-02 08:36

If all that you need is to open zsh shell from sublime rather than the default bash shell, there is a simpler way to do this. On OSX/Mac, open perferences->package settings->terminal view->pallete commands. Change /bin/bash to /bin/zsh like below.

{ "args" : {"title": "Terminal (bash)", "cmd": "/bin/zsh -l"}, },

This works for sublime text 3. Have not tested for lower versions.

Hope this helps!! Cheers!!

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-08-02 08:40

It work for me fine on Mojave.

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin
查看更多
登录 后发表回答