dbrgn / tealdeer

A very fast implementation of tldr in Rust.
https://dbrgn.github.io/tealdeer/
Apache License 2.0
4.06k stars 123 forks source link

[Question] How do I tell git to use tldr? #326

Closed yozachar closed 1 year ago

yozachar commented 1 year ago

How do I tell git to use tldr?

$ git log --help
warning: failed to exec 'man': No such file or directory
fatal: no man viewer handled the request
$ man --version # aliased
tealdeer 1.6.1

Arch man pages say https://man.archlinux.org/man/git-help.1.en#man.viewer, but I'm unable to do the configuration with success.

niklasmohrin commented 1 year ago

Git does not use your shell to spawn the man process, so it is unaware of your aliases. You need to tell git by following the explanation from the link you provided. If setting the configuration does not work, you could try setting the environment variable GIT_MAN_VIEWER=tldr before running git, probably in your shell config. Does this help?

yozachar commented 1 year ago

No, that does not seem to work either:

$ export GIT_MAN_VIEWER=tldr
$ echo $GIT_MAN_VIEWER
tldr
$ git log --help                                                   
warning: 'tldr': unknown man viewer.
warning: failed to exec 'man': No such file or directory
fatal: no man viewer handled the request
dbrgn commented 1 year ago

If the command isn't supported by git out of the box, you need to set it up in your config using man.tdr.cmd:

https://git-scm.com/docs/git-help#_man_viewer

However, tealdeer is not a generic man viewer, so I'm not sure if this is the best idea 🙂 However, if it works for you, that's great.

I'll close this issue for now since it's not a feature request, but feel free to add further comments.

yozachar commented 1 year ago

That works,

$ git config --global man.viewer tldr
$ git config --global man.tldr.cmd tldr
$ git log --help
  Show a history of commits.
  More information: <https://git-scm.com/docs/git-log>.

  Show the sequence of commits starting from the current one, in reverse chronological order of the Git repository in the current working directory:

      git log

  Show the history of a particular file or directory, including differences:

      git log -p path/to/file_or_directory

  Show an overview of which file(s) changed in each commit:

      git log --stat

  Show a graph of commits in the current branch using only the first line of each commit message:

      git log --oneline --graph

  Show a graph of all commits, tags and branches in the entire repo:

      git log --oneline --decorate --all --graph

  Show only commits whose messages include a given string (case-insensitively):

      git log -i --grep search_string

  Show the last N commits from a certain author:

      git log -n number --author=author

  Show commits between two dates (yyyy-mm-dd):

      git log --before="2017-01-29" --after="2017-01-17"

Thanks!