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

Allow TLDR_PAGES_SOURCE_LOCATION to contain multiple locations #188

Open
scottmuc opened this issue Feb 15, 2022 · 1 comment
Open

Allow TLDR_PAGES_SOURCE_LOCATION to contain multiple locations #188

scottmuc opened this issue Feb 15, 2022 · 1 comment

Comments

@scottmuc
Copy link

scottmuc commented Feb 15, 2022

In my work environment, I'm maintaining a fork of tldr-pages to add pages that are private and not ever intended to be merged upstream. In order to not have to maintain a fork, I'd be interested in maintaining a sparse replica that only contains the pages are company maintains.

I was thinking that the variable could be set as follows:

TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages;https://raw.githubusercontent.com/big-corp/tldr/master/pages"

or

TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/master/pages;${HOME}/.tldr/pages

In the above ${HOME}/.tldr is a clone of github.com/big-corp/tldr.

For duplicates or conflicts, I can see a few ways of managing:

  • First one found wins. Probably the best for performance.
  • Last one found wins. Requires a lookup in every page repo.
  • Error on duplicate. Requires a lookup in every page repo and could be views as poor user experience.

Curious what people think. I'd be happy to implement this if the maintainers feel like this could be a workable feature.

Here's my tldr shim I use:

#!/usr/bin/env bash

set -e
set -o pipefail

if [[ ! -d ~/.tldr ]]; then
  echo "Fetching tldr-pages from GitHub..."
  # Use public repo until I have something to hide ;-)
  # Would need to display a useful message if keys aren't loaded
  git clone https://github.com/scottmuc/tldr.git ~/.tldr 2> /dev/null
fi

if [[ "$1" = "--update_cache" || "$1" = "-u" ]]; then
  echo "Updating tldr-pages from GitHub..."
  ( cd ~/.tldr && git pull )
else
  # Disable the cache so standard tldr-pages repo and zip aren't used
  env \
    TLDR_CACHE_ENABLED=0 \
    TLDR_PAGES_SOURCE_LOCATION="file://${HOME}/.tldr/pages" \
    "${HOMEBREW_PREFIX}/bin/tldr" "$@"
fi

and here's it in action:

~ ? tldr muc

  muc

  Scott Muc's cheat sheet.
  More information: https://github.com/scottmuc/tldr/.

  - Initalize 1Password:
    initalize-1password

The reason why this feature in the client would be useful is to remove the need to maintain a fork of the pages as well as providing a home for the additional pages that's not surrounded my upstream maintained files.

@scottmuc
Copy link
Author

Looking at the other issues, this may assist in helping out the folks that submitted #147 and #146

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

No branches or pull requests

1 participant