Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created February 11, 2011 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonty/822787 to your computer and use it in GitHub Desktop.
Save Jonty/822787 to your computer and use it in GitHub Desktop.
Temporarily uploads email attachments from mutt to a web-accessible remote directory for viewing.
image/*; ~/.showinbrowser.sh %s
application/*; ~/.showinbrowser.sh %s
audio/*; ~/.showinbrowser.sh %s
text/*; ~/.showinbrowser.sh %s
Add this line:
set mailcap_path="~/.mutt-mailcap"
#!/bin/sh
# Customise these, obviously
REMOTEHOST='jonty.co.uk'
REMOTEPATH='/home/jonty/bits/attachments/'
HTTPPATH='http://jonty.co.uk/bits/attachments/'
FILENAME=`echo $1 | grep -E -o '[^\/]+$'`
clear
echo "Copying file to $REMOTEHOST..."
scp $1 "$REMOTEHOST:$REMOTEPATH$FILENAME"
clear
echo "Changing remote permissions..."
ssh $REMOTEHOST -C "chmod 777 '$REMOTEPATH$FILENAME'"
clear
echo "\nOpen $HTTPPATH$FILENAME to view the attachment.\n"
echo "Press enter to continue"
read wait
clear
echo "Removing remote file..."
ssh $REMOTEHOST -C "rm '$REMOTEPATH$FILENAME'"
clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment