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