diff options
author | Yigit Sever | 2021-10-12 01:01:01 +0300 |
---|---|---|
committer | Yigit Sever | 2021-10-12 01:01:01 +0300 |
commit | 22bafa21869fb47d8f6568a0e047c226926f20e0 (patch) | |
tree | 90b18965b589d95e27e166186ddc32ca8f92471b /.local/bin/openfile | |
parent | 20e42aa0d070f0c09ab20bf4ab42c3495a807e1c (diff) | |
download | dotfiles-22bafa21869fb47d8f6568a0e047c226926f20e0.tar.gz dotfiles-22bafa21869fb47d8f6568a0e047c226926f20e0.tar.bz2 dotfiles-22bafa21869fb47d8f6568a0e047c226926f20e0.zip |
mutt: free from the shackles
Diffstat (limited to '.local/bin/openfile')
-rwxr-xr-x | .local/bin/openfile | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Helps open a file with xdg-open from mutt in a external program without weird side effects. | ||
4 | tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" | ||
5 | file="$tempdir/$(basename "$1")" | ||
6 | [ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" | ||
7 | mkdir -p "$tempdir" | ||
8 | cp -f "$1" "$file" | ||
9 | $opener "$file" >/dev/null 2>&1 | ||
10 | find "${tempdir:?}" -mtime +1 -type f -delete | ||