Skip to content

Instantly share code, notes, and snippets.

@afarah1
Last active September 20, 2023 19:33
Show Gist options
  • Save afarah1/6457d2a3a14a3f58e2fb to your computer and use it in GitHub Desktop.
Save afarah1/6457d2a3a14a3f58e2fb to your computer and use it in GitHub Desktop.
Extremely simple offline tl;dr pages client
#!/bin/sh
# Simple offline client for tldr pages
#
# Usage:
# tldr command
#
# Updating offline page cache:
# tldr --update
pf=${HOME}/.cache/tldr/pages
if [ ! -d $pf -o ${1:-0} = "--update" ]
then
bd=`pwd`
rm -rf $pf
mkdir -p $pf
cd $pf
git clone --depth 1 -b master --single-branch https://github.com/tldr-pages/tldr.git
mv tldr/pages/* .
rm -rf tldr
rm -f index.json
if [ ${1:-0} = "--update" ]
then
exit
fi
cd $bd
fi
file=`find $pf | grep "/${1:-0}\.md$"`
if [ $? -eq 0 ]
then
vi -R -X "$file"
else
echo "$1 - Command not found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment