From 9a757b3610c9fa0abdd083b4ece181a32a5ff194 Mon Sep 17 00:00:00 2001 From: T0MuX Date: Tue, 14 Jan 2025 05:55:52 +0100 Subject: [PATCH] +fuzbat.sh --- bashrc.d/fuzbat.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 bashrc.d/fuzbat.sh diff --git a/bashrc.d/fuzbat.sh b/bashrc.d/fuzbat.sh new file mode 100644 index 0000000..a5f1bcd --- /dev/null +++ b/bashrc.d/fuzbat.sh @@ -0,0 +1,33 @@ +fuzbat() { +#!/usr/bin/env bash +# fuzbat +# Note-taking app alternative +# Originally written by Casey Brant +# Adapted by Armand Philippot +# Adapted again by T0MuX to keep it simply working as a bash function +# - added FZPATH to chose the notes' path + +FZPATH=$HOME/Sync/Notes + +set -e + +main() { + previous_file="$1" + file_to_edit=`select_file $previous_file` + + if [ -n "$file_to_edit" ] ; then + "$EDITOR" "$file_to_edit" + main "$file_to_edit" + fi +} + +select_file() { + given_file="$1" + fzf --tac --preview="bat --style=numbers --color=always {}" --preview-window=right:70%:wrap --query="$given_file" +} + +OLDPWD=$PWD +cd $FZPATH +main "" +cd $OLDPWD +}