A month ago I refreshed my machine, switching from my trusty Fedora to macOS. Both inherit the Unix pedigree, but there are still plenty of differences. After a month of use, I feel I can finally get by; though many things still feel foreign, at least I can code properly now. I’m taking some time to jot down a few notes, hoping they might help someone.
When you first power on a Mac, there’s an initial setup process that basically asks you to create an Apple account, link a credit card, and pick a region for the corresponding store. The U.S. store seems to have a bit more content by comparison. But if you choose the United States, you’ll need a U.S. credit card that can actually be charged—think that through yourself.
The default terminal on a Mac is bash, just like on Linux, though some people seem to think zsh is better. It really depends on what you’re used to. The only odd thing is that under bash,
cp dira/ dirb/ -rcp -r dira/ dirb/Overall, using a Mac isn’t very different from Linux; with a little tweaking it can feel basically the same. If you’ve used FreeBSD before, the tuning feels even more natural. However, the Mac community environment isn’t great. For example, if you say “I want to achieve X,” the Linux community usually responds with “change the X config” or “you don’t even know that? change the X config.” If you add “Mac” or “OS X” to your Google search, the results are mostly people preaching about taste and product philosophy, telling you “you stupid Windows users should be more like Linux users and us” and not to change these things. If you search in Chinese, you basically won’t find any other type of answer. But for most of your problems (except UI-related ones), you can drop the mac/osx keywords and find answers in Linux or BSD communities, so aside from being annoying it’s not a big deal.
HomeBrew
Red Hat has yum, Debian has apt, Arch’s pacman is also neat—how can a *nix be without a software repository? Mac has two package management systems: MacPorts and Homebrew. If you’re interested in playing with configurations you can use MacPorts, especially if you have fond memories of FreeBSD’s Ports. But I’m lazy, so I just use Homebrew.
Homebrew’s official site is brew.sh; you can find the install command at the bottom of its homepage.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Unlike many Linux distributions, macOS comes with Ruby by default—indeed, very Ruby. Then, quickly (unless your network is terrible, in which case forget I said that), it will download the code and finish installing.
At first you can check the environment—not required, but highly recommended.
brew doctorAfter a moment of silence it will report what’s wrong, usually a bunch of warnings. Most of them mean something like: directories such as /usr/local/lib are now Homebrew’s territory, and it sees other files there—nuke them or not, it’s up to you. If you don’t remove them, Homebrew will keep warning you. Or it might say that /usr/bin comes before it in the PATH order, so after installing something like git you’ll still execute Apple’s version by default. The fix is to add a line at the end of your startup script, such as ~/.bash_profile:
PATH=/usr/local/bin:$PATH
export PATHAfter some fiddling, run doctor again:
$ brew doctor
Your system is ready to brew.Problem resolved. Then you can use it.
Using it is simple:
brew install/remove/uninstall/reinstall package_name # 安装/删除/卸载/重装 某个特定的包
brew search text|/text/ # 搜索某个包
brew update # 和服务器同步包信息
brew upgrade # 更新包Anyway, once the command runs it downloads a bunch of stuff with a clatter, and finally draws a little beer glass to cheer you up, indicating the install/reinstall/remove is done. That feels pleasantly hipster; I feel like having a drink myself. Sometimes if an error occurs, you can basically just blindly add the --overwrite flag as the prompt suggests. If you want to learn more, just man brew.
Bash completion
The package for bash auto-completion is called bash-completion, same on any *nix.
$ brew install bash-completionDone.
Homebrew packages live under /usr/local/Cellar; an “install” links them into directories like /usr/local/bin and /usr/local/lib. But after installation you still need to source its script to use them. When we run a shell, we need to execute the bash-completion script. For example, add a line in your startup script (~/.bash_profile):
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
fiThat’s it.
Then open a new terminal, or in the current terminal run:
source ~/.bash_profileand it takes effect.
We can test the effect. Pick any directory and create a Makefile:
.PHONY: all install clean
all:install
@echo "make all"
install:
@echo "make install"
clean:
@echo "make clean"After saving, type "make " and press Tab, and you'll finally see completions for all, install, and clean instead of a mindless pile of filenames.
LaTeX
Homebrew doesn't come with LaTeX by default; if we search, we find:
$ brew search latex
latex-mk latex2html latex2rtf pplatex rtf2latex2eThere are also a bunch of related notes telling you not to install LaTeX, because this thing is very troublesome on a Mac, and recommending that you install MacTeX. The MacTeX official website is http://www.tug.org/mactex/.
But Homebrew doesn't have MacTeX either, and the official download is painfully slow — at least from my location. You can laugh at my internet now. Anyway, I waited impatiently for a while and then canceled that DMG installation method.
Then there's something called Homebrew Cask.
$ brew install caskroom/cask/brew-cask
....
$ brew cask install mactex
==> Caveats
To use mactex, zsh users may need to add the following line to their
~/.zprofile. (Among other effects, /usr/texbin will be added to the
PATH environment variable):
eval `/usr/libexec/path_helper -s`
==> Downloading http://mirror.ctan.org/systems/mac/mactex/mactex-20140525.pkg
######################################################################## 100.0%
==> Running installer for mactex; your password may be necessary.
Password:
==> installer: Package name is MacTeX-2014
==> installer: Installing at base path /
==> installer: The install was successful.
[此处有个酒杯] mactex installed to '/opt/homebrew-cask/Caskroom/mactex/20140525' (2.3G)Then it's installed — thinking about it, it's actually no different from before; but I'm just weird and don't like DMGs, so it is what it is.
Then you'll see a new folder in Launchpad with a bunch of related programs; click around and play. But at this point you still can't compile .tex files from the Terminal command line. The fix is simple: add /usr/texbin to your PATH.
MacTeX isn't actually the best option; texstudio can build a LaTeX project and makes writing papers much more pleasant. However, I only heard about this after I'd finished installing and when I didn't really have much to write, and the logo's color scheme is too ugly, so I still haven't installed it...
axel, the download godsend
In life you always have to download something; git + brew can't handle everything for you. But when you have to download a huge chunk of data, Xunkai came through with an awesome suggestion: axel.
Installation is simple:
$ brew install axelUsage is also simple:
$ axel -n 256 some_urlIt will fire up 256 processes and pull the data down like a mad dog. But too many or too few are bad; you need to find a balance.
Java
macOS comes with Java built in, but the never-changing JDK 6 is really getting old, and I wanted something newer. Unfortunately, the plan to install a JDK environment directly through Homebrew fell through; we had to download the pkg from the official website and install it.
For the installation, you can go to the official site; the address is http://www.oracle.com/technetwork/java/javase/downloads/index.html. Download whichever version you want, then just click Next all the way through.
Update:
Homebrew can now install the JDK.
brew cask install caskroom/versions/java8 # 安装 jdk8
# brew cask install caskroom/versions/java9 # jdk 9The default environment variable JAVA_HOME can be set directly to the value of /usr/libexec/java_home.
The JDK is not the JVM. Many people accidentally download Java's browser plugin, which takes up quite a bit of space but is barely used by anyone. If you don't mind, you can keep what you just downloaded; otherwise, you may want to remove a few things.
To remove Java's browser plugin, refer to this.
In short, delete:
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.pluginThat's the official approach. However, I also found a symlinked config file under /Library/Application\ Support/Oracle. After checking the directory, it appeared to be mostly empty, and its purpose was unclear, so I just removed the Oracle directory.
If you no longer want to use Java and wish to remove the JDK or old versions, refer to this.
Remotely Logging into Windows
For remotely connecting to Windows from a Mac, I personally think Microsoft Remote Desktop is the best choice — it's an official Microsoft app and it's free. Unfortunately, it's not available in the Chinese App Store. So, your options are: switch to the US store, use the terrible alternative you can find on Microsoft's website, go to certain places I'd rather not mention to do your shameful deeds, or just don't bother. I really wanted to stand firm and say "I just won't connect to Windows, so what?", but in the end I did the most shameful thing. Sigh. Life is imperfect...
Anyway, as shown above, you can edit and save multiple profiles. It still has some quirks after using it for a while, but I haven't found anything better yet...
Something else ...
Computers are meant for enjoying life. There's all kinds of content out there in various forms, and it's worth giving them a try. It's only natural to explore things that catch our interest in the Mac App Store and among open-source software — consider it a bit of hands-on experience.
- Evernote is much better on macOS, and it's great not having ads in the lower-left corner.
- GeoGebra feels nice to use too; I used it on Linux.
- MPlayerX gives videos a great viewing experience.
- Vienna + inoreader are simply addictive.
- Scrivener is one of my favorites, but I haven't bought it yet since I don't have much use for it right now—it's $45. If anyone wants to do some writing, give it a try; there's a one-month trial.
- textmate is a legendary editor that feels amazing to use, and €40 isn't expensive.
- omnifocus is a time-management tool that feels pretty fun; at $39, it seems worth it.
- TexPad is a LaTeX project IDE.

Comments
No comments yet — be the first to write one.