opening sublime text from windows git bash

后端 未结 11 2025
有刺的猬
有刺的猬 2021-01-30 09:15

How do I open Sublime text from Git Bash in Windows? I tried adding the alias at the ~/.bashrc file but nothing worked. I was looking for something very easy but I could not fin

相关标签:
11条回答
  • 2021-01-30 10:00

    I was having some difficulty getting this to work for me as well despite all the answers listed here. I found that modifying my .bashrc file through VIM as suggested here fixed the problem for me. I'm using Git bash on windows 10.

    First I opened bash to my home directory, you can use cd~ to make sure you're in the right place.

    Then, I created my .bashrc file using:

    touch .bashrc

    Then I went to edit that file using:

    vim .bashrc
    

    press the i key to enter insert mode

    enter:

    alias subl='C:/Program\ Files/Sublime\ Text\ 3/sublime_text.exe'
    

    As noted by pretty much everyone else this will have to be the correct path to your sublime_text.exe location. A quick search of your C:\ drive for sublime_text.exe should yield this location.

    now hit esc to exit input mode

    Enter : w q enter to save and exit vim

    exit bash and reopen to apply the new settings

    Entering subl should open sublime text editor now.

    I had tried editing my .bashrc file with wordpad and sublime text itself, but for some reason editing in vim and making sure all the forward slashes and backslashes were correct as noted above worked for me.

    I had found a rogue ^M character after my file path using some of the other methods which I think might have been complicating things as well. deleting this character in vim also fixed the problem after using SawyerDoesStuff's solution.

    Thanks for letting me revive an older post and I hope this helps.

    0 讨论(0)
  • 2021-01-30 10:00

    I followed what Cristiano Ferro did, and if you would like to commit a message with Sublime Text 3, paste this in your git.
    Assuming the program is installed in Program Files:

    export GIT_EDITOR='C:\\Program\ Files\\Sublime\ Text\ 3\\sublime_text.exe'
    

    After this, you can run git commit, and it will open Sublime Text 3.

    0 讨论(0)
  • 2021-01-30 10:06
    1. Create a text file called subl (with no extension) with the following content:

      #!/bin/sh
      "C:\Program Files\Sublime Text 2\sublime_text.exe" $1 &
      
    2. Copy it into the C:\Program Files (x86)\Git\bin folder. 32bit Copy it into the C:\Program Files\Git\usr\bin folder. 64bit

    Now to open the file enter the following command on Windows Git Bash

    subl text.txt
    

    or

    subl .
    
    0 讨论(0)
  • 2021-01-30 10:10

    Create .bash_profile file under C:\Users\YourUserName\ and add the following line in the file:

    alias 'subl="/c/Program Files/Sublime Text 3/subl.exe"'
    
    0 讨论(0)
  • 2021-01-30 10:11

    Locate the folder where Sublime Text is installed. Here I'am taking an example of Sublime Text 3 which is installed in C:/Program Files. For many users it is present in C:/Program Files (x86).

    Run the following command (based upon your requirement):

    echo 'alias subl="/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"'>> ~/.bashrc
    

    Or

    echo 'alias subl="/c/Program\ Files\ \(x86\)/Sublime\ Text\ 3/sublime_text.exe"'>> ~/.bashrc
    

    Try Closing and Re-Opening Git-Bash. If it works, then you're done.
    Otherwise, read this documentation from Udacity.

    0 讨论(0)
提交回复
热议问题