Skip to content

Latest commit

 

History

History
99 lines (74 loc) · 3.09 KB

macos.md

File metadata and controls

99 lines (74 loc) · 3.09 KB

Notes relating macOS

macOS Shortcuts

Key Function
cmd + ` (grave accent) switch between windows of a same program

Shortcut List

BSD Bash Usage

Display disk usage statistics sorted by human readable numbers (ref)

# use GNU sort which supports the missing option "-h"
$ du -hd 1 | gsort -h

Open man page in new terminal window (ref)

$ open x-man-page://<name>
  • zip and unzip
    # dry run, list files
    unzip -l file.zip
    
    # unzip specific file
    unzip file.zip path/to/file.txt     # this will create "./path/to/file.txt"
    
    # unzip specific file and drop directory structures in archive
    unzip -j file.zip path/to/file.txt  # this will create "./file.txt"

Homebrew

brew CLI program

https://docs.brew.sh/Manpage

Writing formulae and casks

GNU, instead of BSD CLI Tools

  • Show dependencies as a tree: brew deps --tree <formula>
Name Homebrew formula
ggrep brew info grep
gsed brew info gnu-sed
gsort brew info coreutils

Where do PATHs come from

  1. /etc/profiles
  2. /usr/libexec/path_helper -s
  3. /etc/paths + file lines under /etc/paths.d
  4. shell profiles (e.g., zsh startup files) see ref

Zsh

Remove duplicates in zsh history (ref)

cat -n $HISTFILE | sort -t ';' -uk2 | sort -nk1 | cut -f2- > .zsh_short_history