-
-
Save afarah1/6457d2a3a14a3f58e2fb to your computer and use it in GitHub Desktop.
Extremely simple offline tl;dr pages client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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