Skip to content

Instantly share code, notes, and snippets.

@majick
Created July 5, 2025 02:57
Show Gist options
  • Select an option

  • Save majick/3105b48a2cc49fbc446878eda8bcc6bb to your computer and use it in GitHub Desktop.

Select an option

Save majick/3105b48a2cc49fbc446878eda8bcc6bb to your computer and use it in GitHub Desktop.
macOS command file to run DOSBox Staging on a particular DOS program
#!/bin/sh
# Yes, POSIX shell. Because I said so.
#
# Example: run Wing Commander 1 launcher
COMMAND="LAUNCHER.BAT"
MYDIR=$(dirname -- $0)
nohup /Applications/DOSBox\ Staging.app/Contents/MacOS/dosbox -exit ${MYDIR}/${COMMAND} 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. Skipped if not present.
if [ $(which dockutil) ] ; then
( nohup dockutil --remove Terminal 2> /dev/null > /dev/null & )
fi
# 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