写代码写了五年这几个命令行工具我每天都在用用了就回不去的命令行效率工具。不卖关子直接上菜。以下是几个你可能没见过、但用了就回不去的命令行工具。1. fzf —— 模糊搜索万物皆可搜# 安装macOSbrewinstallfzf# Ubuntu/Debiansudoaptinstallfzf# 装完执行这个启用快捷键绑定$(brew--prefix)/opt/fzf/install三个最常用的姿势# CtrlT模糊搜索文件路径直接粘贴到命令行# 比如想打开一个深层目录的文件vim [按CtrlT] → 敲几个字母 → 回车# CtrlR模糊搜索历史命令比系统自带的CtrlR强十倍# 按CtrlR → 输入ssh → 所有包含ssh的历史命令都出来了# 搭配任意命令使用kill-9$(psaux|fzf|awk{print $2})# 模糊搜索进程并killcd$(find.-typed|fzf)# 模糊选目录并cd进去一句话从此告别反复 ls、反复按上下键。2. bat —— 带语法高亮的 catbrewinstallbat# macOSsudoaptinstallbat# Ubuntu命令可能是 batcat# 用 bat 替代 catbat 文件名.py效果代码高亮 行号 Git 修改标记比cat好看一百倍。顺便在你的.bashrc或.zshrc里加一行aliascatbat3. fd —— 比 find 快、比 find 简单的文件查找brewinstallfd-find# macOSsudoaptinstallfd-find# Ubuntu# find 的写法find.-name*.py-typef# fd 的写法fd\.py$# 按文件名搜默认正则自动忽略 .gitignore 里的文件fd UserModel# 搜到后执行命令fd\.js$-xwc-l# 统计所有 JS 文件行数默认支持正则、自动忽略.gitignore、彩色输出比find快一截。4. jq —— 命令行里的 JSON 手术刀brewinstalljq# macOSsudoaptinstalljq# Ubuntu你肯定遇到过这个场景curl一个 API返回一大坨 JSON 糊在终端上啥也看不清。# 格式化输出最基本的用法curl-shttps://api.github.com/repos/torvalds/linux|jq.# 提取特定字段curl-shttps://api.github.com/repos/facebook/react|jq.stargazers_count# → 输出228000# 过滤数组curl-shttps://api.github.com/repos/facebook/react/issues|jq.[] | {title: .title, user: .user.login}# 统计curl-shttps://api.github.com/repos/facebook/react/issues|jqlength# → 当前 open 的 issue 数量学会jq你就再也不用把 JSON 复制到 VS Code 里看了。5. tldr —— 太长不看的 man 手册npminstall-gtldr# 或者brewinstalltldr# man tar → 几千行没人看# tldr tar → 直接给出最常用的用法$ tldrtartarArchiving utility. Often combined with a compression method, such asgzipor bzip2. More information: https://www.gnu.org/software/tar. - Create an archive from files:tarcf{{target.tar}}{{file1 file2...}}- Extract a(compressed)archive into the current directory:tarxf{{source.tar[.gz|.bz2|.xz]}}- Create a compressed archive using gzip:tarczf{{target.tar.gz}}{{file1 file2...}}每个命令只列最实用的五六条用法附带清晰说明。真正的人话手册。总结工具一句话替代什么fzf模糊搜索一切CtrlR、反复 lsbat带高亮的 catcatfd更快更简单的 findfindjq命令行处理JSON复制到VS Code看tldr人话版命令手册man每天省 30 秒一年就是三个小时。三个小时拿来摸鱼不好吗作者青年编程