Sublime Text from Command Line

前端 未结 27 1931
时光说笑
时光说笑 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:37

    I just ran the Command Prompt program as an Administrator, and executed the following command.
    Simple, but works for me.

    echo "c:\Program Files\Sublime Text 3\subl.exe" %1 > %systemroot%\system32\subl.bat
    

    Of course, you can call the bat file whatever you want. From then on, as any user you can simply use:

    subl myfile.txt
    
    0 讨论(0)
    • Set the path for sublime: My computer >> properties >> advanced setting >> environment variables >> path variable >> Add>> C:\Program Files\Sublime Text 3

    • Just go to directory where sublime is installed and rename sublime_text to sublime.

    Open command prompt and type sublime.

    0 讨论(0)
  • 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!

    0 讨论(0)
  • 2020-11-27 09:40

    You can simply install Notepad Replacer http://www.binaryfortress.com/NotepadReplacer/ what it will do is make sublime your default notepad in Windows and then you can simply use the commands that you generally use to open inbuilt notepad in windows. for example

    `//to open test.txt, just type
    notepad test.txt
    //to open sublime, Type
    notepad`
    
    0 讨论(0)
  • 2020-11-27 09:41

    Another idea would be to include C:\Program Files\Sublime Text 2\ in your PATH, and then run an administrator command prompt:

    cd "C:\Program Files\Sublime Text 2\"
    mklink sublime.exe sublime_text.exe
    

    That will make a symbolic link with the new name. And now you can use it freely:

    sublime hello.txt
    

    Update: After having a chance to use this trick and update Sublime Text 2, I'm happy to say that updating to a new build doesn't affect the symbolic link.

    0 讨论(0)
  • 2020-11-27 09:42

    Add the installation folder to windows path and you will be able to open Sublime by typing the name of the executable file, which is by default "subl".

    To include the Sublime installation folder in windows path,

    1. Open command prompt and type sysdm.cpl
    2. In Advanced tab, select Environment variables
    3. Under system variables, select variable named "Path" and click Edit.
    4. Add "C:\Program Files\Sublime Text 3;" to the end of the existing string.
    5. Save the changes and restart command prompt.
    0 讨论(0)
提交回复
热议问题