diff options
Diffstat (limited to 'bin/openfile')
-rwxr-xr-x | bin/openfile | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/openfile b/bin/openfile index f6668dc..cf3c6c3 100755 --- a/bin/openfile +++ b/bin/openfile @@ -1,9 +1,10 @@ #!/bin/sh # Helps open a file with xdg-open from mutt in a external program without weird side effects. -[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid xdg-open" -mkdir -p "/tmp/$USER-mutt-tmp" -file="/tmp/$USER-mutt-tmp/$(basename "$1")" -rm -f "$file" -cp "$1" "$file" -$opener "$file" >/dev/null 2>&1 & +tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" +file="$tempdir/$(basename "$1")" +[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" +mkdir -p "$tempdir" +cp -f "$1" "$file" +$opener "$file" >/dev/null 2>&1 +find "${tempdir:?}" -mtime +1 -type f -delete |