Search code examples
linuxwindowsbashubuntusublimetext

Opening Sublime Text from Bash on Ubuntu on Windows


I can't seem to figure out how to open Sublime Text 2 from Bash on Ubuntu on Windows. Ultimately I would like to be able to use subl . to open the contents of the directory I am in.

On my machine, Sublime Text 2 is installed at C:\Program Files\Sublime Text 2. sublime_text.exe is located in this directory. In Bash on Ubuntu on Windows, I can access any files located on C through /mnt/c/.

I tried setting an alias: alias subl="/mnt/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe". However, upon trying subl . I get the following error:

cannot execute binary file: Exec format error

How can I set this up properly?


Solution

  • It's now possible to launch Windows executables (like Sublime Text) from the Bash on Ubuntu command line.

    You should also be able to set an alias to use it from the command line (as you were trying to do). Mine is as follows (and works fine):

    alias subl='"/mnt/c/Program Files/Sublime Text 3/subl.exe"'
    

    Note the second set of quotes: this is necessary because of the spaces in the file path. Alternatively you can escape the spaces (as you did in your example).