I just recently started using Ubuntu on WSL, and I love it. It’s lightning-fast, easy to use, and easy to customize – once you get past the initial learning curve, of course. After getting up and running, I wanted to keep being able to use the shell scripts generated by the JetBrains Toolbox app. They’re so convenient to have, and I like to keep my CLI as my point of entry for everything (well, almost everything) I do. I went on a quick Google quest for how to get JetBrains Shell Scripts in WSL and got everything up and running without much trouble. Here’s what I found:

Running the script in WSL turned out to be easy enough. With the interoperability between WSL and Windows, we can execute cmd.exe right inside of bash. The command is simple:

cmd.exe /c webstorm.cmd
(I will use Webstorm in this example, but of course, this works for all JetBrains Shell Scripts in WSL)

Awesome, except, that’s way too cumbersome to write every time! Ubuntu makes this very easy to address. We’re one small shell script away from being able to simply enter webstorm . and have the IDE open to the current working directory. Start by creating a new file in the /usr/local/bin directory, and opening it in vi:

vi /usr/local/bin/webstorm

(vi cheatsheet here. I don’t judge 🙂 )

And here’s our script:

#!/bin/bash

# Starting point - just the name of the JetBrains 
# generated script to be executed
execString="webstorm.cmd"

# Loop through passed arguments, if any, and append
# to the end of the execString
for var in $@
do
	execString+=" $var"
done

# Finally, pass the execString with arguments to cmd.exe
cmd.exe /c $execString

That’s it! Save and exit vi (:wq or :x), and give it a test run. Head to any directory, type webstorm ., and the IDE should open, with the passed in directory as the active project!

Do you have any favorite shell scripts that you simply must have? Let me know – I’d love to hear about them!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply