Mac terminal tricks

查看Manual

文档不会看,乐趣少一半!
# 模糊查询
man -k

# Bash 有指令 help <builtin> 查看内建指令文档
# Zsh 中 help 指令缺失,可以参考下列
unalias run-help
autoload run-help
HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help

help() {
tldr "$@" || run-help "$@" || curl "cheat.sh/$@" || "$@" --help
}

# the Z shell meta-man page;
man zshall
man zshbuiltins <a class='tag' href="/tags/Zsh">#Zsh</a> built-in functions
man zshexpn     <a class='tag' href="/tags/zsh">#zsh</a> expansion and substitution,includes String, RegExp
man zshmisc     <a class='tag' href="/tags/Loops">#Loops</a>, Function, if, pipeline, etc...
被忽略的指令 type,与 which 各有千秋
type -a <command> #显示所有路径
如 `type -a echo`,显示出 echo:builtin 和 /bin/echo。
compgen -b #显示内建指令列表
Zsh Cheatsheet

语音

say whatever you want to say

网络

traceroute www.example.com // 显示路由

dig 
www.example.com // 显示dns leave hhmm // 设定提示

touchID

echo "auth sufficient 
pam_tid.so" >> /etc/pam.d/sudo // 激活终端 sudo touchID

代理

# 需要手动配置 client 的路由,且把
sudo sysctl -w net.inet.ip.forwarding=1

mas

terminal 管理 appstore
mas list
mas outdated
mas upgrade <app_uuid>

# 
Homebrew integration # If mas is installed, and you run: brew bundle dump --global --force --describe # brew install brew bundle install

asciinema & agg

通过ASCII-nema创建终端操作的GIF展示文件,实现简单分享和展示。
# Record and share terminal sessions
asciinema
# some other commands
# Ctrl+D: quit and save record

# 重放
asciinema play /some/path/tmpxxxxx-ascii.cast

# Asciicast to GIF converter
agg chunk.cast yes.gif

sips

scriptable image processing system[1].
sips -s format png image.webp --out image.png

hyperfine

cli benchmark tools
hyperfine --shell zsh 'for i in {1..10000}; do echo test; done'

hyperfine --warmup 1 -i \
-n "biome" "npx @biomejs/biome lint" \
-n "eslint" "npx eslint ." \
-n "oxlint" "npx oxlint@latest"

Date:
Words:
474
Time to read:
2 mins