opening sublime text from windows git bash

后端 未结 11 2040
有刺的猬
有刺的猬 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 09:46

    I had the same issue launching Sublime Text 3 form Git Bash.

    1. I ran the following command (my OS was windows 7 and Sublime Text 3 was located in the "C:\Program Files\Sublime Text 3" directory) :

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

    2. Close Git Bash and Open it again.

    3. Type subl
    0 讨论(0)
  • 2021-01-30 09:50

    I am going to answer my own question. First, I created a .bash_profile file under /Users/username directory. I have copied all my git aliases here. To access sublime text I added this alias:

    alias subl="/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"
    

    I think the spaces after the backward slashes are important for formatting. If this doesn't work you will have to look where your sublime_text.exe file situated at and put the path after formatting as above. Now in the git bash command line just type

    subl . 
    

    to open the current directory in Sublime Text or the name of the file as

    subl readme.md
    

    to open it in Sublime Text. I also added other useful aliases in the .bash_profile file like:

    alias gc="git commit -m"
    alias ga="git add ."
    alias gl="git log"
    alias gs="git status"
    

    So in your git bash command prompt you can simply type

    gs ##for git status
    gl ##for git log, etc
    

    I hope this will help someone.

    0 讨论(0)
  • 2021-01-30 09:54

    I'm pretty new to this stuff and to git and sublime text. I'm taking the Udacity course on git right now, and was unable to get git bash to open sublime text.

    I kept getting bash: subl: C:/Program command not found

    or something like that

    I found my problem ended up being I had my slashes going the incorrect way, and I found if you have spaces in your file path, you have to add a slash everytime you have a space and it will fix the problem.

    I ended up typing

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

    then subl

    and sublime text was opened.

    My original file path was-

    C:\Program Files\Sublime Text 3

    so make sure you have your slashes going the correct way, and if you have spaces in your file path, to add the necessary slash after a word.

    I'm on windows 10 using sublime text 3 and git bash

    Hopefully this saves someone else a lot of time.

    0 讨论(0)
  • 2021-01-30 09:54

    One of the problems I had was that I had to use backslashes \ in the path of the directory instead of normal slashes /, like the everyone here is using. Then I had to escape backslashes using double backslash \\. So, in my case I wrote the path like this:

    alias subl='C:\\Program\ Files\\Sublime\ Text\ 3\\sublime_text.exe'
    
    0 讨论(0)
  • 2021-01-30 09:55

    A Better Solution:

    The updated version of sublime text 3(Build 3065) brings this feature as "subl.exe" which was "subl" in mac os.

    How to use:

    step 1: Update sublime text (in sublimetext --> Help -> Check for Updates)
    step 2: Just navigate to your project folder through bash and type subl.exe which should open the folder in sublime text. (if you encounter "subl.exe" command not found, just add sublime's path eg: "C:\Program Files\Sublime Text 3" to your system path - Here's how to add path to environment variables)

    0 讨论(0)
  • 2021-01-30 09:59

    I added this to my C:\Users\username\.bashrc file:

    export PATH="$PATH:/c/Program Files/Sublime Text 3"
    

    Save the file. Then in Git Bash, type

    which subl
    

    to prove it works.

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