st-url fix.

This commit is contained in:
Bartek Stalewski 2021-11-08 14:54:36 +01:00
parent 7c1baf8809
commit f699089c50

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)" urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9.,/@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars: urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
grep -aEo "$urlregex" | # grep only urls as defined above. grep -aEo "$urlregex" | # grep only urls as defined above.
@ -12,8 +12,8 @@ urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sideb
while getopts "hoc" o; do case "${o}" in while getopts "hoc" o; do case "${o}" in
h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;; h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
o) chosen="$(echo "$urls" | dmenu -l 20 -i -p 'open')" o) chosen="$(echo "$urls" | dmenu -c -l 20 -i)"
setsid xdg-open "$chosen" >/dev/null 2>&1 & ;; setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
c) echo "$urls" | dmenu -i -p 'copy' -l 10 | tr -d '\n' | xsel -l /dev/null ;; c) echo "$urls" | dmenu -c -l 20 -i| tr -d '\n' | xsel -l /dev/null ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;; *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
esac done esac done