My favorite MacOS initial setup
Key switching: right Command and Option, aka Polish characters like on Windows
If you're used to typing Polish characters using a key right next to spacebar (like on Windows/Linux), use the following script to switch places of right Command and Option
#!/bin/zsh
FILEPATH=~/Library/LaunchAgents/pl.zarajczyk.RightCommandOptionKeyRemappings.plist
if [ -f $FILEPATH ]; then
echo "File $FILEPATH already exists" && exit 1
fi
tee $FILEPATH << EOM
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.nanoant.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":
[
{"HIDKeyboardModifierMappingSrc":0x7000000e7,"HIDKeyboardModifierMappingDst":0x7000000e6},
{"HIDKeyboardModifierMappingSrc":0x7000000e6,"HIDKeyboardModifierMappingDst":0x7000000e7}
]
}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOM
echo "Done, please reboot the system"
0x7000000e7
- right Command0x7000000e6
- right Option- other possibilities of key switching: https://hidutil-generator.netlify.app/
Key switching: tilde and paragraph
Switching places of tilde ~
and paragraph §
buttons,
for people used to US keyboard layout forced to work on EU keyboard.
#!/bin/zsh
FILEPATH=~/Library/LaunchAgents/pl.zarajczyk.TildeParagraphKeyRemappings.plist
if [ -f $FILEPATH ]; then
echo "File $FILEPATH already exists" && exit 1
fi
tee $FILEPATH << EOM
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.nanoant.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":
[
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064}
]
}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOM
echo "Done, please reboot the system"
0x700000064
- button§
0x700000035
- button~
(tilde)- other possibilities of key switching: https://hidutil-generator.netlify.app/
Buttons Home, End, Page Up i Page Down - like on Windows
On Windows pressing Home/End when entering a text in a website moves the caret position to the beginning/end of text field. On MacOS, it will scroll the entire webpage.
#!/bin/zsh
FILEPATH=~/Library/KeyBindings/DefaultKeyBinding.dict
if [ -f $FILEPATH ]; then
echo "File $FILEPATH already exists" && exit 1
fi
if [[ $SHELL != '/bin/zsh' ]]; then
echo "Please set ZSH as your default shell" && exit 1
fi
mkdir -p ~/Library/KeyBindings
tee $FILEPATH << EOM
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
EOM
## Additional steps for iTerm2
echo "bindkey '\e[H' beginning-of-line" >> ~/.zshrc
echo "bindkey '\e[F' end-of-line" >> ~/.zshrc
echo "Done, please reboot the system"
Key repeating on long key press
#!/bin/zsh
defaults write -g ApplePressAndHoldEnabled -bool false
echo "Done, please reboot the system"
Homebrew & coreutils & command line tools installation
- Homebrew - must-have package manager for MacOS
- coreutils - GNU version of coreutils; MacOS is shipped with custom version of some of coreutils, but they work in a slightly different way than the GNU ones
- other software of my choice
#!/bin/zsh
if [[ $SHELL != '/bin/zsh' ]]; then
echo "Please set ZSH as your default shell" && exit 1
fi
if [ $(command -v brew) ]; then
echo "brew already installed"
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ## from https://brew.sh/
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
brew install coreutils
brew install watch
brew install wget
brew install screen
echo 'PATH="'$(brew --prefix coreutils)'/libexec/gnubin:$PATH"' >> ~/.zshrc
echo "Done, please reboot the system"
Python installation
Using pyenv
#!/bin/zsh
if [[ $SHELL != '/bin/zsh' ]]; then
echo "Please set ZSH as your default shell" && exit 1
fi
# docs: https://github.com/pyenv/pyenv#basic-github-checkout
brew install pyenv
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
# choose newest, f.ex. 3.10.0
NEWEST=$(pyenv install --list | grep -E "^\s*\d+\.\d+\.\d+$" | sort -V | tail -n 1 | xargs -I{} echo {})
echo "Will install Python $NEWEST as default"
pyenv install "$NEWEST"
# use it
pyenv global "$NEWEST"
# verify
python --version
echo "Done, please reboot the system"
Java installation (JDK 11 and 17 at once)
#!/bin/zsh
if [[ $SHELL != '/bin/zsh' ]]; then
echo "Please set ZSH as your default shell" && exit 1
fi
brew install openjdk@11
brew install openjdk@17
sudo ln -sfn $(brew --prefix openjdk@11)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
sudo ln -sfn $(brew --prefix openjdk@17)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk
echo 'alias java11="export JAVA_HOME=$(/usr/libexec/java_home -v 11); java -version"' >> ~/.zshrc
echo 'alias java17="export JAVA_HOME=$(/usr/libexec/java_home -v 17); java -version"' >> ~/.zshrc
Docker
See:
Disable "drag to top" opening Mission Controll
MacOS 13 Ventura
Go to System setting
> Desktop and Dock
Scroll to Mission Control
Uncheck "Displays have separate Spaces" then log out and back in again.
Before MacOS 13 Ventura
Go to System Preferences
> Mission Control
Uncheck "Displays have separate Spaces" then log out and back in again.
Software
- Logi Options app from Logitech for mouse and keyboard
- iTerm2 terminal, color preset: Solarized Light
- Divvy window manager - paid. Allows resizing windows using a nice diagram
- IntelliJ IDEA - IDE
- Clipy multi-clipboard
- Tiles Window Manager - freeware. Allows resizing windows by hotkeys or dragging
- shell: ZSH + oh-my-zsh
- https://github.com/rzarajczyk/agnoster-zsh-theme theme for oh-my-zsh: agnoster.rzarajczyk
- HP Drivers - HP Drivers for older printers (see also this link)
- Adobe Reader - PDF reader
Interesting Chrome Extensions
Other interesting MacOS Apps
- BetterTouchTool allows customizing almost everything in MacOS, including TouchBar.