Added preview support
Also, removed unused function, and renamed a function.
This commit is contained in:
25
fzf-vjour
25
fzf-vjour
@@ -22,7 +22,7 @@ for label in "${COLLECTION_LABELS[@]}"; do
|
|||||||
[[ ${#label} -gt $COLLECTION_LABEL_MAX_LEN ]] && COLLECTION_LABEL_MAX_LEN=${#label}
|
[[ ${#label} -gt $COLLECTION_LABEL_MAX_LEN ]] && COLLECTION_LABEL_MAX_LEN=${#label}
|
||||||
done
|
done
|
||||||
|
|
||||||
__vjourupdate() {
|
__vjournalupdate() {
|
||||||
python3 -c '
|
python3 -c '
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -227,13 +227,22 @@ __filepath_from_selection() {
|
|||||||
echo -e "$selection"
|
echo -e "$selection"
|
||||||
}
|
}
|
||||||
|
|
||||||
__open_vj_file() {
|
# Program starts here
|
||||||
local file="$1"
|
|
||||||
local tmpfile="$(mktemp).md"
|
|
||||||
echo "$file" | __vjournal2json
|
|
||||||
}
|
|
||||||
|
|
||||||
selection=$(__lines | fzf --ansi)
|
# Command line arguments to be self-contained
|
||||||
|
# Generate preview of file from selection
|
||||||
|
if [[ "${1:-}" == "--preview" ]]; then
|
||||||
|
local vjfile=$(__filepath_from_selection "$2")
|
||||||
|
cat "$vjfile" | __vjournal2json | jq -r ".description" | batcat --color=always --style=numbers --language=md
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
selection=$(__lines | fzf --ansi --preview="$0 --preview {}"
|
||||||
|
#--bind='ctrl-d:execute(rm -i $(echo {}|$HOME/.zsh/journaling/filefromline))' \
|
||||||
|
#--bind='ctrl-n:execute($HOME/.zsh/journaling/add)' \
|
||||||
|
#--bind='ctrl-s:execute(vdirsyncer sync journals)' \
|
||||||
|
#--preview='vjour2json < $(echo {}|$HOME/.zsh/journaling/filefromline) | jq -r ".description" | batcat --color=always --style=numbers --language=md')
|
||||||
|
)
|
||||||
if [[ -z "$selection" ]]; then
|
if [[ -z "$selection" ]]; then
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
@@ -271,7 +280,7 @@ then
|
|||||||
echo "Uh... chages detected!"
|
echo "Uh... chages detected!"
|
||||||
local vj_file_new="$TMPFILE.ics"
|
local vj_file_new="$TMPFILE.ics"
|
||||||
trap "rm -f $vj_file_new" EXIT
|
trap "rm -f $vj_file_new" EXIT
|
||||||
__vjourupdate "$VJ_FILE" < "$TMPFILE" > "$vj_file_new" && mv "$vj_file_new" "$VJ_FILE"
|
__vjournalupdate "$VJ_FILE" < "$TMPFILE" > "$vj_file_new" && mv "$vj_file_new" "$VJ_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$0"
|
exec "$0"
|
||||||
|
|||||||
Reference in New Issue
Block a user