HomeAboutPostsTagsProjectsRSS

macos

Updated
Words440
TagsRead2 minutes

In macOS, I’ve configured a variety of shortcuts to automate tasks, for example:

  • Appending selected text to a specified Obsidian note.
  • Opening a prompt menu and sharing the selected text with ChatGPT to obtain results.
  • Extracting text from an image to read in an editor.
  • And many others.

I frequently use these actions on both my iPhone and Mac. However, on macOS, I find myself having to manually navigate through the Services menu to activate these actions, which tends to slow down my workflow.

To streamline this process, I’ve developed a script that automatically triggers a Services menu item whenever I select text and press Command + Right Click. This enhancement significantly speeds up my interaction with macOS, making my workflow more efficient.

[[Hammerspoon]] script

-- Ensure the listener is global to avoid garbage collection issues
MouseListener = hs.eventtap.new({ hs.eventtap.event.types.rightMouseDown }, function(e)
  local buttonPressed = e:getProperty(hs.eventtap.event.properties.mouseEventButtonNumber)
  local cmdPressed = e:getFlags().cmd

  if cmdPressed == true then
    -- AppleScript to open the Services menu
    -- https://stackoverflow.com/a/59330902/22903883
    hs.osascript.applescript([[
tell application "System Events"
    set appName to item 1 of (get name of processes whose frontmost is true)
    tell (process 1 where frontmost is true)
        tell menu bar 1
            tell menu bar item appName
                tell menu appName
                     tell menu item "Services"
                          tell menu "Services"
                            click menu item "GPT: Share"
                          end tell
                     end tell
                end tell
            end tell
        end tell
    end tell
end tell]])
    return true -- Consume the right-right-click
  end

  return false
end)

-- Start the event listener
MouseListener:start()

Updated
Words1801
TagsRead4 minutes

display

System Settings > Accessibility > Display > Turn On Reduce Motion

modifier key

  • change to ^
  • caps lock change to

finder

# show hidden files
defaults write com.apple.finder AppleShowAllFiles YES

# show path bar
defaults write com.apple.finder ShowPathbar -bool true

killall Finder;

brew

install brew

Quick Look plugins

brew install --cask \
    qlcolorcode \
    qlstephen \
    qlmarkdown \
    quicklook-json \
    qlprettypatch \
    quicklook-csv \
    betterzip \
    webpquicklook \
    suspicious-package

applications

brew install --cask \
    appcleaner \
    google-chrome \
    iterm2 \    
    raycast \
    visual-studio-code

command line tools

# [Nerd Font](https://www.nerdfonts.com/)
brew install --cask font-fira-code-nerd-font

brew install \
    bat \
    fish \
    git \
    git-delta \
    go \
    hugo \
    jq \
    neofetch \
    orbstack \
    ripgrep \
    starship \
    tree \
    wget

git

git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.ss status

git-delta

~/.gitconfig

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true    # use n and N to move between diff sections
    light = false      # set to true if you're in a terminal w/ a light background color (e.g. the default macOS terminal)

[merge]
    conflictstyle = diff3

[diff]
    colorMoved = default

fish shell

starship preset nerd-font-symbols -o ~/.config/starship.toml

add to ~/.config/fish/config.fish

# Add HomeBrew's bin directory to path so you can use HomeBrew's binaries like `starship`
# Fish uses `fish_add_path` instead of `export PATH` modify $PATH.
fish_add_path "/opt/homebrew/bin/"
# Enable Starship prompt
starship init fish | source

Package manager

fisher

plugin:

abbreviation

add to ~/.config/fish/config.fish

source ~/.config/fish/abbreviation.fish

create abbreviation.fish

abbr proxyall "set --export http_proxy http://127.0.0.1:7890; set --export https_proxy http://127.0.0.1:7890"

custom function

it’s very easy to add a custom function in fish shell, an example

Visual Studio Code

Settings

Side Bar:Location change to right

extensions

  • Auto Hide
  • AutoTrim
  • Emacs Friendly Keymap
  • Indenticator
  • Sort lines
  • vscode-icons

Python

use pyenv to manage Python environments, don’t reply on the python installed by brew, because it might update Python version upexpecetdly when performs brew update.

brew install readline xz pyenv
# otpinal: setup pyenv with fish shell
alias brew="env PATH=(string replace (pyenv root)/shims '' \"\$PATH\") brew"
exec "$SHELL"

pyenv install 3.11.6
pyenv global 3.11.6

Reference

Terminal emulator

iTerm2

Keyboard setting

Use fn to Change Input Source

Keyboard Shortcuts -> Uncheck all Input Sources Spotlight

Apple Internal Keyboard

Keyboard Shortcuts -> Modifier Keys

  • Caps Lock Key -> Command
  • Command -> Control

External Keyboard

Keyboard Shortcuts -> keep Modifier Keys unchanged

Karabiner-Elements

  • left_command -> left_control
  • left_control -> left_command
  • right_command -> right_control
  • right_option -> fn

Make Caps Lock → Hyper Key (⌃⌥⇧⌘) (Caps Lock if alone) import

Tiling Windows Manager

  • yabai (no need to disable System Integrity Protection)
  • skhd

yabai installation and configuration reference:

skhd config

cmd + ctrl + shift + alt is the Hyper Key configurated using Karabiner-Elements

# change focus between external displays (left and right)
cmd + ctrl + shift + alt - p : yabai -m display --focus west
cmd + ctrl + shift + alt - n : yabai -m display --focus east

# fullscreen window
cmd + ctrl + shift + alt - m : yabai -m window --toggle zoom-fullscreen

# cycle focus between windows
cmd + ctrl + shift + alt - o : yabai -m window --focus prev || yabai -m window --focus last
# cycle swap window to the main window
cmd + ctrl + shift + alt - j : /bin/bash ~/bin/cycle_clockwise.sh; yabai -m window --focus prev || yabai -m window --focus last

# rotate layout clockwise
cmd + ctrl + shift + alt - r : yabai -m space --rotate 270
# flip along y-axis
cmd + ctrl + shift + alt - y : yabai -m space --mirror y-axis
# flip along x-axis cmd + ctrl + shift + alt - x : yabai -m space --mirror x-axis
# toggle window float
cmd + ctrl + shift + alt - f : yabai -m window --toggle float --grid 4:4:1:1:2:2

cycle_clockwise.sh:

#!/bin/bash

win=$(yabai -m query --windows --window last | jq '.id')

while : ; do
    yabai -m window $win --swap prev &> /dev/null
    if [[ $? -eq 1 ]]; then
        break
    fi
done

Updated
Words798
TagsRead1 minute

Overview

This guide provides step-by-step instructions for installing and enabling content caching for a macOS virtual machine (VM) in Proxmox.

Install a macOS VM

Follow the tutorial here to install a macOS VM in Proxmox.

Enable Content Caching

If you encounter difficulties enabling content caching through the Sharing menu, follow the instructions provided here .

Registration

If you are unable to register and receive a “Content Caching is temporarily unavailable” message, follow these steps:

  1. Post-install OpenCore configuration.
  2. Fix GenSMBios by following the steps here .
  3. Fix en0 by verifying en0 as build-in. Details can be found here .

Image: en0

  1. Fix ROM by following the steps here .

  2. Reboot your VM and verify the content caching status.

    Reboot and verify the content caching status, you should be seen Activated: true and Active: true

> AssetCacheManagerUtil status

Content caching status:
    Activated: true
    Active: true
    ActualCacheUsed: 2.79 GB
    CacheDetails: (3)
        iCloud: 23.86 GB
        Mac Software: 211.7 MB
        Other: 701.7 MB
    CacheFree: 14.28 GB
    CacheLimit: 45 GB
    CacheStatus: OK
    CacheUsed: 24.77 GB

Image: Content Caching Status

For additional information and discussion, refer to the Reddit post .