summaryrefslogblamecommitdiff
path: root/execurl
blob: a9ee2ab314879f787b33b519062da4b53724d770 (plain) (tree)























                                                                               


                                                                       



















                                                                                                                                                                                       
#!/usr/bin/env bash
# The MIT License (MIT)
# 
# Copyright (c) 2011-2015 Ismaël Bouya http://www.normalesup.org/~bouya/
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


# Feel like tipping/donating? https://www.immae.eu/licenses_and_tipping


# To be used together with remove_attachements script in procmail and urlview to
# visualize and keep some attachements once they are removed from the email
# Example urlview updated configuration:
# REGEXP ((((http|https|ftp|gopher)|mailto):(//)?[^ <>"\t]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">\):]|(file|keepdir)://([^\t\n\r\\ ]+(\\ |\\)?)+)
# COMMAND execurl

export chemin=x"$1"
if [ "${chemin:0:8}" = "xfile://" ]; then
   fichier="${1:7}"
   fichierlu="${fichier//\\ / }"
   if [ ! -f "$fichierlu" ]; then
       exec run-mailcap "${fichierlu//.attachements/Mail/.attachements}"
   else
       exec run-mailcap "$fichierlu"
   fi
elif [ "${chemin:0:11}" = "xkeepdir://" ]; then
   mv "${1:10}" "$HOME/Mail/.attachements/"
else
   exec w3m "$1"
fi