Skip to content

Instantly share code, notes, and snippets.

@cseelye
Last active February 17, 2020 17:40
Show Gist options
  • Save cseelye/5d54ca5d014619aed58cafd551149ab3 to your computer and use it in GitHub Desktop.
Save cseelye/5d54ca5d014619aed58cafd551149ab3 to your computer and use it in GitHub Desktop.
Configure the macOS terminal app
#!/bin/bash
/usr/libexec/PlistBuddy -c "Set 'Default Window Settings' 'Pro'" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Set 'Startup Window Settings' 'Pro'" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Set 'Window Settings:Pro:shellExitAction' 0" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add 'Window Settings:Pro:Bell' integer 0" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add 'Window Settings:Pro:ShouldRestoreContent' integer 0" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add 'Window Settings:Pro:columnCount' integer 130" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add 'Window Settings:Pro:rowCount' integer 40" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add 'Window Settings:Pro:keyMapBoundKeys' dict" ~/Library/Preferences/com.apple.Terminal.plist
# Set a sane key map
for i in $F702,[12D $F703,[12C $F708,[25~ $F709,[26~ $F70A,[28~ $F70B,[29~ $F70C,[31~ $F70D,[32~ $F70E,[33~ $F70F,[34~ $F728,[32~ F704,OP F705,OQ F706,OR F707,OS F708,[15~ F709,[17~ F70A,[18~ F70B,[19~ F70C,[20~ F70D,[21~ F70E,[23~ F70F,[24~ F710,[25~ F711,[26~ F712,[28~ F713,[29~ F714,[31~ F715,[32~ F716,[33~ F717,[34~ F728,[3~ F729,OH F72B,OF ^F702,[15D ^F703,[15C ^F728,[35~ ~F702,b ~F703,f ~F704,[17~ ~F705,[18~ ~F706,[19~ ~F707,[20~ ~F708,[21~ ~F709,[23~ ~F70A,[24~ ~F70B,[25~ ~F70C,[26~ ~F70D,[28~ ~F70E,[29~ ~F70F,[31~ ~F710,[32~ ~F711,[33~ ~F712,[34~ ~^F728,[35~; do IFS="," command eval 'set $i'; /usr/libexec/PlistBuddy -c "Add \"Window Settings:Pro:keyMapBoundKeys:$1\" string $(echo -en "\033")$2" ~/Library/Preferences/com.apple.Terminal.plist; done
# Reread and recache the settings
defaults read ~/Library/Preferences/com.apple.Terminal.plist
defaults read com.apple.Terminal.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment