pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
696 stars 164 forks source link

Open URLs in message (with solution) #1556

Closed atrent closed 3 years ago

atrent commented 3 years ago

I need a simple mechanism to open (a choice of) URLs in a message, this is my script:

#!/bin/bash

# TODO launch default browser? (e.g. i3-sensible-browser)

estrattore(){
    grep -o 'http[s]*://.*' |while
     read url
    do
     echo -n "$url | off "
    done
}

if
 ! pidof chromium
then
 dialog --infobox "ATTENZIONE: no chromium open! (this script becomes blocking for alot)" 0 0
fi

URLS=$(estrattore)
#echo $URLS

if
 ! test -z "$URLS"
then
    scelta=$(mktemp)
    dialog --checklist URLs 0 0 0 $URLS 2> $scelta
    #cat $scelta

    for url in $(cat $scelta)
    do
        chromium $url 2>/dev/null &
    done

    rm $scelta
fi

It uses dialog to let me tick a selection of the URLs found in msg, then it opens chromium (or whatever you want) on the selection, I have hooked it to a key:

    [[thread]]
            'u' = pipeto --format=decoded ~/bin/openUrls.sh
pazz commented 3 years ago

There are several tools for this sort of thing, which eat text on stdin and provide a curses ui for selecting contained URLs. Try urlscan:

u = pipeto 'urlscan -c 2> /dev/null'

I'm also using a custom hook to open the contained html directly i na browser:

https://github.com/pazz/alot/wiki/Contrib-Hooks#open-html-emails-in-external-browser

HTH, P

Quoting atrent (2020-11-30 10:05:58)

I need a simple mechanism to open (a choice of) URLs in a message, this is my script:

!/bin/bash

TODO launch default browser? (e.g. i3-sensible-browser)

estrattore(){ grep -o 'http[s]://.' |while read url do echo -n "$url | off " done }

if ! pidof chromium then dialog --infobox "ATTENZIONE: no chromium open! (this script becomes blocking for alot)" 0 0 fi

URLS=$(estrattore)

echo $URLS

if ! test -z "$URLS" then scelta=$(mktemp) dialog --checklist URLs 0 0 0 $URLS 2> $scelta

cat $scelta

    for url in $(cat $scelta)
    do
            chromium $url 2>/dev/null &
    done

    rm $scelta

fi

It uses dialog to let me tick a selection of the URLs found in msg, the it opens chromium (or whatever you want) on the selection, I have hooked it to a key:

    [[thread]]
                    'u' = pipeto --format=decoded ~/bin/openUrls.sh

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.*

atrent commented 3 years ago

Perfect! I simply missed it ;) Trash this thread then, sorry (or leave it here as a memento)

pazz commented 3 years ago

Just FTR, I use the same custom hook also in envelope mode when I sent html mails (using pandoc)..

Quoting atrent (2020-11-30 10:42:47)

Closed #1556.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.*