Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yozachar opened this issue May 29, 2023 · 4 comments
Closed

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

yozachar opened this issue May 29, 2023 · 4 comments
Labels

Comments

@yozachar
Copy link

yozachar commented May 29, 2023

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.

@yozachar yozachar changed the title [Question] Ask git to use tldr [Question] How do I tell git to use tldr? May 29, 2023
@niklasmohrin
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Owner

dbrgn commented May 30, 2023

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.

@dbrgn dbrgn closed this as completed May 30, 2023
@yozachar
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants