前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >TLDR,一个简易版的命令查询手册

TLDR,一个简易版的命令查询手册

作者头像
HaC
发布2022-05-20 09:34:53
6980
发布2022-05-20 09:34:53
举报
文章被收录于专栏:HaC的技术专栏HaC的技术专栏

Linux系统拥有丰富的命令,一切基于命令操作。

但是要记住所有的命令,任何人可能都无法完成,其次,Linux的命令都带有十分多的参数。

比如我平时百度得最多的是 tar 命令,虽然我知道它是解压缩用的,但你直接用的时候就蒙圈了。

缺少参数的后果:

代码语言:javascript
复制
[root@VM-8-8-centos software]# tar zookeeper-3.4.11.tar.gz
tar: Old option `g' requires an argument.
Try `tar --help' or `tar --usage' for more information.

为了解决这个问题,人们创建了手册页man page,(手册 —— man 是 manual 的缩写,一个Linux命令使用手册)。

但是man手册,实在是太长了:

代码语言:javascript
复制
[root@VM-8-8-centos software]# man tar
TAR(1)                                                   User Commands                                                   TAR(1)

NAME
       tar - manual page for tar 1.26

SYNOPSIS
       tar [OPTION...] [FILE]...

DESCRIPTION
       GNU  `tar'  saves  many files together into a single tape or disk archive, and can restore individual files from the ar‐
       chive.

       Note that this manual page contains just very brief description (or more like a list of possible  functionality)  origi‐
       nally generated by the help2man utility.  The full documentation for tar is maintained as a Texinfo manual.  If the info
       and tar programs are properly installed at your site, the command `info tar' should give you access to the complete man‐
       ual.

EXAMPLES
       tar -cf archive.tar foo bar
              # Create archive.tar from files foo and bar.

       tar -tvf archive.tar
              # List all files in archive.tar verbosely.

       tar -xf archive.tar
              # Extract all files from archive.tar.

蒙圈plus,都怪我英语太菜了。

看到这样的文档,我还是宁愿百度……

直到后来我用了TLDR,百度的频率就大大减少了。

1、TLDR

为了舍弃man手册,于是程序员大神们搞了很多个工具,比如TLDR、Bro、Cheat ,这些都是很简洁的命令手册。

其中我最喜欢的还是 TLDR

项目地址:https://github.com/tldr-pages/tldr

tl;dr 是一个网络词汇,它的全称是「Too Long; Don’t Read」,翻译成中文的话就叫**「太长不看」**。

(所以文章也是一样,又长又臭就没人看了🤣)

TLDR区别于man手册的区别:

  • 简洁,清晰的排版+言简意赅的说明
  • 只收集高频使用的实际例子
  • 缺点是没有man手册全面,但目前一直在更新

TLDR 安装也很简单,支持 nodepython 安装

node:

代码语言:javascript
复制
npm install -g tldr

python:

代码语言:javascript
复制
pip3 install tldr

2、使用

TLDR 的用法比较简单,可以使用 tldr --help 查看用法。

代码语言:javascript
复制
Options:
  -v, --version            output the version number
  -l, --list               List all commands for the chosen platform in the cache
  -a, --list-all           List all commands in the cache
  -1, --single-column      List single command per line (use with options -l or -a)
  -r, --random             Show a random command
  -e, --random-example     Show a random example
  -f, --render [file]      Render a specific markdown [file]
  -m, --markdown           Output in markdown format
  -o, --os [type]          Override the operating system [linux, osx, sunos]
  --linux                  Override the operating system with Linux
  --osx                    Override the operating system with OSX
  --sunos                  Override the operating system with SunOS
  -t, --theme [theme]      Color theme (simple, base16, ocean)
  -s, --search [keywords]  Search pages using keywords
  -u, --update             Update the local cache
  -c, --clear-cache        Clear the local cache
  -h, --help               display help for command

以上用法太长不看,直接使用 tldr 命令

默认就是当前系统下的使用用法,如果要查看其他系统的用法,可以- o指定。

查看windows下的tar用法:

代码语言:javascript
复制
tldr tar -o windows

查看当前系统下的tar用法:

代码语言:javascript
复制
tldr tar

虽然也是英语的,但是说明简洁、例子也是最常用的,而且带有高亮,看起来会很方便。

官网说这个项目会根据系统的语言切换,但我试了一下windows CMD没有成功, git bash 命令模式下才成功显示中文,它是根据你的终端语言决定的。

3、总结

虽然现在没什么人喜欢使用 man手册、-- help 查看命令的用法,但是网上也有很多Linux手册可以直接查看,也是一种不错的选择。

但对其中一些程序员,包括我,能在终端解决的事情,是不会再新开浏览器窗口的,毕竟它一不小心就打断我写代码的思路了。

安装 TLDR 也就一个命令行的事情,相比man手册简洁了许多。

在使用的时候,看一下参数的说明,相比直接百度复制,印象会更深刻,假以时日,相信你连 TLDR 都不用看了。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-05-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、TLDR
  • 2、使用
  • 3、总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档