当你熟悉命令,但是无论出于何种原因都希望使用常见示例而不是详细的手册页时,是否想需要个比man <command>更有用的帮助手册。也许平时你100%依靠Google来找到适合您的CLI参数。
这里介绍给好用的工具cheat(俗称小抄?)。
cheat(https://github.com/cheat/cheat)是个这样的工具,帮助文档用常用的示例给出。这些帮助文档可以来源互联网社区(比如https://github.com/cheat/cheatsheets),也可以根据个人平时总结生成帮助菜单。
cheat是用golang语言编写。所以使用go的在线安装命令
tar -zxvf pandoc-2.10.1-linux-amd64.tar.gz //安装依赖pandoc
cd pandoc-2.10.1/bin
cp pandoc /usr/local/bin/
go get -u -v https://github.com/cheat/cheat.git
注意下这里go用1.14版本可以安装,用1.12没安装成功
初始化环境
mkdir -p ~/.config/cheat && cheat --init > ~/.config/cheat/conf.yml
初始化后,进行下载,互联网文档放在这个目录:
~/.config/cheat/cheatsheets/community/
而个人创建的放在这个目录:
~/.config/cheat/cheatsheets/personal/
cheat tar
会给出以下的提示,是不是比man简洁好多,而且更实用
# To extract an uncompressed archive:
tar -xvf '/path/to/foo.tar'
# To extract a .gz archive:
tar -xzvf '/path/to/foo.tgz'
# To create a .gz archive:
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'
# To extract a .bz2 archive:
tar -xjvf '/path/to/foo.tgz'
# To create a .bz2 archive:
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'
要查看备忘单:
cheat tar # a "top-level" cheatsheet
cheat foo/bar # a "nested" cheatsheet
编辑备忘单:
cheat -e tar # opens the "tar" cheatsheet for editing, or creates it if it does not exist
cheat -e foo/bar # nested cheatsheets are accessed like this
要查看配置的cheat路径:
cheat -d
列出所有可用的备忘单:
cheat -l
列出所有标记有“networking”的备忘单:
cheat -l -t networking
要列出“个人”路径上的所有备忘单:
cheat -l -p personal
在备忘单中搜索短语“ ssh”:
cheat -s ssh
要搜索(通过正则表达式)包含IP地址的备忘单,请执行以下操作:
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
可以以直观的方式组合标志。示例:在“个人”cheat路径上搜索标记有“networking”并匹配正则表达式的工作表:
cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
http://cheat.sh/是一个更方便的网站。
当查询某个命令(比如ls)可以这样使用
curl cheat.sh/ls
当然也可以浏览器打开:
还有像很多类似工具:
tldr(https://tldr.sh/)
navi,https://github.com/denisidoro/navi
mnemonic, https://github.com/codesections/mnemonic
也许还有更多类似的工具。
但是,啥时候会将这些示例添加到man手册页中呢?比如有个命令,只打印手册页的EXAMPLES部分。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。