Help sought with assigning a hotkey to open a terminal in the current directory

Hi all

I'm trying to create a keyboard shortcut to open Windows terminal in the directory currently showing in Opus. (Is there always such a directory? I hope so. But I've got stuck at an earlier stage.)

I see this and I don't know what to do / choose.

I found some documentation (this and this and the like) but it did not seem to help.

First one on the list.

Thank you for your help.

Paths -> (sourcepath) Want Source path (long)? Ah, but of course! :slight_smile:

I am afraid that so doing fails to paths containing spaces, even if I enclose the variable within quotation marks:

[error 2147942667 (0x8007010b) when launching `powershell.exe -NoLogo']
Could not access starting directory "D:\Thunderbird mail" "

If I may: it does not help that for existing hotkeys there is no edit button - not even in a context menu; one has to work out that double-clicking the extant item edits it. Oh, except that, also, there seems to be some sort of editing box at the bottom of the screen, even before the double-click:

The Edit button is right above the list of hotkeys, just outside the area you cropped your screenshot to.

The field that says "Search Keys"? That's for searching the list of keys. :slight_smile:

The edit button: ah yes; thanks. Still, it would be nice to have it in the context menu as well. It is easy to overlook the button because, initially, it is greyed-out, and because it is some distance from the list of hotkeys.

So, that leaves the problem with paths-containing-spaces. Perhaps the problem lies with Windows Terminal, which, I think, needs the path to be sent to it as a literal quoted string. So, how to do that, please, anyone?

The path is quoted automatically if it contains spaces.

Some programs get confused by a backslash on the end of the path, especially if it's quoted. Try using {sourcepath$|noterm} instead of {sourcepath$} maybe.

That latter formulation worked, Leo. Thank you.

I add the following.

I did not realise that one needs the dollar-sign. Actually, does one?

Also: when I tried the following within Opus as a workaround - before solving the problem via {sourcepath$|noterm}, craziness ensued.

C:\Scripts\autohotkey\terminalHere\terminalHere.exe {sourcepath}

The craziness was that the resulting (whole, tried-to-be-executed) command seemed to comprise: the 'source path', a space, and the source path . .

Adding the $ means the command won't run if there isn't a source path available. Not adding the $ means the command will run and omit that parameter entirely (which would probably confuse wt.exe, as the -d argument would not have any path after it).

The menu in your first screenshot has both versions in the list, and uses "Need" vs "Want" to explain the distinction.

1 Like