feat: basic image viewer
This commit is contained in:
parent
4ba328934b
commit
adaff4e285
@ -1,8 +1,11 @@
|
|||||||
# Retrieve content from iCalendar files
|
# Retrieve content from vCard files
|
||||||
#
|
#
|
||||||
# Mandatory variable: `field`.
|
# Mandatory variable: `field`.
|
||||||
# Name of field to retrieve.
|
# Name of field to retrieve.
|
||||||
#
|
#
|
||||||
|
# Optional variable: `prop`.
|
||||||
|
# If `prop` is set, then the property `prop` of `field` is printed.
|
||||||
|
#
|
||||||
# Optional variable: `format`.
|
# Optional variable: `format`.
|
||||||
# If `format` is set to "csv", then the content is interpreted as
|
# If `format` is set to "csv", then the content is interpreted as
|
||||||
# comma-separated values, and empty values are dropped.
|
# comma-separated values, and empty values are dropped.
|
||||||
@ -15,15 +18,18 @@
|
|||||||
|
|
||||||
# print content of field `field`
|
# print content of field `field`
|
||||||
BEGIN { FS = ":"; regex = "^" field; }
|
BEGIN { FS = ":"; regex = "^" field; }
|
||||||
BEGINFILE { type = ""; line = ""; }
|
BEGINFILE { line = ""; }
|
||||||
/^BEGIN:(VJOURNAL|VTODO)/ { type = $2 }
|
/^BEGIN:VCARD/ { next }
|
||||||
/^END:/ && $2 == type { nextfile }
|
/^END:VCARD/ { nextfile }
|
||||||
$0 ~ regex { line = $0; next; }
|
$0 ~ regex { line = $0; next; }
|
||||||
/^ / && line { line = line substr($0, 2); next; }
|
/^ / && line { line = line substr($0, 2); next; }
|
||||||
/^[^ ]/ && line { nextfile }
|
/^[^ ]/ && line { nextfile }
|
||||||
ENDFILE {
|
ENDFILE {
|
||||||
if (type) {
|
if (line) {
|
||||||
# Process line
|
# Process line
|
||||||
|
if (prop)
|
||||||
|
content = getparam(line, prop)
|
||||||
|
else
|
||||||
content = getcontent(line)
|
content = getcontent(line)
|
||||||
if (oneline)
|
if (oneline)
|
||||||
content = singleline(content)
|
content = singleline(content)
|
||||||
|
@ -142,6 +142,7 @@ while true; do
|
|||||||
--bind="alt-o:change-query($FLAG_ORGANIZATION )" \
|
--bind="alt-o:change-query($FLAG_ORGANIZATION )" \
|
||||||
--bind="alt-l:change-query($FLAG_LOCATION )" \
|
--bind="alt-l:change-query($FLAG_LOCATION )" \
|
||||||
--bind="alt-w:toggle-preview-wrap" \
|
--bind="alt-w:toggle-preview-wrap" \
|
||||||
|
--bind="/:toggle-preview" \
|
||||||
--bind="ctrl-d:preview-half-page-down" \
|
--bind="ctrl-d:preview-half-page-down" \
|
||||||
--bind="ctrl-u:preview-half-page-up" \
|
--bind="ctrl-u:preview-half-page-up" \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A && ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" || #--color='preview-bg:#ecc297,preview-fg:black' \
|
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A && ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" || #--color='preview-bg:#ecc297,preview-fg:black' \
|
||||||
|
@ -6,6 +6,7 @@ if [ "${1:-}" = "--preview" ]; then
|
|||||||
name="$1"
|
name="$1"
|
||||||
shift
|
shift
|
||||||
file="$ROOT/$name"
|
file="$ROOT/$name"
|
||||||
|
# Get info
|
||||||
awk \
|
awk \
|
||||||
-v label_tel_text="$LABEL_TEL_TEXT" \
|
-v label_tel_text="$LABEL_TEL_TEXT" \
|
||||||
-v label_tel_fax="$LABEL_TEL_FAX" \
|
-v label_tel_fax="$LABEL_TEL_FAX" \
|
||||||
@ -18,6 +19,20 @@ if [ "${1:-}" = "--preview" ]; then
|
|||||||
-v label_home="$LABEL_HOME" \
|
-v label_home="$LABEL_HOME" \
|
||||||
"$AWK_PREVIEW" "$file" |
|
"$AWK_PREVIEW" "$file" |
|
||||||
$CAT
|
$CAT
|
||||||
|
# Get photo, if supported and if it exists
|
||||||
|
if [ "${CHAFA:-}" ]; then
|
||||||
|
photo=$(mktemp)
|
||||||
|
awk -v field="PHOTO" "$AWK_GET" "$file" | base64 -d -i >"$photo"
|
||||||
|
type=$(file --mime-type -b "$photo" | cut -d '/' -f 1)
|
||||||
|
if [ "$type" = "image" ]; then
|
||||||
|
WIDTH=80
|
||||||
|
if [ "$FZF_PREVIEW_COLUMNS" -lt "$WIDTH" ]; then
|
||||||
|
WIDTH="$FZF_PREVIEW_COLUMNS"
|
||||||
|
fi
|
||||||
|
$CHAFA -f symbols -s "$WIDTH" "$photo"
|
||||||
|
fi
|
||||||
|
rm "$photo"
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -65,4 +65,9 @@ if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
|||||||
export GIT
|
export GIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if command -v "chafa" >/dev/null; then
|
||||||
|
CHAFA="chafa"
|
||||||
|
export CHAFA
|
||||||
|
fi
|
||||||
|
|
||||||
export OPEN=${OPEN:-open}
|
export OPEN=${OPEN:-open}
|
||||||
|
Loading…
Reference in New Issue
Block a user