# MacOS tips

Created on Sun, 06 Oct 11:32AM

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

## Restart mac network with specific interface

```bash
sudo ifconfig en7 down
sudo ifconfig en7 up
```

## Preventing slee when close the lid

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

* [nosleep](https://github.com/integralpro/nosleep)

## Sudo with Touch ID

```bash
# /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

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

## Nmap or nc check

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

## iTerm2 zmodem

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

## Git user base on remote url

```properties
# ~/.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

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

## Other assets

* <https://github.com/hzlzh/Best-App>
* <https://mubu.com/doc/oeP76-2GF>
* <https://github.com/jaywcjlove/awesome-mac>
* <https://lemon.qq.com/lab/>
* <https://sspai.com/tag/Mac>
