--- rchat.orig 2022-06-15 01:27:18.162405896 +0200 +++ rchat 2022-06-15 01:28:24.339404228 +0200 @@ -291,6 +291,23 @@ RCHAT_INSERT() RCHAT_SEND_MESSAGE ; ${0} && RCHAT_EXIT } +RCHAT_OPEN_URL() { + URL_FOLLOW="$(grep -Po '((((http|https|ftp|ircs)|mailto)|magnet)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' /tmp/rchat-cchat | head -n 1)" + + case "$URL_FOLLOW" in + "") $0 && RCHAT_EXIT ;; + esac + + if [ -e "/usr/bin/xdg-open" ]; then + xdg-open $URL_FOLLOW + else + $BROWSER $URL_FOLLOW + fi + + URL_FOLLOW="" + $0 && RCHAT_EXIT +} + RCHAT_CMD() { clear && RCHAT_HEADER && RCHAT_CAT_MESSAGES @@ -314,6 +331,7 @@ RCHAT_CMD() "instance") RCHAT_INSTANCE_LIST | less ;; "e") $EDITOR /tmp/rchat-editor-message && RCHAT_MESSAGE_TYPE=editor && RCHAT_SEND_MESSAGE ;; "donate") RCHAT_DONATE && $0 && RCHAT_EXIT ;; + "open") RCHAT_OPEN_URL ;; esac ${0} && RCHAT_EXIT } @@ -342,6 +360,7 @@ RCHAT_HELP() printf "\n${HSEP}${COLOR_03} To see a full list of all messages downloaded combined, type ':history'." printf "\n${HSEP}${COLOR_03} To clear the saved history, type ':history clear'." printf "\n${HSEP}${COLOR_03} To leave the instance, type ':leave'. (You can also do ZQ)" + printf "\n${HSEP}${COLOR_03} To open the last URL displayed, type ':open'." printf "\n${HSEP}${COLOR_03} To quit rchat (You'll stay logged in), type ':q'. (You can also do ZZ)${COLOR_01}" printf "\n${HSEP}${COLOR_03} To donate, type ':donate'.${COLOR_01}" }