I have the habit of doing a clean installation of MacOS whenever there is a new version of the Apple operational system, so I ended up compiling this guide with the main actions taken right after installation. Feel free to copy, adapt and share this guide as you need.
Homebrew
For those who come from Linux like me, Homebrew (or just brew) works as a package manager for MacOS.
Intallation
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Ref.: https://brew.sh
With brew
installed it is easy to search for and install new applications without having to go to the browser or to the AppStore:
# search and install wget, a command-line tool
brew search wget
brew install wget
# install vlc, a graphical application
# whenever you want to install a graphical app, use cask.
# you will notice on the output of the brew search whether it belongs to cask or not.
brew cask install vlc
Installing applications through homebrew
Next, I install various tools, applications, and fonts that I usually use. Install whatever is useful to you.
# dev tools
brew install git
# enable the fonts' tap
brew tap caskroom/fonts
# terminal and text editors' fonts
brew cask install font-fira-code font-source-code-pro font-roboto-mono
# text editor
brew cask install visual-studio-code
# dev tools
brew cask install github-desktop tableplus docker
# social, groupware, communication
brew cask install slack skype telegram whatsapp zoomus
# downloads, players
brew cask install transmission vlc
# browsers
brew cask install firefox google-chrome
# extras
brew cask install kindle authy itsycal
Another application that I use a lot is trello, which is no longer available through brew. However, there is a CLI tool called mas that can be used to install Mac AppStore applications via command line:
brew install mas
# You may need to sign in to the AppStore
mas signin mas@example.com
# search for apps with "trello" in name
mas search trello
# install trello by its id
mas install 1278508951
For more information on mas see the project page at https://github.com/mas-cli/mas.
Bash Completions
You should have noticed that after installing certain applications through brew
it displays the following message:
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
This means that the installed program came with some macros informing bash about its possible arguments, options or parameters of the command in question when you press the [TAB]
key on the terminal. The famous Linux shell autocomplete feature.
To take advantage of this you must install the following utility:
brew install bash-completion
As suggested by brew, at the end of the bash-completion
installation, you should add the following statement to your .bash_profile
, which may not even exist (in this case just create it):
~/.bash_profile
:
# Enables bash completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Close your terminal and open it again or simply type source ~/.bash_profile
.
Now test typing git [TAB][TAB]
, for instance.
You should be presented to all possible git
subcommands.
Other completions that can be installed separately that I like to use:
brew install docker-completion \
docker-compose-completion \
docker-machine-completion \
django-completion pip-completion
SSH Keys
I use public key cryptography to connect to the servers I manage and I strongly recommend, if you are still using a password to access your servers, to migrate to ssh keys like me.
Generate a new SSH key
My private keys are password protected, so if I neglected them and had those keys compromised, they would still have to guess my passphrase to actually use my keys. By then I would have revoked my old keys and replaced them with new ones.
$ ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)-$(date +'%Y-%m-%d')"
How to change a passphrase
If you already have a ssh key pair and you only want to change your current private key's passphrase, you can simply run:
ssh-keygen -p -f .ssh/id_rsa
The above command can also be used to add a passphrase to a private key that was created without one.
Add keys to SSH agent
To not have to type the passphrase every time I need to use my private key, I use MacOS Keychain that interacts with the SSH agent. That way you only have to enter the passphrase of the private key once per session, that is, every login on the Mac.
Note: If you have installed a newer version of the OpenSSH client through brew, replacing the ssh apple client, perhaps the integration between Keychain and the SSH agent will not work._
~/.ssh/config
:
Host *
AddKeysToAgent yes
ServerAliveInterval 5 # prevents disconnection for inactivity
Take advantage of the following option in your /etc/ssh/ssh_config
:
Host *
# SendEnv LANG LC_* # <- comment on this line at the end of the file
Otherwise, you may encounter the following warning when logging in remotely:
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
Terminal
Let's face it, terminal with a white background!? I usually use the peppermint theme, available for the MacOS native Terminal and also for iTerm2.
Just download and double click on the file. If your Mac claims that this is not a signed and recognized software, go to System Preferences -> Security & Privacy:
Click the Open Anyway button on the General section.
Now let's fix the terminal, with it open and the peppermint theme applied, press CMD
+,
to open the terminal preferences.
- Go to Profiles, on the Text tab change the font to Source Code Pro and a size that suits you (I use 12).
- In the Windows tab change the Window Size to 80 x 20.
Last, make sure that the Peppermint theme is selected and click the Default button to make it the default theme.
The settings for iTerm2 are similar, but you'll need a specific theme for it: peppermint for iTerm2.
Colors for the Terminal
Insert the following snippet into your ~ / .bash_profile
:
#-------------------------------------------------
# Colorful Terminal
#-------------------------------------------------
#
# Tell ls to be colorful
export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
export TERM="xterm-color"
# colorful prompt
PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '
VIM improved
Enter the following settings in your ~/.vimrc
:
syntax enable
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set expandtab " tabs are spaces
set autoindent
set shiftwidth=4
filetype indent on " load filetype-specific indent files
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to
set showmatch " highlight matching [{()}]
set incsearch " search as characters are entered
set hlsearch " highlight matches
colorscheme peachpuff
VSCode
Access the user preferences with CMD
+,
:
{
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"editor.fontSize": 13,
"editor.fontFamily": "'Source Code Pro', 'Roboto Mono', Menlo, Monaco, 'Courier New', monospace",
"editor.wordWrap": "on",
"editor.lineHeight": 26,
"terminal.integrated.fontFamily": "'Source Code Pro'",
"editor.renderIndentGuides": false,
"editor.renderLineHighlight": "none",
"explorer.openEditors.visible": 0,
"editor.minimap.enabled": false,
"git.confirmSync": false,
"git.autofetch": true,
"explorer.confirmDelete": false
}
General customizations
Trackpad
In System Preferences -> Trackpad, in the Point & Click tab:
- Tap to click
- Click:
light
- Tracking speed:
5
In the More Gestures tab:
- App Exposé
Keyboard
In the System Preferences -> Keyboard, Keyboard tab:
- Key Repeat: maximum (
Fast
) - Delay Until Repeat: minimum (
Short
).
Dock
- Size: around
20%
. - Magnification: turned off.
Mark the two checkboxes below, all of which are marked except Show recent application in Dock:
- Minimize windows into application icon.
- Automatically hide and show the Dock.
I use a dragging feature with three fingers, which was well hidden by the apple in the latest versions of MacOS. If you also use or used and do not know where the feature was:
System Preferences -> Accessibility -> Mouse & Trackpad:
- Click the Trackpad Options ... button
- Check Enable dragging
- In the dropdown menu choose: three finger drag
Obs : With this option active, some gestures that previously used three fingers, will require four.
Safari
Em Safari -> Preferences -> Advanced:
- Show full website address.
- Show Develop menu in menu bar.
In View -> Show status bar (ou CMD
+ /
)
Non Retina - HiDPI Displays
If you work most of the time on an external monitor that is not Retina - HiDPI, like mine, you might want to fix some blurry fonts typing this on terminal:
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
Ref.: angristan.xyz/how-to-fix-font-rendering-mac..
That's all folks! I hope you liked it and keep this as reference ;-)