Mac OS Hacks for Power Users
In this article I lay out a bunch of more or less unrelated steps I take to make Mac OS X more usable for me personally. So it's by no means complete or a "you have to do this too" guide. Instead it's aimed at pro users who're looking to improve their setup and get rid of annoyances the OS has to live a more trouble free life and avoid a heart attack ;)
By default Apple destroys some vital characters like
' replacing them with some broken counterparts. Similar story with auto correction, etc. I don't mind being informed about bad spelling but the choice of correcting it should be mine.
To disable these annoying default settings go to
System Preferences -> Keyboard -> Text and disable all of the check boxes on the right, especially the one that says:
use smart quotes. Those are a programmers nightmare.
Since you're here. head over to the
Shortcuts tab as well and disable
Input Sources -> Select the previous Input source. Emacs and Tmux both use
Ctrl-Space to select text. Having Mac OS hijack that is counterproductive.
Mac OS put's laptops into sleep mode when the lid is closed. This is hugely annoying when having a bunch of connections open that shouldn't be interrupted. So far I couldn't find a "don't do that" option in the UI.
While there are a number of tools out there that promise relief none of them worked reliably for me. Luckily you can disable sleep mode all together via the command line:
sudo pmset -a disablesleep 1
Or enable it:
sudo pmset -a disablesleep 0
The current status may be checked with:
This solution is quite elegant as it requires no 3rd party tools and has proven to work reliably for me. However it completely disables the sleep mode. So I switch this on and off as needed.
With Mac OS 10.15 (Catalina) Apple blessed us with
zsh as a new default shell. I have no gripes with that shell but also don't care for it. Bash works just fine for me and I don't feel like switching away from it. So here's how I switch users back to bash.
Login as whatever user you want to modify the shell of. Then run:
Enter your password. An editor will open up (in my case it
vim but you may use the
EDITOR variable to set whatever editor you prefer). Change the user's
Shell parameter to
/bin/bash. Save and restart your Terminal. You should now be in a Bash.
This is all you have to do to make it work. However Apple makes sure to remind you about
zsh every time with a message like this:
The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050.
Slightly annoying but luckily you can get rid of it by setting the following environment variable in you
Just my personal
source ~/.profile #export BASH_SILENCE_DEPRECATION_WARNING=1 alias mutt=neomutt alias vim=nvim alias vi=nvim alias emacs="emacsclient -c" alias ls="ls -G" alias l=ls alias ll="ls -l" alias la="ls -la" alias mc="mc -d" alias ydl=youtube-dl alias yadl="youtube-dl -x --ignore-config" alias ydlnc="youtube-dl --ignore-config" alias emacs='/opt/local/bin/emacsclient -c' alias sudi="sudo -i" alias port="sudo port" alias restartemacs="launchctl unload ~/Library/LaunchAgents/org.macports.emacs.plist ; sleep 2 ; launchctl load ~/Library/LaunchAgents/org.macports.emacs.plist" # https://superuser.com/questions/367275/linux-coloring-bash-prompt-will-break-carriage-return export PS1="\[\e[;32m\]\u\[\e[1;30m\]@\[\e[;36m\]\h \[\e[;33m\]\w\[\e[1;30m\] \$\[\e[m\] " export TERM=screen-256color export HISTSIZE=99999999 export LANG=en.UTF-8
This file is mainly there to give me the ability to browse through my command history in a more familiar way using the Page-Up and Page-Down keys:
"\e[5~": history-search-backward "\e[6~": history-search-forward
One of the Macs greatest strengths is it's UNIX heritage combined with Terminal access. Sadly there's no onboard package manager or portage as you might expect from Linux and BSD systems.
Luckily two popular projects fix this gaping hole in Mac OS X. By far the most popular one is Homebrew which works similar to a binary Linux package manager. While I certainly tried it I've never quite liked it enough to migrate away from the other project, MacPorts (used to be called DarwinPorts).
MacPorts is similar to a classical BSD portage or the Gentoo portage ... guess that's the reason I've adopted it so much. Once installed it allows you easy access to a huge repository of useful tools available in the FOSS sphere. For example:
sudo port install git
/opt/local/ as it's base. So most binaries are in
/opt/local/bin. Useful to know if you're looking for 3rd party options of Mac OS default tools like Vim or Emacs.
Performing the following steps in order to install MacPorts has never let me down:
- Install XCode (sadly you will need to do this through the Apple App Store as they no longer provide standalone installers)
- Open a Terminal and run
sudo xcode-select --installfollowed by
sudo xcodebuild -license. You can skip the license hitting
qand accept it by typing
- I usually install XQuartz too for those few X apps I want to have on the Mac.
- Download the latest MacPorts pkg installer for YOUR Mac OS X version and install it.
- Open a terminal and run:
sudo port selfupdate
Done, you're good to go.
Ever time you start an application your computers sends a request to an Apple controlled service that checks if that Application is OK or not.
While I get the idea behind that I'm not very keen on that system. Recently this caused some major issues for every Mac OS user and has also revealed the questionable nature of the OCSP protocol which essentially leaks that data to anyone who's able to read it.
So I prefer to shut down this feature:
sudo defaults write /Library/Preferences/com.apple.security.revocation.plist OCSPStyle None sudo defaults write com.apple.security.revocation.plist OCSPStyle None
(More on this topic here)
Quick one, TextEdit is actually quite a nice app once you get rid of the Word style. Go to
Preferences and set the
Plain text. Maybe change other settings as needed.
This way you can use TextEdit as an actual text editor instead of a broken text processor (the latter is once again, a programmers nightmare).
Aside from installing XCode I don't use the AppStore. In fact I hate it with a passion. For me it's natural to get a piece of software from any place I choose and trust and I demand that I'm allowed to install it. A tool called gatekeeper is in the way of this freedom.
To be fair, most tools are signed and it's possible to install them through a download on the projects official website (pro tip: NEVER download from anywhere else!). However I don't like missing out of software that is perfectly safe but unsigned.
While the UI option to allow software from every source has disappeared years ago it's still possible to regain control over where you get your software from. Open a terminal and run:
sudo spctl --master-disable
To re-enable gatekeeper:
sudo spctl --master-enable
It is good practice to disable gatekeeper only while installing something and re-enable it afterwards. The general idea isn't all that bad.
I use emacs in server mode as the awesome Spacemacs mod takes a while to load. On Linux with
systemd this is 1-2-3 easy. Luckily Mac OS X has a similar mechanism called
launchd which allows custom user daemons.
To run Emacs in server mode on login I create
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.macports.emacs</string> <key>ProgramArguments</key> <array> <string>/opt/local/bin/emacs</string> <string>--daemon</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Once ready the daemon can be loaded with:
launchctl load ~/Library/LaunchAgents/org.macports.emacs.plist
and unloaded with:
launchctl unload ~/Library/LaunchAgents/org.macports.emacs.plist
Maybe alias your
emacs command to
emacsclient -c if you do this (see bash config further up)
as a treasure trove of hacks that make MacOS more pro user friendly hoping that there's something useful to take away for everyone.