Sublime Text from Command Line

前端 未结 27 2255
时光说笑
时光说笑 2020-11-27 08:37

I installed Sublime Text and wanted to know how to open rb files in it from the terminal. I saw What is the command to make Sublime Text my core editor? and I s

27条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 09:39

    I know this thread is a bit old, but I recently came up with this solution and thought I would share it...

    If you use Cygwin, you can create a bash script that will convert the unix pathnames to windows paths and pass them to sublime. Paste the following into a new file:

    #!/bin/bash
    
    /cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe `cygpath -w $@` &
    

    Save it in /usr/bin/subl (or wherever you want so long as the location is in your $PATH) and make it executable ($ chmod a+x /usr/bin/subl)

    With this script, you can use both UNIX and Windows style paths (/cygdrive/c/ or C:/) because the cygpath utility converts the / and ~ path aliases to their windows equivalents.

    Now, you can use $ subl file1.txt file2.md ~/file3.txt to open those files in sublime!

提交回复
热议问题