Better mutt and terminal previews with quicklook

main
Steffen Rademacker 3 years ago
parent 4972186182
commit 95595d50f0

@ -18,6 +18,7 @@ brew install --cask iterm2
brew install --cask kap
brew install --cask karabiner-elements
brew install --cask microsoft-teams
brew install --cask qlstephen
brew install --cask sequel-pro
brew install --cask signal
brew install --cask sketch
@ -28,6 +29,12 @@ brew install --cask telegram
brew install --cask vmware-fusion
brew install --cask zoom
# Quicklook-reset
xattr -cr ~/Library/QuickLook
xattr -d -r com.apple.quarantine ~/Library/QuickLook
qlmanage -r
qlmanage -r cache
# link config files for some casks
ln -s ~/dotfiles/hammerspoon ~/.hammerspoon
ln -s ~/dotfiles/karabiner ~/.config/karabiner
@ -42,7 +49,7 @@ sudo v /Applications/UniFi.app/Contents/Info.plist
# THEN add this: <key>JVMRuntime</key> <string>adoptopenjdk-8.jdk</string>
# firefox-extensions:
# vimium ff, dark reader, privacy badger, ublock origin, wikiwand,
# surfingkeys, dark reader, privacy badger, ublock origin, wikiwand,
# 1passwd classic extension, react developer tools, df youtube
# other software:

@ -15,6 +15,7 @@
// coc-yank
{
"coc.preferences.formatOnSaveFiletypes": [
"typescriptreact",
"javascriptreact",
"javascript",
"scss",
@ -28,10 +29,7 @@
// we use eslint instaed
"javascript.format.enabled": false,
"javascript.validate.enable": false,
"typescript.suggest.enabled": false,
"typescript.validate.enable": false,
"typescript.format.enabled": false,
"tsserver.disableAutomaticTypeAcquisition": true,
"suggest.minTriggerInputLength": 3,
"suggest.noselect": false,
"suggest.enablePreselect": true,
@ -47,14 +45,14 @@
"scss": [
"css"
],
"jsx": [
"javascript"
],
"javascriptreact": [
"javascript"
],
"typescript": [
"javascript"
],
"typescriptreact": [
"javascript"
]
}
}

@ -27,10 +27,11 @@ macro index,pager \cb "<pipe-message>urlscan<enter>" "call urlscan to extract UR
macro index,pager O "<shell-escape>mbsync -a<enter>" "run mbsync to sync all mail"
# View attachments properly.
bind attach <return> view-mailcap
bind attach <space> view-mailcap
# Drafts
bind compose P postpone-message
bind compose <space> view-attach
bind index p recall-message
# finding stuff

@ -1,21 +1,50 @@
# MS Word documents
application/msword; ~/dotfiles/office/view-attachment.sh %s "-" '/Applications/LibreOffice.app'
application/vnd.ms-excel; ~/dotfiles/office/view-attachment.sh %s "-" '/Applications/LibreOffice.app'
application/vnd.openxmlformats-officedocument.presentationml.presentation; ~/dotfiles/office/view-attachment.sh %s "-" '/Applications/LibreOffice.app'
application/vnd.oasis.opendocument.text; ~/dotfiles/office/view-attachment.sh %s "-" '/Applications/LibreOffice.app'
# HTML and text
text/html; w3m -I %{charset} -T text/html; copiousoutput;
text/plain; $EDITOR %s
# Images
image/jpg; ~/dotfiles/office/quicklook.sh %s jpg
image/jpeg; ~/dotfiles/office/quicklook.sh %s jpg
image/pjpeg; ~/dotfiles/office/quicklook.sh %s jpg
image/png; ~/dotfiles/office/quicklook.sh %s png
image/gif; ~/dotfiles/office/quicklook.sh %s gif
video/mp4; ~/dotfiles/office/quicklook.sh %s mp4
application/pdf; ~/dotfiles/office/quicklook.sh %s pdf
# images and other media
audio/aac; ~/dotfiles/office/mutt/view.sh %s
audio/mpeg; ~/dotfiles/office/mutt/view.sh %s
audio/wav; ~/dotfiles/office/mutt/view.sh %s
audio/webm; ~/dotfiles/office/mutt/view.sh %s
image/bmp; ~/dotfiles/office/mutt/view.sh %s
image/gif; ~/dotfiles/office/mutt/view.sh %s
image/jpeg; ~/dotfiles/office/mutt/view.sh %s
image/png; ~/dotfiles/office/mutt/view.sh %s
image/svg+xml; ~/dotfiles/office/mutt/view.sh %s
image/tiff; ~/dotfiles/office/mutt/view.sh %s
image/vnd.microsoft.icon; ~/dotfiles/office/mutt/view.sh %s
video/mp4; ~/dotfiles/office/mutt/view.sh %s
video/mpeg; ~/dotfiles/office/mutt/view.sh %s
video/webm; ~/dotfiles/office/mutt/view.sh %s
video/x-msvideo; ~/dotfiles/office/mutt/view.sh %s
# HTML
text/html; w3m -I %{charset} -T text/html; copiousoutput;
text/plain; nvim %s
# fonts
application/vnd.ms-fontobject; ~/dotfiles/office/mutt/view.sh %s
font/otf; ~/dotfiles/office/mutt/view.sh %s
font/ttf; ~/dotfiles/office/mutt/view.sh %s
font/woff2; ~/dotfiles/office/mutt/view.sh %s
font/woff; ~/dotfiles/office/mutt/view.sh %s
# documents
application/json; ~/dotfiles/office/mutt/view.sh %s
application/msword; ~/dotfiles/office/mutt/view.sh %s
application/pdf; ~/dotfiles/office/mutt/view.sh %s
application/rtf; ~/dotfiles/office/mutt/view.sh %s
application/vnd.ms-excel; ~/dotfiles/office/mutt/view.sh %s
application/vnd.ms-powerpoint; ~/dotfiles/office/mutt/view.sh %s
application/vnd.oasis.opendocument.presentation; ~/dotfiles/office/mutt/view.sh %s
application/vnd.oasis.opendocument.spreadsheet; ~/dotfiles/office/mutt/view.sh %s
application/vnd.oasis.opendocument.text; ~/dotfiles/office/mutt/view.sh %s
application/vnd.openxmlformats-officedocument.presentationml.presentation; ~/dotfiles/office/mutt/view.sh %s
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; ~/dotfiles/office/mutt/view.sh %s
application/vnd.openxmlformats-officedocument.wordprocessingml.document; ~/dotfiles/office/mutt/view.sh %s
application/xml; ~/dotfiles/office/mutt/view.sh %s
text/calendar; ~/dotfiles/office/mutt/view.sh %s
text/css; ~/dotfiles/office/mutt/view.sh %s
text/csv; ~/dotfiles/office/mutt/view.sh %s
text/javascript; ~/dotfiles/office/mutt/view.sh %s
text/xml; ~/dotfiles/office/mutt/view.sh %s
# Unidentified files
application/octet-stream; ~/dotfiles/office/view-attachment.sh %s "-"
# all other Unidentified files
application/octet-stream; ~/dotfiles/office/mutt/view.sh %s

@ -0,0 +1,3 @@
#!/usr/local/bin/zsh
trap 'exit 0' 2 #traps Ctrl-C (signal 2)
qlmanage -p $1 >& /dev/null

@ -1,8 +0,0 @@
#!/bin/bash
QLFILE=$1
# we have to trap ctrl-c so that a successful exit signal will be given,
# so that mutt won't prompt us to press any key to continue
trap 'exit 0' 2 #traps Ctrl-C (signal 2)
qlmanage -p $QLFILE >& /dev/null

@ -1,127 +0,0 @@
#!/bin/bash
#
# Author: Eric Gebhart
#
# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments.
#
# Function: Copy the given file to a temporary directory so mutt
# Won't delete it before it is read by the application.
#
# Along the way, discern the file type or use the type
# That is given.
#
# Finally use 'open' or 'open -a' if the third argument is
# given.
#
#
# Arguments:
#
# $1 is the file
# $2 is the type - for those times when file magic isn't enough.
# I frequently get html mail that has no extension
# and file can't figure out what it is.
#
# Set to '-' if you don't want the type to be discerned.
# Many applications can sniff out the type on their own.
# And they do a better job of it too.
#
# Open Office and MS Office for example.
#
# $3 is open with. as in open -a 'open with this .app' foo.xls
#
# Examples: These are typical .mailcap entries which use this program.
#
# Image/JPEG; /Users/vdanen/.mutt/view_attachment %s
# Image/PNG; /Users/vdanen/.mutt/view_attachment %s
# Image/GIF; /Users/vdanen/.mutt/view_attachment %s
#
# Application/PDF; /Users/vdanen/.mutt/view_attachment %s
#
# #This HTML example passes the type because file doesn't always work and
# #there aren't always extensions.
#
# text/html; /Users/vdanen/.mutt/view_attachment %s html
#
# # If your Start OpenOffice.org.app is spelled with a space like this one, <--
# # then you'll need to precede the space with a \ . I found that too painful
# # and renamed it with an _.
#
# Application/vnd.ms-excel; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app'
# Application/msword; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app'
#
#
# Debugging: If you have problems set debug to 'yes'. That will cause a debug file
# be written to /tmp/mutt_attach/debug so you can see what is going on.
#
# See Also: The man pages for open, file, basename
#
# the tmp directory to use.
tmpdir="$HOME/.tmp/mutt_attach"
# the name of the debug file if debugging is turned on.
debug_file=$tmpdir/debug
# debug. yes or no.
#debug="no"
debug="yes"
type=$2
open_with=$3
# make sure the tmpdir exists.
mkdir -p $tmpdir
# clean it out. Remove this if you want the directory
# to accumulate attachment files.
rm -f $tmpdir/*
# Mutt puts everything in /tmp by default.
# This gets the basic filename from the full pathname.
filename=`basename $1`
# get rid of the extenson and save the name for later.
file=`echo $filename | cut -d"." -f1`
if [ $debug = "yes" ]; then
echo "1:" $1 " 2:" $2 " 3:" $3 > $debug_file
echo "Filename:"$filename >> $debug_file
echo "File:"$file >> $debug_file
echo "===========================" >> $debug_file
fi
# if the type is empty then try to figure it out.
if [ -z $type ]; then
file $1
type=`file -bi $1 | cut -d"/" -f2`
fi
# if the type is '-' then we don't want to mess with type.
# Otherwise we are rebuilding the name. Either from the
# type that was passed in or from the type we discerned.
if [ $type = "-" ]; then
newfile=$filename
else
newfile=$file.$type
fi
newfile=$tmpdir/$newfile
# Copy the file to our new spot so mutt can't delete it
# before the app has a chance to view it.
cp $1 $newfile
if [ $debug = "yes" ]; then
echo "File:" $file "TYPE:" $type >> $debug_file
echo "Newfile:" $newfile >> $debug_file
echo "Open With:" $open_with >> $debug_file
fi
# If there's no 'open with' then we can let preview do it's thing.
# Otherwise we've been told what to use. So do an open -a.
if [ -z $open_with ]; then
open $newfile
else
open -a "$open_with" $newfile
fi

@ -15,6 +15,12 @@ l () {
fi
}
# s as in 'show' / quicklook script
s () {
trap 'exit 0' 2 #traps Ctrl-C (signal 2)
qlmanage -p $1 >& /dev/null
}
take () {
mkdir -p $1
cd $1

Loading…
Cancel
Save