opening sublime text from windows git bash

后端 未结 11 2044
有刺的猬
有刺的猬 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: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.

提交回复
热议问题