MacOS tips

Created on Sun, 06 Oct 11:32AM

Last changed on 2023-01-27 20:37:24

Restart mac network with specific interface

sudo ifconfig en7 down
sudo ifconfig en7 up

Preventing slee when close the lid

# 禁止自动睡眠
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1
# 恢复关盖睡眠
sudo pmset -b sleep 5; sudo pmset -b disablesleep 0

Sudo with Touch ID

# /etc/pam.d/sudo
sudo gsed -i '1aauth	   sufficient 	  pam_tid.so' /etc/pam.d/sudo
sudo sed -i '' -e '1a\
auth       sufficient     pam_tid.so' /etc/pam.d/sudo #sudo touch id

Check listen port

sudo lsof -i -P | grep -i "listen"

Nmap or nc check

nc -zv [host-name/ip] [port(s)]

iTerm2 zmodem

zsh <(curl -sSL https://github.com/Junyangz/iterm2-zmodem/raw/master/iterm2-zmodem.sh)

Git user base on remote url

# ~/.gitconfig, need git version >= 2.36
[includeIf "hasconfig:remote.*.url:git@github.com*/**"]
# [includeIf "hasconfig:remote.*.url:https://github.com*/**"] # for https
	path = ~/.gitconfig-github

MacOS remove quarantine

xattr -d -r com.apple.quarantine /Applications/xxx.app # or xxx binary

Other assets

Last updated