Mac

Mostly for myself when setting up macOS. Make daily programming activity more productive.

Allow me to introduce a site before The main dish:

Original Macintosh - Anecdotes about the development of Apple’s original Macintosh, and the people behind it.

Symbol for keys:

Command (or Cmd) ⌘
Shift ⇧
Option (or Alt) ⌥
Control (or Ctrl) ⌃
Caps Lock ⇪
Fn

⌥+⇧+] for typing (instead of normal ').

Faster key response

I really cannot live without this.

defaults write -g KeyRepeat -int 2
defaults write -g InitialKeyRepeat -int 12

The lower the number, the faster it is.

KeyRepeat: 120, 90, 60, 30, 12, 6, 2
InitialKeyRepeat: 120, 94, 68, 35, 25, 15

Sudo with Touch ID

Add this line to /etc/pam.d/sudo:

auth       sufficient     pam_tid.so

AirPods Pro

HOWTO use it (Noise cancelling, mode switching, etc).

Fixing AirPods issue

This may help

killall coreaudio

Restart your computer or repair (Bluetooth).

Enable Audio Codec

For better headlphone performance.

sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
sudo defaults write bluetoothaudiod "Enable AAC codec" -bool true

On Paste

System Preferences > Keyboard > App Shortcuts > All Applications

add "Paste and Match Style" ⌘V
add "Paste" ⌘V

Context

Turn off preview thumbnail when taking Screenshot

⌘+⇧+5, options, turn off thumbnail.

Search in current folder

Show Hidden files

defaults write com.apple.finder AppleShowAllFiles YES

Open App from 3rd-party developer

defaults write /Library/Preferences/com.apple.security GKAutoRearm -bool NO

Touchbar

Turned on Expanded Control Strip & Remove Siri.

See this post.

Restart Touchbar

pkill "Touch Bar agent";
killall "ControlStrip";

Sign PDF by Preview

Fill out and sign PDF forms in Preview on Mac.

Shortcuts

⌃ + ⌘ + space to pull up emoji selection menu.

Orta’s Keyboard Shortcuts and Apple’s official guide.

Git & GitHub

My Git tips, please check Git.

GitHub

Install GitHub’s CLI (gh).

Change Your Name to yours.
Change your@mail.com to yours.

git config --global user.name "Your Name"
git config --global user.email "your@mail.com"
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lp local-push
git config --global color.ui true
git config --global url."git@github.com:".insteadOf "https://github.com/"
git config --global core.editor "subl -w"
git config --global core.excludesfile ~/.gitignore_global
git config --global diff.noprefix true
git config --global hub.protocol https

prefer git url

Add SSH key on GitHub

Change your@mail.com to yours.

ssh-keygen -t rsa -b 4096 -C "your@mail.com"
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_rsa
pbcopy < ~/.ssh/id_rsa.pub
open https://github.com/settings/keys

Softwares

Please see my /use page.

Visual Studio Code

Please see Visual Studio Code.

Sublime Text 3

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Oceanic Next Color Scheme with JetBrains Mono and Oxygen Mono font.

For more, please see my Sublime Text Tips.

Open file by editor on iTerm2

Zip sharing

$ zip -e file.zip file
Enter password:
Verify password:

Switch Keyboard Input Source

⌘+space

US keyboard setting to quickly switch to Japanese

Download Karabiner Elements, import rules for Japanese, then enable:

Search history for any readline based program

# ~/.inputrc
set show-all-if-ambiguous on
set completion-ignore-case on
set input-meta on
set output-meta on
set convert-meta off

"\e[5~": history-search-backward # fn + up
"\e[6~": history-search-forward # fn + down

Change computer & host name

https://support.apple.com/lt-lt/guide/mac-help/mchlp2322/mac

Convert mov to mp4

ffmpeg -i in.mov -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 out.mp4

Stop saving passwords to Browsers

Turn off the built-in password manager in your browser

Troubleshootings

MacBook Pro 16" 2019

Loom

Try ⌘ + ⌃ + c and see what happens :)