Skip to content

Useful scripts and programs

Marco Bonelli edited this page Aug 20, 2019 · 13 revisions

Create a new issue if a page doesn't exist

# create a new issue if not found (requires hub cli client)
# checks brew and cargo for homepage + description

function tld {
  tldr $* 2>/dev/null && return
  local repo=~/code/tldr # replace with location to tldr repo
  local info=("${(@f)$(brew info --json=v1 $1 2>/dev/null | jq -r '.[].homepage,.[].desc')}")
  test $#info -gt 1 || info=("${(@f)$(cargo show $1 2>/dev/null | awk '/^homepage|description/ { $1=""; print }')}")
  test $#info -gt 1 || return
  hub -C $repo issue | grep $1 && return
  hub -C $repo issue create -F <(echo "page request: $1\n\nAdd documentation for [$1]($info[1])\n$info[2]")
}

Find pages that don't exist

A script that finds pages that haven't been created yet can be found here. It has 2 modes:

  • history - Searches your ~/.bash_history
  • man - Searches the installed man pages

Translation helper: find next page to translate

A Python script that finds the next page (in alphabetical order) that needs to be translated from English to the chosen target language, copies it in the correct folder and opens it in the default text editor (i.e. the command editor). To use, simply download and run the script inside the tldr repository after cloning it.

Script available here: tldr_translate_next_page.py.

usage: ./tldr_translate_next_page.py [-h] [-c] LANGUAGE

positional arguments:
  LANGUAGE         target language (e.g. it)

optional arguments:
  -h, --help       show this help message and exit
  -c, --copy-only  only copy the file, without opening it in the text editor
Clone this wiki locally