Search code examples
windowsbashsublimetext3windows-subsystem-for-linux

Can't open sublime in Bash on Ubuntu on WIndows


I would like to be able to open the sublime text editor from the command line from Bash on Ubuntu on Windows, but each time I attempt to run the command 'subl' I get hit with

    -bash: C:/Program Files/Sublime Text 3/sublime_text.exe: No such file or directory

This is definitely the right directory, but I have no clue as to why this isn't working. Any tips?


Solution

    1. Run notepad as administrator.

    2. Copy & paste this two line of code below:

       #!/bin/bash 
       "$(dirname "$0")/subl.exe" "$@"
      
    3. Save it as subl.txt inside C:\Program Files\Sublime Text 3

    4. Open the folder 'C:\Program Files\Sublime Text 3'

    5. Finally right click and rename this file to subl. That means remove the .txt extension from that file.

    Now, you are ready to use subl command on gitbash or wsl linux terminal.