Calaf
Calaf

Reputation: 10817

Emacs: How to read command help just as one would read Man pages?

It's nice to run M-x man foo for command foo within Emacs. It's then possible to navigate easily within the man page and to find details quickly.

When the help of a command (such as git) produces limited output, one can just use a terminal instead of emacs.

But occasionally, a command (such as aws help—run in a terminal) produces extensive output. Yet the output is not compatible with the emacs Man mode. An option is to use M-x shell within emacs, but that will not display the page at once. It will report "WARNING: terminal is not fully functional" and require pressing a key endlessly until the complete help appears, or, for Emacs 25, "Could not find executable named 'groff'".

What is a good way to read long manual pages produced by commands within emacs?

Upvotes: 2

Views: 460

Answers (3)

doug
doug

Reputation: 381

I just ran into this exact problem a few days ago.

Type escape + ! then type (for example) “aws ec2 help”. This brings the help text into a new buffer called Shell Command Output, with all of the control-h characters, etc.

Switch to the new buffer with control-x then lowercase ‘o’ (for other buffer)

Type escape + lowercase ‘x’ to run an emacs function, then type ‘man’ and hit Enter. It will prompt for man page entry and default to EC2, just hit Enter. In my case, it displays an error in the status line, “error in process sentinel: Can’t find the EC2 manpage”.

However, the “man page” functions are now available, so now (in that buffer)you can type escape + x and run the function Man-fontify-manpage. The page should now look like a nice man page with bold, etc.

You can then rename the buffer (escape + x then something like ec2) so the buffer isn’t replaced if you run another shell command.

Upvotes: 1

juanleon
juanleon

Reputation: 9380

If you want the output in a shell buffer, you can do git help commit | cat (so no more "terminal is not fully functional").

Probably you can do M-! aws help | cat RET also. I do not have aws, but hopefully the piping will remove the escape characters if aws output formatting is done right. You should try also TERM=dumb aws help. Any command should know better than using fancy output when TERM is set to dumb. If aws is dumb that way itself, you could pipe its output to something that filters out control characters -- try this

For forcing man mode in an arbitrary buffer, M-x Man-mode (yes, uppercase). I am not sure if that will play nice with aws's output.

By the way, for git I suppose you know you can do man git-commit (or man git-any_git_command, in general), so you have a nice alternative to git help when using emacs (output of help and man page is the same).

Upvotes: 0

phils
phils

Reputation: 73274

I you just want the output in a buffer, you can simply use:
M-! aws help RET

Upvotes: 0

Related Questions