简介
在大家日常在 macOS/Linux 上使用 Shell 的时候,常常会遇到一些不太熟悉的命令行指令,为此我们一般会查看一下该命令的使用手册(指南)。往往,大家都会使用 man <command>
这样一个非常传统的指令。但 man
也有一些缺点,比如显示的信息过于冗余等。
其实,GitHub 上有一个几乎完美的命令行手册显示工具,叫做 tldr
。它能够提供比 man
简介明了多的说明。
tldr
项目地址:https://github.com/tldr-pages/tldr
(注:本文同时适用于 macOS 和 Linux)
想看看效果的话,可以看看这个例子。
举例
拿 unar
举个例子:
(顺便说一句,只能拿小的命令来举例,要不然 man
就会输出几千行几万行)
使用 man unar
:
unar(1) User Commands unar(1)
NAME
unar - extract archive file contents
SYNOPSIS
unar [OPTION]... ARCHIVE [FILE]...
DESCRIPTION
Extract FILEs or the contents of ARCHIVE.
OPTIONS
-o, -output-directory DIRECTORY
The directory to write the contents of the archive to. Defaults
to the current directory.
-f, -force-overwrite
Always overwrite files when a file to be unpacked already exists
on disk. By default, the program asks the user if possible,
otherwise skips the file.
-r, -force-rename
Always rename files when a file to be unpacked already exists on
disk.
-s, -force-skip
Always skip files when a file to be unpacked already exists on
disk.
-d, -force-directory
Always create a containing directory for the contents of the
unpacked archive. By default, a directory is created if there
is more than one top-level file or folder.
-D, -no-directory
Never create a containing directory for the contents of the
unpacked archive.
-p, -password PASSWORD
The password to use for decrypting protected archives.
-e, -encoding ENCODING
The encoding to use for filenames in the archive, when it is not
known. If not specified, the program attempts to auto-detect
the encoding used. Use "help" or "list" as the argument to give
a listing of all supported encodings.
-E, -password-encoding ENCODING
The encoding to use for the password for the archive, when it is
not known. If not specified, then either the encoding given by
the -encoding option or the auto-detected encoding is used.
-i, -indexes
Instead of specifying the files to list as filenames or wildcard
patterns, specify them as indexes, as output by lsar.
-nr, -no-recursion
Do not attempt to extract archives contained in other archives.
For instance, when unpacking a .tar.gz file, only unpack the
.tar file and not its contents.
unar(1) User Commands unar(1)
NAME
unar(1) User Commands unar(1)
NAME
unar - extract archive file contents
SYNOPSIS
unar [OPTION]... ARCHIVE [FILE]...
DESCRIPTION
Extract FILEs or the contents of ARCHIVE.
OPTIONS
-o, -output-directory DIRECTORY
The directory to write the contents of the archive to. Defaults
to the current directory.
-f, -force-overwrite
Always overwrite files when a file to be unpacked already exists
on disk. By default, the program asks the user if possible,
otherwise skips the file.
-r, -force-rename
Always rename files when a file to be unpacked already exists on
disk.
-s, -force-skip
Always skip files when a file to be unpacked already exists on
disk.
-d, -force-directory
Always create a containing directory for the contents of the
unpacked archive. By default, a directory is created if there
is more than one top-level file or folder.
-D, -no-directory
Never create a containing directory for the contents of the
unpacked archive.
-p, -password PASSWORD
The password to use for decrypting protected archives.
-e, -encoding ENCODING
The encoding to use for filenames in the archive, when it is not
known. If not specified, the program attempts to auto-detect
the encoding used. Use "help" or "list" as the argument to give
a listing of all supported encodings.
-E, -password-encoding ENCODING
The encoding to use for the password for the archive, when it is
not known. If not specified, then either the encoding given by
the -encoding option or the auto-detected encoding is used.
-i, -indexes
Instead of specifying the files to list as filenames or wildcard
patterns, specify them as indexes, as output by lsar.
-nr, -no-recursion
Do not attempt to extract archives contained in other archives.
For instance, when unpacking a .tar.gz file, only unpack the
.tar file and not its contents.
-t, -copy-time
Copy the file modification time from the archive file to the
containing directory, if one is created.
-k, -forks visible|hidden|skip
How to handle Mac OS resource forks. visible creates
AppleDouble files with the extension ".rsrc", hidden creates
AppleDouble files with the prefix "._", and skip discards all
resource forks. Defaults to visible.
-q, -quiet
Run in quiet mode.
-v, -version
Print version and exit.
-h, -help
Display help information.
SEE ALSO
lsar(1)
The Unarchiver 2011-09-26 unar(1)
(END)
可以看出,真的是——长长长长长长长……
而且,大部分命令其实我们都不怎么需要。
再看看 tldr unar
:
unar
从归档文件中提取内容。
更多信息:https://manned.org/unar.
提取一个归档文件到当前目录:
unar 归档文件
提取一个归档文件到指定目录:
unar -o 路径/到/目录 归档文件
如果要提取的文件已经存在,则总是覆盖:
unar -f 归档文件
如果要提取的文件已经存在,则总是重命名:
unar -r 归档文件
如果要提取的文件已经存在,则总是跳过:
unar -s 归档文件
还适配中文,并且信息非常简单集中,十分人性化。
了解差距了吧?
使用方法
tldr
有三种最常用的方法来安装:
- npm 安装
npm install -g tldr
- Python pip 安装
pip3 install tldr
- Homebrew 安装
brew install tlrc
请大家注意,这些命令需要的环境可能没有预置在某些电脑上,这就需要你先去安装 Node.js、Python 3 或 Homebrew。本人有一些文章可供参考:
Node.js 的安装与使用(npm)
cnpm 的安装与使用
Python 更换 pip 源详细指南
Homebrew 安装与配置(macOS)
Homebrew安装与配置(Linux)
关于 Python 的安装,可以参考 Python 的官网(Python.org)。
其他更多操作,请参考项目地址上的说明。
本文完。
【开源 Mac 工具推荐】系列将会持续更新,关注我(YoungGeeker),一起探索少年极客的世界!
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » 【开源 Mac 工具推荐之 5】tldr:简洁明了的命令行手册显示工具
发表评论 取消回复