Context Menu entries to open WSL shell

Delete the context menu item you added (you can't change its type once created).

Then add a new context menu item, and make sure you set the Type drop-down to Run and Opus Function (not supported in Explorer).

That is required to run Opus commands from context menus menus (but also means they won't appear outside of Opus, of course).

Thanks! Works great and is super useful! :slight_smile:

I am running both SUSE and Ubuntu. Is there a way to tell Directory Opus which one to use?

Thanks.

We might add a setting to let you override it, but at the moment we just send all commands to WSL and it then forwards them on to the default distro.

"You can change the default distro by using the “wslconfig” tool."

https://devblogs.microsoft.com/commandline/a-guide-to-invoking-wsl/

I have it working now, thanks Leo! I thought that I might add the following info to help others solve a problem I had upon setting my WSL shell. I had configured my Ubuntu window to match the colors and fonts from Ubuntu. However when I launched the window from my content menu under Opus, it came using the stock black and green. I found a chart to convert the existing color palate from the DOS standard to the Ubuntu color set. This change can be made to only your WSL windows by using "Properties", and all command prompt type windows using "Default".

First, make sure to select slot 3 for the Screen Background and the Popup Text and slot 16 for the Screen Text and Popup Background. Then a bit of manual input is required to enter the following RGB values for each slot.

Slot 1: Red: 78, Green: 154, Blue: 6
Slot 2: Red: 52, Green: 101, Blue: 164
Slot 3: Red: 48, Green: 10, Blue: 36
Slot 4: Red: 6, Green: 152, Blue: 154
Slot 5: Red: 204, Green: 0, Blue: 0
Slot 6: Red: 117, Green: 80, Blue: 123
Slot 7: Red: 196, Green: 160, Blue: 0
Slot 8: Red: 211, Green: 215, Blue: 207
Slot 9: Red: 85, Green: 87, Blue: 83
Slot 10: Red: 114, Green: 159, Blue: 207
Slot 11: Red: 138, Green: 226, Blue: 52
Slot 12: Red: 52, Green: 226, Blue: 226
Slot 13: Red: 239, Green: 41, Blue: 41
Slot 14: Red: 173, Green: 127, Blue: 168
Slot 15: Red: 252, Green: 233, Blue: 79
Slot 16: Red: 238, Green: 238, Blue: 238

For more details, this information was originally posted here: https://medium.com/@jgarijogarde/make-bash-on-ubuntu-on-windows-10-look-like-the-ubuntu-terminal-f7566008c5c2 by James Garijo-Garde.

Ok so I have adapted this to open Windows Terminal instead (which is a huge improvement in general over previous options or CLI on Windows...). They key is to use the -d switch to specify the folder to open to.

(Note, this is opening Ubuntu for me, which I have set to be the default in the Windows Terminal settings).

I have the general context menu working fine with:

C:\Users\YOU\AppData\Local\Microsoft\WindowsApps\wt.exe -d {sourcepath} 

However, I can't quite get the right click on folders to work - have tried the above, and

C:\Users\YOU\AppData\Local\Microsoft\WindowsApps\wt.exe -d {file} 

Though it seems this should probably be added in a more offical way to the CLI options in Opus itself (https://www.gpsoft.com.au/help/opus12/index.html#!Documents/CLI_Command.htm)

Leo - any tips on getting that folder right click to work?

{file} will only give the name of the right-clicked file or folder, but you want the full path.

Use {filepath} instead, or {filepath|noterm} which avoids the extra \ on the end of folder paths which confuses some things.

Awesome - {filepath} works fine. Not sure how I missed that in looking at the arguments....sorry!

1 Like

Actually in some cases {filepath|noterm} seems required, so that's the way to go.

I got error:

--startingDirectory: 1 required TEXT missing
Run with --help for more information.

I used following function.

C:\Users<My user name>\AppData\Local\Microsoft\WindowsApps\wt.exe -d {filepath|noterm}

I went to Settings > Customize Toolbars > Context Menu > Lister Context, insert new Button. The function is the above line.

Thanks!

You can use CLI DOSPROMPT=wsl if you want to open a WSL prompt in the current folder.

In the code you were using, {filepath|noterm} would insert the path of the selected file or folder (the noterm part means it won't add a backslash at the end if it's a folder). That doesn't usually make sense in the Lister Context menu, since right-clicking the background normally deselects everything.

You could use {sourcepath} instead there if you want to run wt.exe and give it the current path.

Thanks Leo!

I would like to open it with Windows Terminal and my default profile is Ubuntu. I followed our suggestion. Now the command is

C:\Users<My user name>\AppData\Local\Microsoft\WindowsApps\wt.exe -d {sourcepath}

When I right click an empty space inside a folder and choose the entry I created, it did opened Ubuntu in Windows terminal, but it does not in the desired folder. It is in HOME directory.

Could this be caused by the {sourcepath} is DOS format path?

Try {sourcepath|noterm} since noterm seemed to be needed with the earlier examples. (I didn't think of that before, sorry!)

Same. It still opened in HOME directory.

If you run wt.exe -d "C:\Program Files" from a Command Prompt, does it open in the specified Program Files folder?

It is still opened $HOME directory. If I pass Linux path as following,

wt.exe -d /mnt/c/QA (This is my c:\QA folder under Windows)

Windows terminal just crashes with following error.

[error 0x8007010b when launching `wsl.exe -d Ubuntu']

But if I changed the default profile to "cmd" in Windows terminal, then it opened in the correct directory.

Seems like a wt.exe issue at this point, or maybe not the right syntax (but I don't know wt.exe to tell you the correct syntax if that's the case).

This works for me.

I guess your default profile is "cmd" or "Windows PowerShell". If you installed Ubuntu or other Linux distro, and set it as default profile, will this still work for you?

I set the default to Ubuntu, and yes it still works (running wt.exe -d "C:\Program Files" from Start -> Run opens WT with the CD set to /mnt/c/Program Files).