I've got multiple terminal tabs open, and I want to be able to close the current tab. How can I make the current terminal tab be the active tab, so that I can close that tab with ⌘+w?
I am in the default Mac terminal.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
If you're trying to do it in a script, you might use something like this:
tell application "Terminal" repeat with w in (get windows) repeat with t in (get tabs of w) if processes of t contains "man" then set selected of t to true set index of w to 1 end if --properties of t end repeat end repeat end tell tell application "System Events" to tell process "Terminal" perform action "AXRaise" of window 1 tell menu 3 of menu bar 1 if enabled of menu item "Close Tab" then click menu item "Close Tab" else click menu item "Close Window" end if end tell end tell
Tab objects don't have a
set index to 1 doesn't actually raise a window, but it makes it it appear as window 1 to System Events, which supports the AXRaise action.