+fuzbat.sh

This commit is contained in:
T0MuX 2025-01-14 05:55:52 +01:00
parent 2cceae456e
commit 9a757b3610

33
bashrc.d/fuzbat.sh Normal file
View file

@ -0,0 +1,33 @@
fuzbat() {
#!/usr/bin/env bash
# fuzbat
# Note-taking app alternative
# Originally written by Casey Brant <https://caseybrant.com/>
# Adapted by Armand Philippot <https://wp.armandphilippot.com>
# 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
}