From 8f97de03651a7070cae444e9ae13c9f660119bd3 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Thu, 3 Oct 2019 11:51:06 +0100 Subject: Improve mutt attachment script --- bin/.local/bin/mutt_attach | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'bin/.local') diff --git a/bin/.local/bin/mutt_attach b/bin/.local/bin/mutt_attach index e5ddbad..4a14dbc 100755 --- a/bin/.local/bin/mutt_attach +++ b/bin/.local/bin/mutt_attach @@ -1,7 +1,19 @@ #!/usr/bin/env bash -files=$(vifm "$HOME" --choose-files -) +# File in which to store the list of filenames to attach +tmp=$(mktemp) -for file in $files; do - tmux send-keys -t email.0 "a$file " -done +vifm "$HOME" --choose-files "$tmp" +# ranger "$HOME" --choosefiles="$tmp" + +while IFS="" read -r file; do + + # Workaround for filenames that contain spaces + if [[ "$file" = *" "* ]]; then + file_no_space=/tmp/$(basename "$file" | sed 's/ /_/g') + ln -s -f "$file" "$file_no_space" + file="$file_no_space" + fi + + tmux send-keys -t email:Email.0 -l "a$file "; +done < "$tmp" -- cgit v1.2.3