My MacBook setup

Disabling [rootless]
System Integrity Protection ("rootless") keeps some directories and files from being modified, even by root.
Some programs do not work well with SIP enabled. Do the following to turn it off:
- Enter Recovery Mode: start up while holding
Command ⌘+R - Open the terminal: Utilities » Terminal
- Run the command
csrutil disable
Password for root:
sudo passwd
Hostname
sudo scutil --set ComputerName "Air"
sudo scutil --set HostName "Air"
sudo scutil --set LocalHostName "Air"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist NetBIOSName -string "Air"
Trackpad
Three-finger drag
Accessibility » Mouse & Trackpad » Trackpad Options… » Enable dragging » three finger drag
Scanner
Xsane, which I use on Linux, also works on the Mac. It is open source and quite complete:
brew install sane-backends
brew install xsane
Vuescan is a native app and works very well, but it is paid software.
Zoom
Accessibility » Zoom » Use scroll gesture with modifier keys to zoom: ^ Control
XCode
The latest version of XCode can be downloaded from the Apple Store or at https://developer.apple.com/downloads/, where the beta versions are also available.
If the .xip file downloaded from Apple’s site shows up as corrupted, try opening it with another program. Here The Unarchiver showed “Data Corrupted”, but Archive Utility worked perfectly.
Install the command line tools:
xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Open XCode and accept the license, or type “agree” at sudo xcodebuild -license to agree.
Turn off Gatekeeper to allow installing apps downloaded from the internet
This fixes “XXX can’t be opened because it is from an unidentified developer”.
sudo spctl --master-disable
System Preferences > Security & Privacy > General » Allow apps downloaded from: Anywhere.
Turn it back on with: sudo spctl --master-enable.
Dotfiles
git clone --recursive https://github.com/jbsilva/dotfiles.git
cd dotfiles
git submodule update --init --recursive
Homebrew
Download and install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap Homebrew/bundle
brew bundle --file=/Users/julio/dotfiles/Brewfile
Karabiner-Elements
Download Karabiner-Elements
Some advanced modifications can be found at https://ke-complex-modifications.pqrs.org/.
Swap Caps-Lock for ESC
The configuration is in the dotfiles.
Use Enter in Finder to go into a directory
Use F2 to rename
Zplug + Zprezto
Zplug manages the ZSH plugins. It is installed automatically.
Links to the dotfiles
ln -s ~/dotfiles/.gitconfig ~
ln -s ~/dotfiles/.config ~
ln -s ~/dotfiles/.zsh ~
ln -s ~/dotfiles/.zshrc ~
Copies of the dotfiles that cannot be links
sudo cp ~/dotfiles/fstab /etc/fstab
Zsh default shell
command -v zsh | sudo tee -a /etc/shells
sudo chsh -s "$(command -v zsh)" "${USER}"
compaudit | xargs chmod g-w
Zsh completions
Install the zsh_completions formula:
brew install zsh-completions
Add $(brew --prefix)/share/zsh-completions to $FPATH:
FPATH=$(brew --prefix)/share/zsh-completions:$FPATH
Mounting a drive
Create the folder listed in /etc/fstab and mark it as immutable so
that MacOs does not delete it after the disk is unmounted:
sudo mkdir /Volumes/Elements
sudo chflags uchg /Volumes/Elements/
Mount the disk:
diskutil mount disk2s1
Vim
Vundle
Open Vim and download the plugins with :PluginInstall
Spell checker
Type :setlocal spell spelllang=pt_br in Vim and follow the instructions.
Finder
- In Home (
~)View»Show View Options(Cmd+J):- Calculate all sizes,
- Show Library Folder,
- Show item info
- On the Desktop
- Right click »
Show View Options(Cmd+J):- Show item info,
- Increase the Grid spacing
- Right click »
Preventing automatic sleep
There are several programs for this:
- InsomniaX
- Caffeine
- Amphetamine
- KeepingYouAwake
I am using KeepingYouAwake, which is very simple and free.
From the command line there is caffeinate:
Prevents sleep for 1 hour (3600 seconds):
caffeinate -u -t 3600
Prevents sleep until a command finishes:
caffeinate -s command
Prevents sleep until Ctrl-C:
caffeinate -I
Preventing sleep when the lid is closed
sudo pmset -a disablesleep 1
Turning off HD sleep
System Preferences » Energy Saver: uncheck Put hard disks to sleep when possible
A link to /Volumes on the Desktop
ln -s /Volumes ~/Desktop/
Turning off the guest user
System Preferences » Users & Groups: Uncheck “Allow guest to log in to this computer”.
SSH
Copy your keys from the backup and set the right permissions:
cp -r /Volumes/Cofre/.ssh ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/*
chmod 644 ~/.ssh/*.pub
Spotlight
System Preferences » Spotlight
Spotlight returns quite useless things in the search results. Turn off Bookmarks & History, Fonts, Movies, Music, Other, Presentations, and so on.
Uncheck “Allow Spotlight Suggestion in Look up”.
NTFS
NTFS-3g
OSXFuse and NTFS-3g can be installed with Homebrew for free.
Link mount_ntfs to ntfs-3g:
sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.original
sudo ln -s /usr/local/sbin/mount_ntfs /sbin/mount_ntfs
Paragon and Tuxera
I used NTFS-3g for many years (both on Linux and on the Mac), but its performance really does leave something to be desired.
I switched to Paragon when I had to back up a few terabytes of data. The difference in transfer rate was quite significant.
Consider Paragon (R$ 34.95) or [Tuxera] (R$ 107.13) if you use NTFS-formatted disks.
Python
Virtualenv
$ export PYTHON_CONFIGURE_OPTS="--enable-framework --enable-unicode=ucs4 --enable-ipv6 --enable-loadable-sqlite-extensions"
(Other options –enable-shared –with-wide-unicode –with-computed-gotos)
$ pyenv install 2.7-dev
$ pyenv install 3.7-dev
$ pyenv rehash
$ pyenv global 2.7-dev 3.7-dev
Framework support (--enable-framework) is needed for tools such as YouCompleteMe.
Python libs
pip3 install flake8 ipython matplotlib numpy pep8 pep8-naming pygments scipy unidecode mako coursera awscli neovim
Ruby
Ruby version manager (RVM)
curl -L https://get.rvm.io | bash -s stable --rails
Gems
gem install pygmentize
Defaults
Trackpad and Mouse
Natural scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true
Tap to click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
Right button
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 0
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true
Keyboard
Enables tab in modal dialogs
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
Language
defaults write NSGlobalDomain AppleLanguages -array "en" "de" "pt-BR"
defaults write NSGlobalDomain AppleLocale -string "pt_BR@currency=BRL"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool true
Enables the Debug menu in the App Store
defaults write com.apple.appstore ShowDebugMenu -bool true
The folder where screenshots will be saved
SCREENSHOTS="${HOME}/Desktop/Screenshots" && mkdir "${SCREENSHOTS}" && defaults write com.apple.screencapture location -string "${SCREENSHOTS}"
Enables character repeat when a key is held down (needs a restart)
$ defaults write -g ApplePressAndHoldEnabled -bool false
Faster key repeat rate
$ defaults write NSGlobalDomain KeyRepeat -int 2
Starts Finder in home (~/)
$ defaults write com.apple.finder NewWindowTarget -string "PfLo"
$ defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
Shows the path bar in Finder
$ defaults write com.apple.finder ShowPathbar -bool true
Shows the status bar in Finder
$ defaults write com.apple.finder ShowStatusBar -bool true
Does not warn about extension changes
$ defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
Checks for updates daily (default: one week)
$ defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
Shows (internal) drive icons on the desktop
$ defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
Shows external drive icons on the desktop
$ defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
Shows removable media icons on the desktop
$ defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
Shows server icons on the desktop
$ defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
Does not create .DS_Store on network volumes
$ defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
Enables the develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true && \
defaults write com.apple.Safari IncludeDevelopMenu -bool true && \
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true && \
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true && \
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
Shows the absolute path in Finder’s title bar
$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Shows ~/Library
$ chflags nohidden ~/Library
Default Apps
By hand
$ vim ~/Library/Preferences/com.apple.LaunchServices.plist
Duti
$ duti -s org.videolan.vlc .mp4 all
Enables CUPS’ web interface
$ sudo cupsctl WebInterface=yes
The server will be available at http://localhost:631/admin.
Lock screen
System Preferences » Security & Privacy » General » Require Password » 5 seconds
Lock: Control + Shift + Power Sleep: Command ⌘ + Option ⌥ + Power
Shortcut: System Preferences » Keyboard » Shortcuts » + » Lock Screen » Shortcut
iTerm2
Terminal colorscheme
Apply Zenburn
$ wget https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/Zenburn.itermcolors
Command ⌘ + i » Colors » Color Presets » Import… » Zenburn.itermcolors » Open General
» Copy Current Settings to Selected Profile.
Font
The Nerd Fonts package was installed through Homebrew. To use it in iTerm2, just do the following:
Preferences » Profiles » Text » Non-ASCII Font » Hack Regular Nerd Font Complete
Login Items
System Preferences » Users & Groups » Current User » Login Items
Keep only:
- Flux
- InsomniaX (or equivalent)
- SwitchResX Daemon
- Moom
Chrome as the default browser
xdg-mime default chromium.desktop x-scheme-handler/http
xdg-mime default chromium.desktop x-scheme-handler/https
Mute Chrome
In the address bar: chrome://flags/#enable-tab-audio-muting
Hosts
I have a script that downloads the hosts file from someonewhocares.org and installs it automatically:
sudo ~/dotfiles/hosts.sh
An application that helps manage the hosts file is GasMask:
brew cask install gas-mask
Dock
Keep only useful programs in the Dock:
- Finder
- Contacts
- Calendar
- iTerm
- Google Chrome
Spotify
Besides logging into Spotify, you also have to set up scrobbling to Last.fm: Preferences »
Connect to Last.fm
Preferences: Turn off “Local Files”
Tips
Keeping the cover from being separate in Two Page view in Preview
Whenever you view a PDF two pages at a time, Preview will show the first page on its own, as if it
were a book cover. Sometimes that is not what we want and there is no way to turn that “feature”
off, but there is a trick: insert a blank page and move it to the first position:
Edit » Insert » Blank Page; View » Contact Sheet, then drag the blank page to the first
position.
Scrolling in the terminal
Shift+fn+UP and Shift+fn+DOWN
Setting up Gmail accounts is trivial, but besides those I also use an email address on my own host.
If Mail does not automatically recognize each imap folder’s role, you will have to set it by hand. E.g.:
Select Deleted Messages » Mailbox » Use This Mailbox As » Trash Mailbox
PATH
Check that the order of the directories in /etc/paths is right and that every directory is there.
Programs installed without Homebrew
- Adobe Acrobat Pro or PDF Expert: Viewing and editing PDFs
- Adobe Lightroom: Organizing the photo gallery
- Adobe Photoshop: Image editing
- CleanMyMac: System maintenance
- Dash: API Documentation Browser
- iStat Menu: Menu bar with CPU/Memory/Network/etc status
- LittleSnitch: Blocks unwanted connections. Free alternative: Lulu
- MacPaw Gemini: Removes duplicate files
- Microsoft Office
- Many Tricks Moom: Manages windows
- Parallels: Virtualization
- SideSync: For managing Samsung devices
- SwitchResX: Screen resolution
- Vuescan: scanner (free alternative: xsane)
- Wunderlist
Firewall
OS X ships with pfctl. LittleSnitch and Lulu also let you manage outgoing connections.
SSL certificates
In my case, I have to add the university’s certificates: moodle.dc.ufscar.br
MySQL
CLI
brew install mysql
mysql.server start
mysql_secure_installation
mysql_upgrade -u root -p
mysql.server restart
$ mysql -u root -p
mysql> select host, user, password from mysql.user;
mysql> CREATE USER 'julio'@'localhost' IDENTIFIED BY '123456';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'julio'@'localhost' WITH GRANT OPTION;
mysql> show variables;
mysql> show databases;
mysql> use nome_do_esquema;
$ mysql.server stop
MySQL Workbench
brew cask install mysqlworkbench
Apache
Uncomment the following lines in /etc/apache2/httpd.conf:
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule cgi_module libexec/apache2/mod_cgi.so
User folder
Uncomment the following lines in /etc/apache2/httpd.conf:
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
Uncomment the following line in /etc/apache2/extra/httpd-userdir.conf:
Include /private/etc/apache2/users/*.conf
Create the file /etc/apache2/users/julio.conf:
<Directory "/Users/julio/Sites/">
Options Indexes MultiViews FollowSymLinks
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Restart Apache with sudo apachectl restart.
Create the ~/Sites folder:
mkdir ~/Sites
PHP
sudo cp /etc/php.ini.default /etc/php.ini
sudo -e /etc/php.ini
phpMyAdmin
sudo vim /etc/apache2/httpd.conf
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
Google KSFetch
Google checks for updates every hour. Change that to 7 days:
defaults write com.google.Keystone.Agent checkInterval 604800
Or turn the check off entirely:
defaults write com.google.Keystone.Agent checkInterval 0
iTerm2 + tmux
iTerm2 integrates with tmux, a terminal multiplexer.
Install it with homebrew:
brew install tmux
Control mode:
tmux -CC
Byobu
Better than screen and tmux
Update: also consider Zellij.
Date
Date & Time:
- Use a 24-hour clock,
- Show the day of the week,
- Show date
iBooks
Every time you open an .epub, iBooks copies it into the directory
/Users/julio/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks.
The original stays where it was. It can be worth deleting the files (from within iBooks) to save space.
Inline attachment viewing type:
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
defaults write com.apple.mail DisableInlineAttachmentViewing -bool false
Github
git config --global credential.helper osxkeychain
This is already set in ~/.gitconfig.
Dictionaries
Dict.cc
Download it from http://www.dict.cc/?s=about%3Awordlist
iStat Menus
Settings » Date & Time:
- Uncheck
Show date and time in menu bar.
Settings » Energy Saver:
- Uncheck
Show battery status in menu bar.
Rearrange the menu items by dragging them while holding the Command (⌘) key.
Skype
Skype » Preferences… » Save files in: ~/Downloads/Skype
Telegram
Telegram » Preferences… » Advanced Settings » Save documents to: ~/Download/Telegram
Links
- https://gist.github.com/1623487.git
- Rootless: https://en.wikipedia.org/wiki/System_Integrity_Protection
- Security: https://github.com/lfit/itpol/blob/master/linux-workstation-security.md
- https://www.reddit.com/r/osx/comments/300chd/what_are_the_most_essential_apps_for_os_x_in/
- https://github.com/monfresh/laptop
- https://gist.github.com/adamstac/822811
- http://mikebuss.com/2014/02/02/a-beautiful-productive-terminal-experience/
- http://www.defaults-write.com/
- http://www.slant.co/topics/526/~window-manager-for-mac
- http://www.sunrisepage.com/computers/osx/osx1011.htm
- http://www.reecefowell.com/2012/11/16/ksfetch-annoyance-on-mac-os-x-10-8-ml-with-hands-off-or-little-snitch-firewall/
- https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration
- http://www.simononsoftware.com/virtualenv-tutorial-part-2/
- https://www.tekrevue.com/tip/gatekeeper-macos-sierra/
- https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.
I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.
I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.
On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.
Browse my gallery for some of my photography.
Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.
Always happy to connect! 🙂