16

In bash, I can use the help command to print a synopsis for a specific builtin command

$ help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.
Options:
  -L    print the value of $PWD if it names the current working
        directory
  -P    print the physical directory, without any symbolic links

By default, `pwd' behaves as if `-L' were specified.

Exit Status:
Returns 0 unless an invalid option is given or the current directory
cannot be read.

Is there an equivalent in zsh, or do I just use man zshbuiltins?

glenn jackman
  • 26,306

3 Answers3

14

As indicated in the Stack Overflow question in @DavidPostill's comment, put this into ~/.zshrc:

unalias run-help
autoload run-help
HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help
alias help=run-help

If you're on macOS and installed using Homebrew, then you will want to replace the HELPDIR line with this:

HELPDIR=$(command brew --prefix)/share/zsh/help
Lucas
  • 125
glenn jackman
  • 26,306
1

I wanted to see what zsh said about : The noop builtin.

Here's a little hack that worked:

man zshbuiltins |& awk '/^ *:/,/^$/'

I am running the command man zshbuiltins and using an awk range-based regex to print the line that begins with : (possibly with preceeding whitespace) and ends with a blank newline.

0

Append this in your ~/.zshrc file

function help(){
    bash -c "help $@"
}
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Sep 28 '23 at 16:55
  • I thought it was obvious from context, but if I'm in zsh I don't want to read bash help, I want zsh help. – glenn jackman Sep 28 '23 at 22:09
  • I think this was intended as a joke. – 5fec Jan 29 '24 at 13:36