· Mar 6, 2020

Force terminal to the foreground after current command finishes running

Simple problem:

  1. I leave a long-running command in terminal
  2. Switch to another task(s)
  3. Remember that I need to check on my command after a few hours

Is there any way to force terminal to the foreground after current command ends?

This is Windows with cterm/iristerm although Putty/Kitty solution would also be nice.

Discussion (6)2
Log in or sign up to continue

Cache Terminal doesn't have a setting similar to Putty.

Windows has methods for finding a specific window that belongs to another app and bringing it to the foreground. You could write a C++ or C# program to do that:

Or many scripting languages have libraries that use those Windows methods:

It's not a pretty solution but you can achieve it using a terminal script (iristerm/cterm). The script will call your routine and when it ends it will throw a popup alert informing that your routine did finish. It will not bring the terminal to the foregroung but you get the alert.

Save this to a file:

send: d ^myRoutine<cr>
wait for: USER>
execute: mshta vbscript:Execute("msgbox ""Routine myRoutine finished processing."",48:close")

In terminal, press ALT+S and select the your script file and when the routine ends you will see a popup.