aboutsummaryrefslogtreecommitdiff
path: root/neomutt/openfile
diff options
context:
space:
mode:
Diffstat (limited to 'neomutt/openfile')
-rw-r--r--neomutt/openfile9
1 files changed, 9 insertions, 0 deletions
diff --git a/neomutt/openfile b/neomutt/openfile
new file mode 100644
index 0000000..7b229b0
--- /dev/null
+++ b/neomutt/openfile
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/neomutt/files"
+file="$tempdir/${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