Compare commits

...

2 Commits

Author SHA1 Message Date
4d0148e2a3 improvement: adding attachments 2025-06-17 11:25:55 +02:00
fef86eef7a bugfix: open attachment 2025-06-17 11:14:18 +02:00

View File

@@ -918,15 +918,29 @@ __tentative_toggle() {
# @req $AWK_ATTACH: Awk script to add attachment # @req $AWK_ATTACH: Awk script to add attachment
__add_attachment() { __add_attachment() {
fpath="$ROOT/$1" fpath="$ROOT/$1"
f=$($FZF --prompt="Select attachment> ") sel=$(
$FZF --prompt="Select attachment> " \
--walker="file,hidden" \
--walker-root="$HOME" \
--expect="ctrl-c,ctrl-g,ctrl-q,esc"
)
key=$(echo "$sel" | head -1)
f=$(echo "$sel" | tail -1)
if [ -n "$key" ]; then
f=""
fi
if [ -z "$f" ] || [ ! -f "$f" ]; then if [ -z "$f" ] || [ ! -f "$f" ]; then
return return
fi fi
filename=$(basename "$f") filename=$(basename "$f")
mime=$(file -b -i "$f" | cut -d ';' -f 1)
if [ -z "$mime" ]; then
mime="application/octet-stream"
fi
fenc=$(mktemp) fenc=$(mktemp)
base64 "$f" >"$fenc" base64 "$f" >"$fenc"
filetmp=$(mktemp) filetmp=$(mktemp)
awk -v file="$fenc" -v mime="application/octet-stream" -v filename="$filename" "$AWK_ATTACH" "$fpath" >"$filetmp" awk -v file="$fenc" -v mime="$mime" -v filename="$filename" "$AWK_ATTACH" "$fpath" >"$filetmp"
mv "$filetmp" "$fpath" mv "$filetmp" "$fpath"
if [ -n "${GIT:-}" ]; then if [ -n "${GIT:-}" ]; then
$GIT add "$fpath" $GIT add "$fpath"
@@ -1272,6 +1286,7 @@ while true; do
--bind="start:hide-input" \ --bind="start:hide-input" \
--bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \ --bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -eq 0 ] && echo 'unbind(enter)+unbind(ctrl-alt-d)'" \ --bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -eq 0 ] && echo 'unbind(enter)+unbind(ctrl-alt-d)'" \
--bind="w:toggle-wrap" \
--bind="j:down" \ --bind="j:down" \
--bind="k:up" || --bind="k:up" ||
true true
@@ -1349,6 +1364,8 @@ while true; do
case $yn in case $yn in
"yes") "yes")
$OPEN "$attpath" $OPEN "$attpath"
printf "Press <enter> to continue." >/dev/tty
read -r tmp
break break
;; ;;
"no") "no")