diff -up a/iron b/iron --- a/iron 2022-09-22 16:58:41.352303177 +0200 +++ b/iron 2022-09-22 16:57:54.359304361 +0200 @@ -332,6 +332,29 @@ IRON_INSERT() IRON_SEND_MESSAGE ; ${0} && IRON_EXIT } +# open the url +IRON_OPENURL() { + URL_SRC1="$(grep -Po '((((http|https|ftp|ircs)|mailto)|magnet)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' $WDIR/iron-message | head -n 1)" + URL_SRC2="$(grep -Po '((((http|https|ftp|ircs)|mailto)|magnet)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' $WDIR/iron-messageimg | head -n 1)" + + # image or message link + if [ "$TYPE" != "IMG" ]; then + URL_FOLLOW="$URL_SRC1" + else + URL_FOLLOW="$URL_SRC2" + fi + + # if it's empty, reset + if [ "$URL_FOLLOW" = "" ]; then + $0 && IRON_EXIT + else + command -v xdg-open > /dev/null && xdg-open "$URL_FOLLOW" # Edit this line if you want to switch web browser + $0 && IRON_EXIT + fi + + rm -f $WDIR/iron-messagedata && ${0} && IRON_EXIT +} + # run a command and perform its action IRON_CMD() { @@ -342,6 +365,8 @@ IRON_CMD() "r") rm -f $WDIR/iron-messagedata && ${0} && IRON_EXIT ;; "reset") IRON_RESET ;; "e") touch $WDIR/iron-editor-message ; $EDITOR $WDIR/iron-editor-message && IRON_MESSAGE_TYPE=editor && IRON_SEND_MESSAGE ;; + "o") TYPE=URL && IRON_OPENURL ;; + "i") TYPE=IMG && IRON_OPENURL ;; esac $0 && IRON_EXIT