conemu start a given console with hotkey

1

How could I assign a hotkey of my choice to start c:\cygwin\cygwin.bat ?

Similarly, but a bit more difficult, how could I start c:\dir1#VAR#\dir2\test.bat, where #VAR# is the name of a directory that varies, and the last (in alphabetical order) of all #VAR# should be chosen ?

So just to be clear, if c:\dir1\A\dir2\test.bat and c:\dir1\B\dir2\test.bat exist, the console that should be opened when the hotkey is pressed is: c:\dir1\B\dir2\test.bat.

Thanks

Car981

Posted 2013-03-28T19:51:48.293

Reputation: 305

Answers

1

You may create Macro on Keys & Macro page and choose any hotkey for it.

Shell("",@"c:\cygwin\cygwin.bat")

UPD. Or create a task and choose hotkey for it.

cmd /k c:\cygwin\cygwin.bat

As for you second part of question... You may do that via additional bat-file, for example

c:\dir1\runner.bat

@echo off
setlocal
cd /d "%~dp0"
set b=.
for /D %%g in (*) do set b=%%g
if not "%b%"=="." "%~dp0%b%\test.bat"

And run it with Macro ("new_console:n" means "Disable 'Press enter...' confirmation")

Shell("new_console:n",@"c:\dir1\runner.bat")

enter image description here

Maximus

Posted 2013-03-28T19:51:48.293

Reputation: 19 395

Thank you very much, it works like a charm, and I wouldn't have been able to produce such a batch script. Could you please explain how it works, especially the 'for' line ? – Car981 – 2013-04-03T15:12:31.983

For line enumerates all subdirectories in the current directory, which was set by CD command.So, "b" local variable will get the name of the last directory. Assuming that NTFS always sorts items by name, you will get exactly what you want. – Maximus – 2013-04-03T15:56:10.293

Is there a way to assign a shortcut to open a task that is defined already? I mean, suppose I already have c:\dir1\runner.bat assigned to task 3, I want a shortcut that opens task 3 so I don't have to repeat myself. – stijn – 2013-07-18T07:25:27.937

1Call shell with task name in curly brackets. – Maximus – 2013-07-18T10:41:57.670