|
@@ -5,8 +5,25 @@
|
|
|
[ -z "$(which rg 2>/dev/null)" ] && echo "[-] You need ripgrep (rg) installed" && exit 1
|
|
|
[ -z "$(which fzf 2>/dev/null)" ] && echo "[-] You need fzf installed" && exit 1
|
|
|
|
|
|
+function usage {
|
|
|
+
|
|
|
+ echo "cheat.sh - cheatsheet reader"
|
|
|
+ echo "Options:"
|
|
|
+ echo " -h print help/usage"
|
|
|
+ echo " -l list all files"
|
|
|
+ echo " -p print cheatsheets path"
|
|
|
+ echo " -w writable"
|
|
|
+ echo " -g open in gvim"
|
|
|
+ echo " -s search for string in <arg> using ripgrep"
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
-cheatsheets="/home/juan/documents/checkncheat/"
|
|
|
+
|
|
|
+if [ $CHEAT = "" ]; then
|
|
|
+ cheatsheets="$HOME/documents/cheatsheets/"
|
|
|
+else
|
|
|
+ cheatsheets="$CHEAT"
|
|
|
+fi
|
|
|
|
|
|
|
|
|
[ ! -d "$cheatsheets" ] && echo "[-] Cheatsheet folder does not exist." && exit 1
|
|
@@ -20,13 +37,14 @@ if [ $# -eq 0 ] ; then
|
|
|
fi
|
|
|
|
|
|
|
|
|
-while getopts ":glws:p" options ; do
|
|
|
+while getopts ":ghlws:p" options ; do
|
|
|
case "${options}" in
|
|
|
- l) fd -t f \.md -x echo {/.} ;;
|
|
|
- p) echo $cheatsheets ;;
|
|
|
- w) vim -c "Goyo 90%" "$(fzf)" ;;
|
|
|
- g) vim -R -c "Goyo 90%" "$(fzf)" -g ;;
|
|
|
- s) rg "${OPTARG}" ;;
|
|
|
- *) echo 'Invalid Argument' ;;
|
|
|
+ h) usage ;;
|
|
|
+ l) fd -t f \.md -x echo {/.} ;;
|
|
|
+ p) echo $cheatsheets ;;
|
|
|
+ w) vim -c "Goyo 90%" "$(fzf)" ;;
|
|
|
+ g) vim -R -c "Goyo 90%" "$(fzf)" -g ;;
|
|
|
+ s) rg "${OPTARG}" ;;
|
|
|
+ *) echo 'Invalid Argument' ;;
|
|
|
esac
|
|
|
done
|