Skip to content

Instantly share code, notes, and snippets.

@Mattti0
Created April 3, 2024 04:57
Show Gist options
  • Save Mattti0/264d95ca6adb923853cf3b8a62015032 to your computer and use it in GitHub Desktop.
Save Mattti0/264d95ca6adb923853cf3b8a62015032 to your computer and use it in GitHub Desktop.
mdreader utility to bashrc
#! /bin/bash
check_app() {
if apt-cache show $1 &>/dev/null; then
return 0
else
return 1
fi
}
if ! check_app "lynx"; then
echo "lynx not installed..."
echo "install it running apt install lynx"
exit
fi
if ! check_app "pandoc"; then
echo "pandoc not installed..."
echo "check installation details from:"
echo "https://github.com/jgm/pandoc/blob/main/INSTALL.md"
exit
fi
if ! grep "mdreader()" ~/.bashrc > /dev/null; then
echo "" >> ~/.bashrc
echo "### MDREADER UTILITY ###" >> ~/.bashrc
echo "function mdreader() {" >> ~/.bashrc
echo " pandoc \"\$1\" | lynx -stdin;" >> ~/.bashrc
echo "}" >> ~/.bashrc
else
echo "mdreader already installed"
fi
@Mattti0
Copy link
Author

Mattti0 commented Apr 3, 2024

Preview of mdreader output
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment