From 22bafa21869fb47d8f6568a0e047c226926f20e0 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Tue, 12 Oct 2021 01:01:01 +0300 Subject: mutt: free from the shackles --- .local/bin/openfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 .local/bin/openfile (limited to '.local/bin/openfile') diff --git a/.local/bin/openfile b/.local/bin/openfile new file mode 100755 index 0000000..cf3c6c3 --- /dev/null +++ b/.local/bin/openfile @@ -0,0 +1,10 @@ +#!/bin/sh + +# Helps open a file with xdg-open from mutt in a external program without weird side effects. +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 -- cgit v1.2.3-70-g09d2