content/blog/2021-02-19-macos.org
204 lines · 7262 bytes
1#+date: <2021-02-19 Fri 00:00:00>
2#+title: macOS Operating System: Initial Setup and Configuration Guide
3#+description: Comprehensive overview for first-time macOS users transitioning from other OS platforms, including system setup, terminal usage, and user interface customization.
4#+slug: macos
5#+filetags: :macos:terminal:setup:
6
7* Diving into macOS
8
9After spending nearly 15 years working with Windows and 8 years on
10Linux, I have experienced macOS for the first time. By chance, my spouse
11happened to buy a new MacBook and gifted me their 2013 model. Of course,
12I still consider my Linux desktop to be my daily driver and keep Windows
13around for gaming needs, but over the past week I've found myself using
14the MacBook more and more for things that don't require gaming specs or
15advanced dev tools.
16
17* Initial Thoughts
18
19Before I move on to the technical aspects of my set-up, I want to take
20some time and express my thoughts on the overall OS.
21
22As expected, the initial computer setup is a breeze with Mac's guided
23GUI installer.
24
25The desktop itself reminds me of GNOME more than anything else I've
26seen: even Pantheon from [[https://elementary.io/][ElementaryOS]], which
27people commonly refer to as the closest Linux distro to macOS. The
28desktop toolbar is great and far surpasses the utility of the GNOME
29toolbar due to the fact that the extensions and icons /actually work/. I
30launch macOS and immediately see my shortcuts for Tresorit, Bitwarden,
31and Mullvad pop up as the computer loads.
32
33Even further, the app dock is very useful and will be yet another
34familiarity for GNOME users. I know many people like panels instead of
35docks, but I've always found docks to have a more pleasing UI. However,
36I had to disable the "Show recent applications in Dock" preference; I
37can't stand items taking up precious screen space if I'm not currently
38using them. On that same note, it's taking me some time to get use to
39the fact that I have to manually quit an app or else it will still stay
40open/active in the dock, even if I've closed out all windows for that
41app (e.g. Firefox).
42
43Overall, I'm having a lot of fun and for users who spend a large
44majority of their time performing basic tasks like web browsing,
45writing, watching media, etc., macOS is a fantastic option.
46
47The rest of this post explains the technicalities of how I set up my CLI
48environment to make me feel more at-home, similar to the environments I
49set up on Fedora, Ubuntu, etc.
50
51* Making it Feel Like Home
52
53If you're someone who uses Linux primarily, no doubt your first thought
54when booting macOS will be the same as mine was: "Where is the terminal
55and how do I set up my favorite utilities?"
56
57Luckily, macOS hasn't completely hidden away the development tools from
58the average user. You can easily find the Terminal app in the Launchpad
59area, but it's probably not what you're used to. I was surprised (and
60happy) to see that the default shell is =zsh=, the shell I use on all of
61my Linux distros. However, the commands are not the same - even the ones
62you may think are native to the shell. Commands like =dir= do not exist,
63so other native commands like =ls -la= or =pwd= are more useful here.
64
65With only a few minutes of installing and tweaking a few packages, I was
66able to recreate a terminal environment that I feel very comfortable
67using. See the image below for a preview of the iTerm2 app with a split
68view between my macOS desktop shell and an SSH session into my server.
69
70* Xcode
71
72My first step was to search the web for any hints on how to get =zsh=
73back up to the state I like, with extensions, themes, etc. My first step
74was to install the CLI tools for
75[[https://developer.apple.com/xcode/][Xcode]], Apple's suite of
76development tools.
77
78#+begin_src sh
79sudo xcode-select -r
80#+end_src
81
82#+begin_src sh
83sudo xcode-select --install
84#+end_src
85
86* Homebrew
87
88Next up is to install [[https://brew.sh][Homebrew]], a nifty package
89manager for macOS.
90
91#+begin_src sh
92/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
93#+end_src
94
95I ran into a permission error when installing Homebrew:
96
97#+begin_src sh
98Error: Failed to link all completions, docs and manpages:
99 Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
100Failed during: /usr/local/bin/brew update --force --quiet
101#+end_src
102
103I found that the following permission modification worked like a charm.
104However, I noted that some users online discussed the fact that this
105solution may not work if your system has multiple users who use
106Homebrew.
107
108#+begin_src sh
109sudo chown -R $(whoami) $(brew --prefix)/*
110#+end_src
111
112Next up is to ensure Homebrew is updated and cleaned.
113
114#+begin_src sh
115brew update
116#+end_src
117
118#+begin_src sh
119brew cleanup
120#+end_src
121
122* iTerm2
123
124Now that I've installed the basic utilities for development, I moved
125onto installing iTerm2, a much better terminal than the default.
126
127#+begin_src sh
128brew install --cask iterm2
129#+end_src
130
131I also used the =Make iTerm2 Default Term= and
132=Install Shell Integration= options in the iTerm2 application menu to
133make sure I don't run into any issues later on with different terminals.
134
135We will also install =zsh= so we can use it in iTerm2.
136
137#+begin_src sh
138brew install zsh
139#+end_src
140
141* Oh-My-Zsh
142
143I've shown the great aspects of [[https://ohmyz.sh][Oh My Zsh]] in other
144blog posts, so I'll skip over that speech for now. Simply install it and
145run an update.
146
147#+begin_src sh
148sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
149#+end_src
150
151#+begin_src sh
152omz update
153#+end_src
154
155Finally, restart the iTerm2 application to ensure all changes go into
156effect.
157
158* Oh-My-Zsh Themes
159
160Let's change the theme of the terminal to make it a little more
161friendly.
162
163#+begin_src sh
164open ~/.zshrc
165#+end_src
166
167The third section of this file should contain a line like the code
168below. Change that theme to
169[[https://github.com/ohmyzsh/ohmyzsh/wiki/Themes][any theme you want]],
170save the file, and exit.
171
172#+begin_src sh
173ZSH_THEME="af-magic"
174#+end_src
175
176After changing the =.zshrc= file, you'll need to close your terminal and
177re-open it to see the changes. Optionally, just open a new tab if you're
178using iTerm2, and you'll see the new shell config.
179
180* Oh-My-Zsh Plugins
181
182Of course, my customization of =zsh= would not be complete without
183[[https://github.com/zsh-users/zsh-autosuggestions][zsh-autosuggestions]].
184This will bring up commands you've run in the past as you type them. For
185example, if you've run =ssh user@192.168.1.99= before, the terminal will
186show this command as soon as you start typing it (e.g. =zsh u=), and you
187can hit the right arrow to autocomplete the command.
188
189#+begin_src sh
190git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
191#+end_src
192
193#+begin_src sh
194open ~/.zshrc
195#+end_src
196
197#+begin_src sh
198# Scroll down the script and edit this line to add zsh-autosuggestions
199plugins=(git zsh-autosuggestions)
200#+end_src
201
202Remember: After changing the =.zshrc= file, you'll need to close your
203terminal and re-open it to see the changes. Optionally, just open a new
204tab if you're using iTerm2, and you'll see the new shell config.