I'm trying to mimic the subl
command in iterm for mac computers in cygwin.
Basically, I want to be able to open a current folder from cygwin by typing subl .
I haven't found any good instructions. I know where my .bashrc file is located. I just dont know what to do to create the command subl
and make it so that the path following subl
opens with Sublime.
Can anyone help?
You'd want to make an alias and source it from bashrc.
Example
Create a file ~/.bash_aliases
with:
alias subl='/cygdrive/c/sublime.exe' #make sure this command is correct for you
Now in ~/.bashrc
do:
source ~/.bash_aliases
Log out and log back in, and subl .
should work
Assuming you want correct behaviour when doing subl ~
, a simple alias or adding Sublime Text to your PATH
will not work.
You can use the following bash function instead (put it in your .bashrc
):
function subl {
cygpath --windows $@ | sed 's/\\/\\\\/g' | tr '\n' '\0' | xargs -0 -n1 /cygdrive/c/Program\ Files/Sublime\ Text\ 3/subl.exe
}
Note that when passing paths to xargs
you need to 1) escape the backslashes, 2) use the NUL
character as argument delimiter for it to work with paths with spaces.
Edit: Use subl.exe
rather than sublime_text3.exe
so that it would detach itself from the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With