aboutsummaryrefslogtreecommitdiffstats
path: root/batnote_openbsd
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbatnote_openbsd56
1 files changed, 56 insertions, 0 deletions
diff --git a/batnote_openbsd b/batnote_openbsd
new file mode 100755
index 0000000..9a0dea9
--- /dev/null
+++ b/batnote_openbsd
@@ -0,0 +1,56 @@
+#!/usr/local/bin/bash
+
+# a script for FZFing through my Notes folder for quick reading.
+# Uses bat if installed, otherwise will use less.
+
+NOTES=/home/$USER/Notes
+FZF_BIN=/home/$USER/.fzf/bin/fzf
+BAT=/usr/bin/bat
+LESS=/usr/bin/less
+VIM=/usr/local/bin/vim
+
+CMD=$LESS
+
+# instead of viewing with less, we want to edit in Vim
+if ! [[ -x $FZF_BIN ]]; then
+ echo "You need to have FZF installed for this to work."
+ exit 1
+fi
+
+if [[ $1 = "-v" ]]
+then
+ echo "Using vim..."
+ CMD=$VIM
+ # Thanks to https://stackoverflow.com/a/1489405 for the find command to omit .git
+ $CMD "$(find $NOTES -name '.git*' -type d -prune -o -type f -print|$FZF_BIN)"
+ exit
+fi
+
+if [[ $1 = "-m" ]]
+then
+ echo "Searching mod files only..."
+ NOTES=$NOTES/modzet
+ if [[ $2 = "-v" ]]
+ then
+ echo "Using vim..."
+ CMD=$VIM
+ fi
+ # Thanks to https://stackoverflow.com/a/1489405 for the find command to omit .git
+ $CMD "$(find $NOTES -name '.git*' -type d -prune -o -type f -print|$FZF_BIN)"
+ exit
+fi
+
+# if [[ -z $1 ]]; then
+# echo "You must provide a file name as the argument to this command."
+# exit 1
+# else
+# TARGET=$1
+# fi
+
+
+if [[ -x $BAT ]]; then
+ CMD=$BAT
+fi
+
+# Thanks to https://stackoverflow.com/a/1489405 for the find command to omit .git
+clear; $CMD "$(find $NOTES -name '.git*' -type d -prune -o -type f -print|$FZF_BIN)"