I have a hunch that this may not be possible, but perhaps I should ask the wizards in here: I normally use ConEmu to run Linux on Windows 10 (via WSL) in order to be able to use a "real" console. This works fine, and I can very simply add a toolbar button to DOpus that starts a WSL console for me.
However, now I would like to replicate the "Launch WSL shell in the current source folder" functionality which uses a special command ("CLI DOSPROMPT=wsl") to do its magic. This one works fine, too, except it launches a Windows console, which doesn't properly support quite a bit of the functionality that my Linux shell provides.
So, after this long preamble, my question is the following: Is it possible to create a command that launches ConEmu and then somehow pipes a "cd {sourcepath}" into the session opened in ConEmu? The two issues here are to (a) inject anything whatsoever into the ConEmu session, and (b) translate the source path from "Windows coordinates" to "WSL coordinates" (where, say, "C:\somefolder\someotherfolder" becomes "/mnt/c/somefolder/someotherfolder").
I realize that part of the issue is dealing with ConEmu, and my problem is that I find its documentation somewhat inscrutable (read "I just don't get it"…); I did try some command line/startup parameters for ConEmu to try and do what I want, but I got nowhere. There is a "-Dir" parameter that sounds like it should accomplish what I want, but this doesn't seem to work; if I use DOS/Windows path syntax the command runs fine but has no effect, if I use Unix syntax I get an error message.
So my faint hope is that someone in here knows both ConEmu and DOpus well enough to either find a solution, or else tell me "forget it".
No, none of that works; things are a lot more complex with using ConEmu to run a bash session, since that involves starting a "WSL Bridge" so that bash can properly communicate with the console.
However, I have made some progress as follows: My shell is ultimately started internally by ConEmu using the following command (in ConEmu's task settings):
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -C~ -cur_console:pm:/mnt -new_console:P:"xterm-bash"
This will start the bash session in my home folder (~). If I replace the "~" by a path that is known to WSL, the session will start there. So this means I would need to accomplish two things:
I need to define a DOS variable holding the path of the folder that I want my bash session to start in. If I call this, say %StartFolder%, I could replace the above "-C~" with "-C%StartFolder%" and things should work. So task one is to set this variable such that it is defined when I call ConEmu.
As far as the content of that variable %StartFolder%, I have the additional complication of having to translate the DOS/Windows folder name to "Unix syntax", where, say, "F:\branch1\branch2" would need to turn into "/mnt/f/branch1/branch2"
Alright, so I think I can accomplish almost all I need by starting ConEmu using a batch script that takes {sourcefolder} as its first argument, and then calls something like
wsl wslpath -a %StartFolder%
which uses the function wslpath that's already defined in newer versions of Windows 10 to convert the pathname. The only complication that remains is that wslpath needs to have the backslashes in the DOS folder name escaped, so "C:\somefolder\someotherfolder" needs to be converted to "C:\\somefolder\\someotherfolder". Is there an easy way to do that from within DOpus? If not then I could certainly write a function that does that.
Ah, and brilliant tip about the MS-DOS Batch function dropdown. It looks like this means I won't have to define an external batch script for this, IF such a function "knows" what "{sourcepath}" is. Is this the case?
Just as a check, for regular cmd.exe, i've got a call to conemu with -Dir flag and {sourcepath} like this :
conemu64.exe -Dir {sourcepath}
and it's working fine.
As you said, paths in WSL are different. And path in unix style are not the same as path used by dopus in its path variables (with backslash etc) which are closest to regular dos path styles.
I'm sure there is a better solution as your batch trick...
Maybe it's a matter of configuring conemu specifically for wsl rather than dopus.
Conemu has a page on configuring conemu with wsl :
ps : sorry, i am not able to help more on that solution because i'm still on windows 8 with no wsl