Workflow: use a single Windows console!

21 views
Skip to first unread message

Edward K. Ream

unread,
Jun 11, 2024, 5:37:01 AMJun 11
to leo-editor

I have always launched programs in separate Windows consoles and used Alt-Tab to switch between them. But two nights ago, I realized that this procedure creates unnecessary work. What if it were possible to launch multiple programs from a single console?


OMG. Ten minutes of googling reveals that the Windows "start" command does exactly what I want. So now all my workhorse .cmd scripts use "start".


The only drawback is that the console no longer remembers command history.


Btw, it's now possible to launch two scripts at once. For example, s && d launches both the s.cmd and d.cmd scripts.


Summary


There is no need to alt-tab to the correct console! This is the biggest improvement to my workflow in recent memory.


I assume a similar trick is possible on other platforms.


Edward

Thomas Passin

unread,
Jun 11, 2024, 6:38:51 AMJun 11
to leo-editor
I use the START command sometimes.  For example, in the execute-external-file command, I have this bit:

            if processor == 'cmd.exe':
                cmd = ['start', processor, '/k', fullpath]
                subprocess.Popen(cmd, shell=True)
            else:
                cmd = ['start', 'cmd.exe', '/k', processor, fullpath]
                subprocess.Popen(cmd, shell=True)


But START can be tricky.  For example, if the first parameter on the command line is in double quotes, it is used as the title of the window.  If you don't realize that and the program you are STARTing needs to have its path quoted, START won't work because you program path will become the title and the next arg, if any, will become the program to execute, which is not what you want.  You have to use a pair of double quotes to avoid the problem:  START "" "quote path to program to run".  START has other quirks too.

I find it's easy to get confused about output when two programs run in the same console - who is printing to the console just now?  There's also the matter of how to terminate a program if it gets stuck or you are done with it.

One approximate equivalent on Linux is to end the command line with an ampersand.  This launches the program and its output goes to the terminal as usual.  If you hit CTRL-z, it executes in the background and you can use the terminal for other things too. the jobs command will show background programs. 

Thomas Passin

unread,
Jun 11, 2024, 7:01:13 AMJun 11
to leo-editor
More than running several programs in one console, what I would like is to be able to use a different color scheme for each console.  That would make it instantly clear which console is which.  It's possible to run a command to change the console color scheme - Microsoft has a tool named ColorTool.exe that will do so - but after you use it all subsequent consoles open with the new color scheme.  Grr - not what I want.

BTW, instead of changing your command files to use START, it could be easier to use DOSKEY macros (aliases) instead.  For example, I have set up my console to run my aliases.cmd file on startup using <WINKEY-R>:

cmd /k aliases

The aliases.cmd file defines some DOSKEY macros for that console session.  One of them launches my favorite text editor using START:

set ep="C:\Program Files\EditPlus\editplus.exe"
doskey ep=start "$1" /b %ep% $*


so when I type ep, I get the text editor started without a console.  I can edit the aliases.cmd file with another macro:

doskey ea=%ep% "c:\usr\bin\aliases.cmd"

IOW, you can separate the launch method from the command script.
On Tuesday, June 11, 2024 at 5:37:01 AM UTC-4 Edward K. Ream wrote:
Reply all
Reply to author
Forward
0 new messages