소스 검색

improved cheat.sh

Marius Schwarz 4 년 전
부모
커밋
1cf4d14b21
1개의 변경된 파일15개의 추가작업 그리고 2개의 파일을 삭제
  1. 15 2
      cheat.sh

+ 15 - 2
cheat.sh

@@ -15,6 +15,16 @@ function usage {
     echo "    -w   writable"
     echo "    -g   open in gvim"
     echo "    -s   search for string in <arg> using ripgrep"
+    echo "    -i   interactive menu with dmenu"
+}
+
+
+# select the files using a dmenu/rofi interface and display em with md-viewer
+function interactive {
+    cd $cheatsheets
+    cs=`fd .md$ . | dmenu -i -l 20`
+    nohup md-viewer $cs >&2 2>/dev/null &
+
 }
 
 # Set the path to the cheatncheck repo here
@@ -32,12 +42,14 @@ fi
 cd $cheatsheets
 
 if [ $# -eq 0 ] ; then
-    vim -R -c "Goyo 90%" "$(fzf)"
+    #vim -R -c "Goyo 90%" "$(fzf)"
+    chosen_cheatsheet=`fzf`
+    nohup md-viewer "$chosen_cheatsheet" >&2 2>/dev/null &
     exit 1
 fi
 
 # Option Parsin
-while getopts ":ghlws:p" options ; do
+while getopts ":ghlws:pi" options ; do
     case "${options}" in
         h) usage ;;                             # print help/usage
         l) fd -t f \.md -x echo {/.} ;;         # list all files
@@ -45,6 +57,7 @@ while getopts ":ghlws:p" options ; do
         w) vim -c "Goyo 90%" "$(fzf)" ;;        # writable
         g) vim -R -c "Goyo 90%" "$(fzf)" -g ;;  # open in gvim
         s) rg "${OPTARG}" ;;                    # search for string in <arg> using ripgrep
+        i) interactive ;;                       # interactive dmenu/rofi menu
         *) echo 'Invalid Argument' ;;           # Argument not available
     esac
 done