--- rchat 2022-06-13 09:47:05.046528474 +0200 +++ rchat 2022-06-13 10:24:15.472680433 +0200 @@ -241,6 +241,23 @@ RCHAT_CHECK_UPDATE() ${0} && RCHAT_EXIT # Reset the script if there are new messages } +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 @@ -263,6 +280,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 } @@ -291,6 +309,7 @@ RCHAT_HELP() printf "\n-${COLOR_03} To see a full list of all messages downloaded combined, type ':history'." printf "\n-${COLOR_03} To clear the saved history, type ':history clear'." printf "\n-${COLOR_03} To leave the instance, type ':leave'." + printf "\n-${COLOR_03} To open the last URL displayed, type ':open'." printf "\n-${COLOR_03} To quit rchat (You'll stay logged in), type ':q'.${COLOR_01}" printf "\n-${COLOR_03} To donate, type ':donate'.${COLOR_01}" }