Skip to content

Instantly share code, notes, and snippets.

@mpoisot
mpoisot / display_config.sh
Created October 29, 2020 15:25
Set multi-monitor display arrangement for a MacBook based on which USB C port the monitor plugs in to
#!/usr/bin/env sh
# Call this script from an EventScripts trigger. https://www.mousedown.net/software/EventScripts.html
# Depends on `displayplacer`. https://github.com/jakehilborn/displayplacer
# On my macbook, when my external screen is plugged into the right USB ports I get one contextual ID running `displayplacer list`. When plugged into the left ports I get a different ID.
# 27" LG info from `displayplacer list`, connected to right USB ports:
# Persistent screen id: 1B2915BF-F01F-DFDA-9605-FB0311DB5E03
# Contextual screen id: 458633946
@mpoisot
mpoisot / gist:2352577
Created April 10, 2012 16:21
Mac OSX Home & End Keybindings
Create or add to ~/Library/KeyBindings/DefaultKeyBinding.dict
{
/* Remap Home / End to be correct :-) */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}
@mpoisot
mpoisot / gist:2352305
Created April 10, 2012 15:48
Mac OSX Enable Trim Support (for SSD drive)
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches