Skip to content

Commit 93ca6fc

Browse files
wfxrjoshmedeski
andcommitted
feat: add GitHub repos support
Co-authored-by: Josh Medeski <[email protected]>
1 parent fe810df commit 93ca6fc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fzf-url.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@ urls=$(echo "$content" |grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:
3939
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/')
4040
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/')
4141
gits=$(echo "$content" |grep -oE '(ssh://)?git@\S*' | sed 's/:/\//g' | sed 's/^\(ssh\/\/\/\)\{0,1\}git@\(.*\)$/https:\/\/\2/')
42+
gh=$(echo "$content" |grep -oE "['\"]([A-Za-z0-9-]*/[.A-Za-z0-9-]*)['\"]" | sed "s/'\|\"//g" | sed 's#.#https://github.com/&#')
4243

4344
if [[ $# -ge 1 && "$1" != '' ]]; then
4445
extras=$(echo "$content" |eval "$1")
4546
fi
4647

47-
items=$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}" "${extras[@]}" |
48+
items=$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${gh[@]}" "${ips[@]}" "${gits[@]}" "${extras[@]}" |
4849
grep -v '^$' |
4950
sort -u |
5051
nl -w3 -s ' '
5152
)
5253
[ -z "$items" ] && tmux display 'tmux-fzf-url: no URLs found' && exit
5354

54-
printf '%s' "$items" | fzf_filter | awk '{print $2}' | \
55+
fzf_filter <<< "$items" | awk '{print $2}' | \
5556
while read -r chosen; do
5657
open_url "$chosen" &>"/tmp/tmux-$(id -u)-fzf-url.log"
5758
done

0 commit comments

Comments
 (0)