Created
July 5, 2025 02:48
-
-
Save majick/123536197b9c446be30db6f63f083a95 to your computer and use it in GitHub Desktop.
Run a single-shot .command file on macOS without ugly Terminal bullshit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| nohup [DO_WHATEVER_YOU_WANT_HERE] 2> /dev/null > /dev/null & | |
| # The magic incantation to: | |
| # a. Make Terminal willing to close windows | |
| # b. Quit the terminal after this .command file runs | |
| # c. Get rid of Terminal from the Recent Apps list (because nobody runs Terminal) | |
| # | |
| # We're being clever with subshells here because Terminal doesn't want to die. | |
| # | |
| # Terminal is a piece of shit. | |
| # | |
| # a. Fuck this default pref of leaving dead windows. | |
| defaults export com.apple.Terminal - \ | |
| | plutil -replace "Window Settings".Basic.shellExitAction -integer 1 -o - - \ | |
| | defaults import com.apple.Terminal | |
| # b. call applescript host to kill the fucking terminal, which will now die. | |
| ( sleep 1; osascript -e 'tell application "Terminal" to quit' 2> /dev/null >/dev/null & ) | |
| # c. Get rid of the ugly and confusing icon. Requires dockutil. | |
| ( nohup dockutil --remove Terminal 2> /dev/null > /dev/null & ) | |
| # TODO: just make command files only ever run in iTerm. Except iTerm pops a tab instead of | |
| # a window which is hot garbage. Tabbed terminal windows are trash. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment