When a GUI process is launched from the OS X terminal, the window shows up in the background, and you have to use command-tab to give it focus.
Is there a way to make the terminal automatically give such GUIs focus after they are launched? For example (assuming gitk is installed):
% gitk
should launch the GUI and then switch to it.
Note: For several reasons, using open
as this answer suggests is not a general solution.
Update: To better explain why the open
method isn't satisfactory, here's a sample bash session (with witty commentary).
% cd /my_repo
% gitk
Waiting for the GUI to appear ... any day now ... oh wait -- it's already open. I just didn't notice because it opened a window BEHIND my terminal. I wonder how long I was going to sit here waiting....
% open gitk
The file /my_repo/gitk does not exist.
Ah, of course.
% which gitk
/usr/bin/gitk
% open /usr/bin/gitk
What the ... it opened a new terminal window to run gitk, and it did so in my home directory, not /my_repo, so gitk complains that the current directory isn't actually a repository...
In Mac OS X, the graphical user interface (GUI) is based on the Aqua theme, menu bar, and iOS-like features.
Key Points. macOS has a graphical user interface (GUI) that includes the Finder, designed to easily access files and perform tasks on a Mac. The command-line interface (CLI) is a powerful tool for performing advanced tasks as an IT administrator.
In the Terminal app on your Mac, press the Up Arrow key. The last command you entered appears on the command line. Continue pressing the Up Arrow key until you see the command you want, then press Return.
Do you need to invoke it synchronously? If not, you could start it asynchronously with &
and then activate it with osascript -e 'tell application "gitk" to activate'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With