34 lines
712 B
Bash
34 lines
712 B
Bash
|
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
|
||
|
}
|