Answers:
您可以使用在线文档。
curl "http://man.he.net/?topic=<command_name>§ion=all"
。用<command_name>
您要查找的命令替换
您可以在Git的bash环境中使用手册页,但是考虑花费较少工作的其他替代方法可能更方便。
我也没有的超级用户多的代表,所以我很伤心地说,我真的不能给所有我需要在响应中的链接。我在Tumblr上重新发布了我的回复。
综上所述:
祝好运。
MinGW-get install msys-man
。Man还可以作为Windows二进制文件获得:sourceforge.net/projects/ezwinports/files(可通过FAQ找到:mingw.org/wiki/FAQ#toc10)。该页面也有污点。两者可能都比那些脚本运行得快。
我将其他一些答案拼凑在一起,以获得man
可以像本机一样使用的命令。只要坚持在你的下面.bashrc
,并且要么source
它,或重新打开终端。
function man {
local section=all
if [[ "$1" =~ ^[0-9]+$ ]]; then section="$1"; shift; fi
local doc="$(curl -v --silent --data-urlencode topic="$@" --data-urlencode section="$section" http://man.he.net/ 2>&1)"
local ok=$?
local pre="$(printf '%s' "$doc" | sed -ne "/<PRE>/,/<\/PRE>/ { /<PRE>/ { n; b; }; p }")"
[[ $ok -eq 0 && -n "$pre" ]] && printf '%s' "$pre" | less || printf 'Got nothing.\n' >&2
return $ok
}
它还支持请求特定的man节,例如man 3 printf
用于系统调用。
缺点:源(man.he.net)并非完全是RESTful API,即使什么也没找到,它仍会返回200,因此很难给出准确的错误消息。取而代之的是,无论问题出在哪里,它都只会打印“一无所有”。这可能可以改善。另外,结果页面包含html实体,例如<
而不是<
,这使某些用法字符串很难看。
除了Sathya的答案,您还可以在Windows的bash中执行此操作:
curl -v --silent "http://man.he.net/?topic=<command_name>§ion=all" 2>&1 | sed -n "/<PRE>/,/<\/PRE>/p"
只需用<command_name>
您要查找的命令替换。
命令的示例输出ls
:
<PRE>提要ls [OPTION] ... [FILE] ...
描述列出有关FILE的信息(默认为当前目录)。如果未指定-cftuvSUX和--sort,则按字母顺序对条目进行排序。
Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them. E.g., `--block-size=M' prints sizes in units of 1,048,576 bytes. See SIZE format below. -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime, newest first -C list entries by columns --color[=WHEN] colorize the output. WHEN defaults to `always' or can be `never' or `auto'. More info below -d, --directory list directory entries instead of contents, and do not derefer- ence symbolic links -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -ls --color -F, --classify append indicator (one of */=>@|) to entries --group-directories-first group directories before files. augment with a --sort option, but any use of --sort=none (-U) disables grouping -G, --no-group in a long listing, don't print group names -h, --human-readable with -l, print sizes in human readable format (e.g., 1K 234M 2G) --si likewise, but use powers of 1000 not 1024 -H, --dereference-command-line follow symbolic links listed on the command line --dereference-command-line-symlink-to-dir follow each command line symbolic link that points to a direc- tory --hide=PATTERN do not list implied entries matching shell PATTERN (overridden by -a or -A) --indicator-style=WORD append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F) -i, --inode print the index number of each file -I, --ignore=PATTERN do not list implied entries matching shell PATTERN -k like --block-size=1K -l use a long listing format -L, --dereference when showing file information for a symbolic link, show informa- tion for the file the link references rather than for the link itself -m fill width with a comma separated list of entries -n, --numeric-uid-gid like -l, but list numeric user and group IDs -N, --literal print raw entry names (don't treat e.g. control characters spe- cially) -o like -l, but do not list group information enclose entry names in double quotes --quoting-style=WORD use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape -r, --reverse reverse order while sorting -R, --recursive list subdirectories recursively -s, --size print the allocated size of each file, in blocks -S sort by file size --sort=WORD sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v --time=WORD with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status -c; use specified time as sort key if --sort=time --time-style=STYLE with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like `date'; if FORMAT is FORMAT1<newline>FORMAT2, FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with `posix-', STYLE takes effect only outside the POSIX locale -t sort by modification time, newest first -T, --tabsize=COLS assume tab stops at each COLS instead of 8 -u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time -U do not sort; list entries in directory order -v natural sort of (version) numbers within text -w, --width=COLS assume screen width instead of current value -x list entries by lines instead of by columns -X sort alphabetically by entry extension -Z, --context print any SELinux security context of each file Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.
退出状态:0,如果正常,
1 if minor problems (e.g., cannot access subdirectory), 2 if serious trouble (e.g., cannot access command-line argument).
作者由Richard M. Stallman和David MacKenzie撰写。
报告错误将错误报告到bug-coreutils@gnu.org GNU coreutils主页:< http://www.gnu.org/software/coreutils/> ; 使用GNU软件的一般帮助:< http://www.gnu.org/gethelp/> ; 向< http://translationproject.org/team/> ; 报告ls翻译错误;
版权版权所有(C)2011自由软件基金会,Inc.许可的GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>。这是免费软件:您可以自由更改和重新分发它。在法律允许的范围内,没有任何担保。
还请参见ls的完整文档作为Texinfo手册进行维护。如果在您的站点上正确安装了info和ls程序,则该命令
info coreutils 'ls invocation' should give you access to the complete manual.
GNU coreutils 8.12.197-032bb 2011年9月
<STRONG> <A HREF="/man1/LS"> LS(1)</A> </ STRONG> </ PRE>
在bash窗口中为您提供命令信息。
Git命令快速参考
git [command] -help
在浏览器中打开命令的在线信息。
Git命令手册页
git help [command] git [command] --help
如果有人尝试man
在Windows上工作并使用Msys2,则发现以下内容:
我通过使用上面的回答说非常接近,即安装groff
(可通过pacman获得),然后在此处使用脚本,该脚本的核心是对的调用groff -Tascii -mandoc -P-c
。
但是,除非我先解压缩gz文件,否则我无法将其用于我的手册页(位于中/usr/share/man
)。
这不是可接受的解决方案,所以我进一步看了看,发现通过运行
pacman -Ss -man
(当前)有三个带有“ man-”前缀的软件包。(在这里看到他们)。
我尝试了一个名为man-db的方法,它可以工作,现在我可以man
按常规预期的方式运行。
pacman -S man
按期望的方式简单地运行和安装收益
将其添加到 .bashrc
C:\Users\<Username>\.bashrc
function man() {
VAR1="http://man.he.net/?topic="
VAR2=$1
VAR3="§ion=all"
VAR4="$VAR1$VAR2$VAR3"
curl -v --silent "$VAR4" 2>&1 | sed -n "/<PRE>/,/<\/PRE>/p"
}
将其添加到 .bash_profile
C:\Users\<Username>\.bash_profile
# Read .bashrc
source ~/.bashrc
重新启动终端。
man find
将返回的手册页find
。
这是一个简短答案的版本:
function man-short() {
$1 --help
}