Or is there maybe a way to set the pager for all help related queries to some command? I’m using bat and would like to pipe all --help through | bat --language=help by default for the syntax highlighting and colored output… Or if you know a lower effort way to color the output of --help let me know.

  • bleistift2@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    8
    ·
    3 days ago

    To answer the original question, even though @RedWeasel@lemmy.world’s advice really is superior:

    All commands that can be executed via your shell must live in your $PATH or their subdirectories. You could enumerate all files in there, filter by being executable, and run them with the --help argument.

    You can then filter these commands by their exit code. If --help is a recognized flag, the exit code should be 0. Otherwise it should be something else. (Running every command blindly might be a bad idea though.)

    • RedWeasel@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      3 days ago

      Or if you are lazy you could add “-h” as an option to said help command for when --help doesn’t work. Shouldn’t take to long to to make a list with a script that runs each command to with --help and logs it all to a file though. Then just go look for the ones that don’t like it in the log. Apparently bash has a builtin command named help, so a different name is probably better then.

      ls -1 $dir | while read line do echo “----------” $line --help |& >> logfile.txt done

      Just search in you favorite pager for “-----” and just hit “next” key.