对于很多使用终端的Linux和Mac用户,使用Terminal最难的就是要记住众多的Linux命令了。比如:ssh
,curl
,grep
等,经常会记不住参数的顺序。这个时候通常在使用的时候通过man阅读长长的文档,从中对比一个个参数,这样费时又费力。
今天要介绍的一个好用的工具叫tldr
,tldr全称Too long, Don’t read,翻译成中文就是[太长不读]。tldr
根据二八原则将命令的常用场景给出示例,让人一看就懂。
tldr项目地址: https://github.com/tldr-pages/tldr
tldr安装
tldr有很多种语言版本,安装也很简单,各种包管理工具都支持。
安装方式如下
C++ client
1 | $ brew install tldr-pages/tldr/tldr |
Crystal client
1 | $ brew install porras/tap/tlcr |
Go client
1 | $ go get github.com/pranavraja/tldr (or platform binaries) |
Node.js client
1 | $ npm install -g tldr |
Perl5 client
1 | $ cpanm App::tldr |
Python clients
- tldr-python-client
1 | $ pip install tldr |
1 | $ pip install tldr.py |
Ruby client
1 | $ gem install tldrb |
Bash client
1 | https://github.com/raylee/tldr |
Web client
1 | https://ostera.github.io/tldr.jsx |
Android clients
- tldr-viewer, available on Google Play
1 | https://github.com/gianasista/tldr-viewer |
- tldroid, available on Google Play
1 | https://github.com/hidroh/tldroid |
iOS clients
- tldr-man-page, available on App Store
1 | https://github.com/freesuraj/TLDR |
- tldr-pages, available on App Store
1 | https://github.com/mflint/ios-tldr-viewer |
更多客户端可参考: https://github.com/tldr-pages/tldr
tldr使用
tldr命令格式
1 | $ tldr -h |
来看几个例子
1 | $ tldr ssh |
$ tldr curl
# curl
Transfers data from or to a server.
Supports most protocols including HTTP, FTP, POP.
- Download a URL to a file:
curl "URL" -o filename
- Send form-encoded data:
curl --data name=bob http://localhost/form
- Send JSON data:
curl -X POST -H "Content-Type: application/json" -d '{"name":"bob"}' http://localhost/login
- Specify an HTTP method:
curl -X DELETE http://localhost/item/123
- Head request:
curl --head http://localhost
- Include an extra header:
curl -H "X-MyHeader: 123" http://localhost
- Pass a user name and password for server authentication:
curl -u myusername:mypassword http://localhost
怎么样,比man看起来舒服多了吧?还等什么,赶紧上手体验一下吧!
参考文档
http://www.google.com
https://github.com/tldr-pages/tldr
https://codingstyle.cn/topics/26