For many, many years now when I want to browse a man page about something I’ll type man X into my terminal, substituting X for whatever it is I wish to learn about. Depending on the manual, it’s short and therefore easy to find what I want, or I am deep in the woods because I’m trying to find a specific flag that appears many times in a very long document. Woe is me if the flag switch is a bare letter, like x.

And let’s say it is x. Now I am searching with /x followed by n n n n n n n n N n n n n n. Obviously I’m not finding the information I want, the search is literal (not fuzzy, nor “whole word”), and even if I find something the manual pager might overshoot me because finding text will move the found line to the top of the terminal, and maybe the information I really want comes one or two lines above.

So… there HAS to be a better way, right? There has to be a modern, fast, easily greppable version to go through a man page. Does it exist?

P.S. I am not talking about summaries like tldr because I typically don’t need summaries but actual technical descriptions.

  • @pr06lefs@lemmy.ml
    link
    fedilink
    36
    edit-2
    11 months ago

    Kind of off topic, but you know what would be cool? If you had an ‘man explain’ command that would define all the flags/args in a command, like:

    man explain rsync --append-verify --progress -avz -e "ssh -p 2222" root@$dip:/sdcard/DCIM/Camera newphonepix

    Would give you:

    rsync - a fast, versatile, remote (and local) file-copying tool
          --append-verify          --append w/old data in file checksum
          --progress               show progress during transfer
          --archive, -a            archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
          --verbose, -v            increase verbosity
          --compress, -z           compress file data during the transfer
          --rsh=COMMAND, -e        specify the remote shell to use 
    

    etc.

    • @thingsiplay@beehaw.org
      link
      fedilink
      911 months ago

      You can just grep the help output

      $ rsync --help 2>&1 | grep -E '^ *(--append-verify|--progress|--archive)'
      --archive, -a            archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
      --append-verify          --append w/old data in file checksum
      --progress               show progress during transfer
      

      So it should be possible to create a simple script to do that. Similarly one can output the man document as text to stdout, which in turn can be grepped. I have no grep command at hand to do this in a useful way:

      man grep | col -b
      
    • @gomp@lemmy.ml
      link
      fedilink
      811 months ago

      Here’s what I get in fish when I start writing a rsync command and hit tab to ask for completions:

      ❱ rsync --append-verify --progress -avz -
      -0  --from0                               (All *from/filter files are delimited by 0s)  --delete                   (Delete files that don’t exist on sender)
      -4  --ipv4                                                               (Prefer IPv4)  --delete-after         (Receiver deletes after transfer, not before)
      -6  --ipv6                                                               (Prefer IPv6)  --delete-before         (Receiver deletes before transfer (default))
      -8  --8-bit-output                          (Leave high-bit chars unescaped in output)  --delete-delay                 (Find deletions during, delete after)
      [more lines omitted]
      
    • @Majestix@lemmy.world
      link
      fedilink
      411 months ago

      There is a Plugin for Zsh (ohmyzsh) that gives you that right in the shell. I use it all the time and rely on it. Don’t have the name on my mind though, sorry.

  • @traches@sh.itjust.works
    link
    fedilink
    English
    1011 months ago

    I’d also like some guidance on this problem (other than “use emacs”), but searching for “ -x” will have a lower false positive rate

  • @Obi@sopuli.xyz
    link
    fedilink
    811 months ago

    As someone with 0 knowledge of Linux (and very little of programming/command lines in general), this thread reads funny AF.

  • @jeffreyosborne@lemm.ee
    link
    fedilink
    611 months ago

    I like tldr. It doesnt give incredibly in depth explanations, but it does show the basics of using most commands.

  • @thingsiplay@beehaw.org
    link
    fedilink
    3
    edit-2
    11 months ago

    Sorry for my previous comment. I was commenting before reading the entire post and was missing the point. On a sidenote, its often enough and helpful to just list the options with program -h or --help . Sometimes the help option has more information or is easier to understand than the man document.

    When I search for options in a man document, I usually try it with putting a dash in front of it as -x or --ignore in example. For really large documents sometimes it can help to add a space before it " -x" or a comma after it "-x, " depending on how its actually written. BTW the man program itself has a builtin help you can show by just pressing h while looking at a document.

  • @PseudoSpock@lemmy.dbzer0.com
    link
    fedilink
    311 months ago
           man -k printf
               Search  the short descriptions and manual page names for the keyword
               printf as regular expression.  Print out any matches.  Equivalent to
               apropos printf.
    
  • Troy
    link
    fedilink
    211 months ago

    In KDE, there used to be man: as a protocol that you could use from Konqueror or anything else for that matter. Does it still exist?

    I’m at work and cannot check.

    • Jure Repinc
      link
      fedilink
      English
      2
      edit-2
      11 months ago

      Yup still exists. It is also available in KDE Help Center. And you can quickly jump to a man page you typing “#man” into KRunner.

  • nore {she/her}
    link
    fedilink
    211 months ago

    I’ve had this same situation happen to me before and my solution was to search -x instead of just x.

  • wuphysics87
    link
    fedilink
    211 months ago

    You can search via regex. For instance you know a section heading or flag is the first thing on a line preceded with spaces. I also find it earier to read with extensions for colors.