all repos — dotfiles @ c8b57d5f847c9d840b3174674a1a083aa0434ef1

my *nix dotfiles

bin/xurls (view raw)

 1#!/usr/bin/env bash
 2# extract urls in current tmux pane and pass it to fzy
 3
 4content="$(tmux capture-pane -J -p)"
 5
 6mapfile -t urls < <(echo "$content" | grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')
 7mapfile -t wwws < <(echo "$content" | grep -oE '(http?s://)?www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/\S+)*' | grep -vE '^https?://' |sed 's/^\(.*\)$/http:\/\/\1/')
 8mapfile -t ips  < <(echo "$content" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]{1,5})?(/\S+)*' |sed 's/^\(.*\)$/http:\/\/\1/')
 9mapfile -t gits < <(echo "$content" | grep -oE '(ssh://)?git@\S*' | sed 's/:/\//g' | sed 's/^\(ssh\/\/\/\)\{0,1\}git@\(.*\)$/https:\/\/\2/')
10
11items="$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}" |
12    grep -v '^$' |
13    sort -u |
14    nl -w3 -s ' '
15)"
16
17[ -z "$items" ] && exit
18
19u="$(fzy <<< "$items" | awk '{ print $2 }')"
20luakit "$u"