MacOS

These are a couple of notes on how I like to use a Mac with macOS on it, and why I bother.

Those Apple Silicon based Macs are pretty awesome, especially in terms of power-efficiency / battery-life. Additionally, macOS has excellent support for free as well as non-free software, specifically the office-suite. These are the two main reasons for me to use macOS on a Mac.

As far as a proprietary systems goes, then macOS can be comfortable, it get you started with vim and a decent Terminal.app. However, just remember that if you want to change anything kernel-wise, then you are stuck. And when you go down the route of disabling system protection, then macOS quickly becomes unstable and very annoying.

So, sticking within the provided system sandbox seems like the best use of a mac, for me atleast. Allowing myself the use of things like Yabai, to spend less time moving and resizing windwows.

Settings

The stuff below are settings in the macOS Ventura System Settings:

  • Appearance

    • Appearance: Dark

    • Sidebar icon size: Large

  • Desktop & Dock

    • Position on Screen: Left

  • Keyboard

    • Keyboard Shortcuts -> Modifier Keys

      • Select keyboard: Apple Internal Keyboard / Trackpad

      • Caps Lock key: Control

    • Keyboard Shortcuts -> Modifier Keys

      • Select keyboard: USB Keyboard

      • Caps Lock key: Control

      • Option key: Command

      • Command key: Option

  • Trackpad

    • Scroll & Zoom -> Natural scrolling: off

Tweaks

The tweaks are things which I haven’t found a convenient way to configure via Settings.app. Howevever, they are still within the functionality of the macOS sandbox.

Home/End

When hitting the physcial Home/End keys on a keyboard, which actually have those keys, then it moves the text-cursor to the begginning / end of the line. Additionally, then shift/move selects text.

Create the file ~/Library/KeyBindings/DefaultKeyBinding.dict, with the content:

{
  "\UF729"  = moveToBeginningOfParagraph:; // home
  "\UF72B"  = moveToEndOfParagraph:; // end
  "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
  "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl-home
  "^\UF72B" = moveToEndOfDocument:; // ctrl-end
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
  "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}

Unfortunately, then this does not work for everything… however… better than nothing.

Brew

Apple provides an App store, however, it requires logging in with an Apple-account. Plus, it is a graphical application, I much prefer a software/package manager in the SHELL. Thus, I go with the Brew package manager. In addition to providing packages, then it also provides a service-controller. So, when installing a daemon, then you can start/stop it via brew services.

There are alternatives, such as macports, similar to the FreeBSD ports collection. However, brew also contains non-free software, which is why I am using MacOS to begin with: better support for non-free software.

The neat thing about brew is that everything I need can be installed using it, with the exception of Rust, which should be installed via rustup.

Install brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Setup PATH:

echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/$USER/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/$USER/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Install Packages:

brew install \
 bash \
 cdrtools \
 clang-format \
 docutils \
 doxygen \
 gcovr \
 git \
 git-gui \
 graphviz \
 htop \
 koekeishiya/formulae/skhd \
 koekeishiya/formulae/yabai \
 meson \
 moreutils \
 mutagen-io/mutagen/mutagen \
 mypy \
 ncurses \
 neovim \
 ninja \
 pkg-config \
 pygments \
 readline \
 ruby \
 sloccount \
 sqlite \
 sshuttle \
 tree \
 vim \
 wget

Install Casks:

brew install \
 1password \
 discord \
 docker \
 element \
 firefox \
 gimp \
 google-chrome \
 homebrew/cask-fonts/font-dejavu-sans-mono-nerd-font \
 inkscape \
 iterm2 \
 meld \
 microsoft-office \
 microsoft-remote-desktop \
 openscad \
 pycharm \
 slack \
 spotify \
 sublime-text \
 todoist \
 vlc \
 wkhtmltopdf \
 zoom

Python

A recent Python interpreter comes with macOS, thus no need to grab a newer one via Brew. However, what is nice, is using pipx to manage Python-based cli-tools. Thus ensure you run:

pipx ensurepath

Rust

Install via untrusted sources:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

setting PATH.

LunarVim

macOS comes with vim, which is pretty great! However, much like vim was an improvement over vi, then the extended neovim is a potential evolutionary step to the greatest text-editor ever.

Projects such as LunarVim, turns neovim into an IDE.

LV_BRANCH='release-1.2/neovim-0.8' bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/fc6873809934917b470bff1b072171879899a36b/utils/installer/install.sh)

iTerm2

The Terminal.app is great, however for use with lvim, then better color-support is needed. Also, iTerm2.app has been the “category-killer” for Terminal applications on macOS for 10+ years. Thus, when looking to customize/configuring something, then there is more hits on iTerm2.app over Terminal.app simply due to its popularity.

  • iTerm2 -> Settings -> Appearance

    • General -> Theme: Compact

  • iTerm2 -> Settings -> Profiles -> Profile Name: Default

    • General -> Working Directory: Reuse preivous session’s directory

    • Colors -> Color Presets: Solarized Dark

    • Colors -> Font: DejaVuSansMono Nerd Font 18

Window Manager

Yabai is a tiling window manager, other alternatives include Amethyst, and the very simple Rectangle.app. I tried out Rectangle.app but got frustrated as it allows be to position windows, however, it does not automatically manage their position as a tiling window manager does. When coming from e.g. i3 on Linux, then it is worth noting that macOS was not built for this, also, it is very easy to disable window-management for things like Calculator.app and System Settings.app.

Thus, if yabai is getting in the way, then disable it for certain applications. Also, it can be completely switched off easily withouth bring down everything. Thus, it is relatively “safe” to use what it provides, and opt out when it fails you.

Edit the Yabai configuration vim ~/.yabairc:

#!/usr/bin/env sh

#
# for this to work you must configure sudo such that
# it will be able to run the command without password
#
# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition
#
# yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
# sudo yabai --load-sa
#

yabai -m rule --add app="^Discord$" grid=1:1:0:0:1:1 manage=off
yabai -m rule --add app="^(Calculator|System Settings|System Preferences|Archive Utility)$" manage=off

# global settings
yabai -m config                                 \
    mouse_follows_focus          off            \
    focus_follows_mouse          off            \
    window_origin_display        default        \
    window_placement             second_child   \
    window_topmost               off            \
    window_shadow                on             \
    window_animation_duration    0.0            \
    window_opacity_duration      0.0            \
    active_window_opacity        1.0            \
    normal_window_opacity        0.90           \
    window_opacity               off            \
    insert_feedback_color        0xffd75f5f     \
    active_window_border_color   0xff775759     \
    normal_window_border_color   0xff555555     \
    window_border_width          4              \
    window_border_radius         12             \
    window_border_blur           off            \
    window_border_hidpi          on             \
    window_border                off            \
    split_ratio                  0.50           \
    split_type                   auto           \
    auto_balance                 off            \
    top_padding                  12             \
    bottom_padding               12             \
    left_padding                 12             \
    right_padding                12             \
    window_gap                   06             \
    layout                       bsp            \
    mouse_modifier               fn             \
    mouse_action1                move           \
    mouse_action2                resize         \
    mouse_drop_action            swap

echo "yabai configuration loaded.."

Edit shortcuts for Yabai by using skhd vim  ~/.skhdrc:

alt - left : yabai -m window --focus west
alt - down : yabai -m window --focus south
alt - up : yabai -m window --focus north
alt - right : yabai -m window --focus east

Yabai is controlled via brew-services:

brew services start yabai

Meld

Meld is not officially supported on macOS, however, unofficially .dmg exists and they are installable via brew. However, they are not signed and thus, not allowed to run on Ventura. Here is an unsafe way to work around that short-coming:

xattr -r -d com.apple.quarantine /Applications/Meld.app/

DS_STORE

Do:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Note

Does not take effect until after logout/reboot.

cdrtools

Using cloud-init tools… images… recall which tool was used here.

Microsoft Office

This thing just works, with OneDrive sync and everything with your Microsoft Account. One note, regarding the use of Outlook and Exchange, To utilize this, then first log into Word/Excel/OneDrive, because then the office-suite knows that it is licenced.

Then you can open Outlook, and in “Help”, there is an option “Revert to Legacy”. With this version Exchange is functional.

Short-comings

I miss the following tools:

  • cloud-init

  • pahole

  • A native / fast use of Docker and Podman, that is, native containers…

And I miss the i3 setup I have on Debian.