All Projects → tldr-pages → Tldr Node Client

tldr-pages / Tldr Node Client

Licence: mit
Node.js command-line client for tldr pages

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tldr Node Client

Tldr
📚 Collaborative cheatsheets for console commands
Stars: ✭ 36,408 (+12368.49%)
Mutual labels:  tldr
Tachyons Tldr
quick lookup for tachyon classes, scales and colour palette
Stars: ✭ 170 (-41.78%)
Mutual labels:  tldr
tldr.el
tldr client for Emacs
Stars: ✭ 118 (-59.59%)
Mutual labels:  tldr
Tl
tldr for R!
Stars: ✭ 52 (-82.19%)
Mutual labels:  tldr
Manpages Tldr
Short, practical manpages for everyday usage
Stars: ✭ 108 (-63.01%)
Mutual labels:  tldr
Tldr
Golang command line client for tldr https://github.com/tldr-pages/tldr
Stars: ✭ 210 (-28.08%)
Mutual labels:  tldr
Tldr Sh Client
Simplified and community-driven man pages
Stars: ✭ 583 (+99.66%)
Mutual labels:  tldr
alfred-tldr
tldr with alfred workflow written in Go
Stars: ✭ 77 (-73.63%)
Mutual labels:  tldr
Tldrlfs
Too Long; Didn't Read Linux From Scratch
Stars: ✭ 139 (-52.4%)
Mutual labels:  tldr
TLDR.jl
A package for fast help and snippets
Stars: ✭ 16 (-94.52%)
Mutual labels:  tldr
Tldr Alfred
Alfred workflow for TLDR
Stars: ✭ 70 (-76.03%)
Mutual labels:  tldr
Tldr
Text summarizer for golang using LexRank
Stars: ✭ 92 (-68.49%)
Mutual labels:  tldr
Dilettantes-Guide-to-Linting
Setting up ESLint, Prettier, VS Code, and the AirBnB style guide in beautiful harmony.
Stars: ✭ 18 (-93.84%)
Mutual labels:  tldr
Tldr
fast and interactive tldr client written with go
Stars: ✭ 984 (+236.99%)
Mutual labels:  tldr
red-tldr
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.
Stars: ✭ 159 (-45.55%)
Mutual labels:  tldr
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+9419.86%)
Mutual labels:  tldr
Tldr C Client
C command-line client for tldr pages
Stars: ✭ 180 (-38.36%)
Mutual labels:  tldr
tldr-flutter
simplified man-pages, a tldr.sh client
Stars: ✭ 65 (-77.74%)
Mutual labels:  tldr
tldr-php
PHP Client for tldr
Stars: ✭ 18 (-93.84%)
Mutual labels:  tldr
tldr
Simplified and community-driven man pages (tldr-pages) in a single binary.
Stars: ✭ 33 (-88.7%)
Mutual labels:  tldr

tldr-node-client

NPM version GitHub Action Build Status Gitter chat

A Node.js based command-line client for tldr.

tldr screenshot

tldr-node-client's output for the tar page, using a custom color theme

Installing

npm install -g tldr

Usage

To see tldr pages:

  • tldr <command> show examples for this command
  • tldr <command> --os=<platform> show command page for the given platform (linux, osx, sunos)
  • tldr --search "<query>" search all pages for the query
  • tldr --linux <command> show command page for Linux
  • tldr --osx <command> show command page for OSX
  • tldr --sunos <command> show command page for SunOS
  • tldr --list show all pages for current platform
  • tldr --list-all show all available pages
  • tldr --random show a page at random
  • tldr --random-example show a single random example
  • tldr --markdown show the original markdown format page

The client caches a copy of all pages locally, in ~/.tldr. There are more commands to control the local cache:

  • tldr --update download the latest pages and generate search index
  • tldr --clear-cache delete the entire local cache

As a contributor, you might also need the following commands:

  • tldr --render <path> render a local page for testing purposes

Tldr pages defaults to showing pages in the current language of the operating system, or English if that's not available. To view tldr pages for a different language, set an environment variable LANG containing a valid POSIX locale (such as zh, pt_BR, or fr) and then run the above commands as usual. In most *nix systems, this variable will already be set.

It is suggested that the LANG environment variable be set system-wide if this isn't already the case. Users without sudo access can set it locally in their ~/.profile.

  • LANG=zh tldr <command>

For the list of available translations, please refer to the main tldr repo.

Configuration

You can configure the tldr client by adding a .tldrrc file in your HOME directory. You can copy the contents of the config.json file from the repo to get the basic structure to start with, and modify it to suit your needs.

The default color theme is the one named "simple". You can change the theme by assigning a different value to the "theme" variable -- either to one of the pre-configured themes, or to a new theme that you have previously created in the "themes" section. Note that the colors and text effects you can choose are limited. Refer to the chalk documentation for all options.

{
  "themes": {
    "ocean": {
      "commandName": "bold, cyan",
      "mainDescription": "",
      "exampleDescription": "green",
      "exampleCode": "cyan",
      "exampleToken": "dim"
    },
    "myOwnCoolTheme": {
      "commandName": "bold, red",
      "mainDescription": "underline",
      "exampleDescription": "yellow",
      "exampleCode": "underline, green",
      "exampleToken": ""
    }
  },
  "theme": "ocean"
}

If you regularly need pages for a different platform (e.g. Linux), you can put it in the config file:

{
  "platform": "linux"
}

The default platform value can be overwritten with command-line option:

tldr du --os=osx

As a contributor, you can also point to your own fork containing the tldr.zip file. The file is just a zipped version of the entire tldr repo:

{
  "repository" : "http://myrepo/assets/tldr.zip",
}

Command-line Autocompletion

Currently we only support command-line autocompletion for zsh and bash. Pull requests for other shells are most welcome!

zsh

It's easiest for oh-my-zsh users, so let's start with that.

mkdir -p $ZSH_CUSTOM/plugins/tldr
ln -s bin/completion/zsh/_tldr $ZSH_CUSTOM/plugins/tldr/_tldr

Then add tldr to your oh-my-zsh plugins, usually defined in ~/.zshrc, resulting in something looking like this:

plugins=(git tmux tldr)

Alternatively, using zplug

zplug "tldr-pages/tldr-node-client", use:bin/completion/zsh

Fret not regular zsh user! Copy or symlink bin/completion/zsh/_tldr to my/completions/_tldr (note the filename). Then add the containing directory to your fpath:

fpath = (my/completions $fpath)

Bash

ln -s bin/completion/bash/tldr ~/.tldr-completion.bash

Now add the following line to our bashrc file:

source ~/.tldr-completion.bash

FAQ

Installation Issues

  • If you are trying to install as non-root user (npm install -g tldr) and get something like:
Error: EACCES: permission denied, access '/usr/local/lib/node_modules/tldr'

Then most probably your npm's default installation directory has improper permissions. You can resolve it by clicking here

  • If you are trying to install as a root user (sudo npm install -g tldr) and get something like:
as root ->
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tldr/node_modules/webworker-threads/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/tldr/node_modules/webworker-threads/.node-gyp/8.9.1"

You need to add the option --unsafe-perm to your command. This is because when npm goes to the postinstall step, it downgrades the permission levels to "nobody". Probably you should fix your installation directory permissions and install as a non-root user in the first place.

  • If you see an error related to webworker-threads like:
/usr/local/lib/node_modules/tldr/node_modules/natural/lib/natural/classifiers/classifier.js:32
    if (e.code !== 'MODULE_NOT_FOUND') throw e;

Most probably you need to reinstall node-gyp and webworker-threads. Try this -

sudo -H npm uninstall -g tldr
sudo -H npm uninstall -g webworker-threads
npm install -g node-gyp
npm install -g webworker-threads
npm install -g tldr

For further context, take a look at this issue

Colors under Cygwin

Colors can't be shown under Mintty or PuTTY, because the dependency colors.js has a bug. Please show support to this pull request, so it can be merged.

Meanwhile, you can do one of the following to fix this issue:

  • Add the following script to your shell's rc file (.zshrc, .bashrc, etc.): (RECOMMENDED)
tldr_path="$(which tldr)"
function tldr() {
  eval "$tldr_path" [email protected] "--color"
}
  • Add alias tldr="tldr --color=true" to your shell's rc file.
  • Prepend process.stdout.isTTY = true; to tldr.js (NOT RECOMMENDED)
  • Fix colors.js's logic (NOT RECOMMENDED)
    • Go to %appdata%\npm\node_modules\tldr\node_modules\colors\lib\system\
    • Overwrite supports-colors.js with supports-colors.js from my repo.
  • Use CMD.exe.

Contributing

Contribution are most welcome! Have a look over here for a few rough guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].