Skip to content

Allow TLDR_PAGES_SOURCE_LOCATION to contain multiple locations #188

@scottmuc

Description

@scottmuc

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions