Skip to content

Commit 096d492

Browse files
gavvvrwfxr
authored andcommitted
Compatibility with Mac's pre-4.0 Bash
This will eliminate the need to additionally install Bash v4+ on Mac
1 parent 5097bb4 commit 096d492

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fzf-url.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ else
3535
content="$(tmux capture-pane -J -p -S -"$limit")"
3636
fi
3737

38-
mapfile -t urls < <(echo "$content" |grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')
39-
mapfile -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/')
40-
mapfile -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/')
41-
mapfile -t gits < <(echo "$content" |grep -oE '(ssh://)?git@\S*' | sed 's/:/\//g' | sed 's/^\(ssh\/\/\/\)\{0,1\}git@\(.*\)$/https:\/\/\2/')
38+
urls=$(echo "$content" |grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')
39+
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/')
40+
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/')
41+
gits=$(echo "$content" |grep -oE '(ssh://)?git@\S*' | sed 's/:/\//g' | sed 's/^\(ssh\/\/\/\)\{0,1\}git@\(.*\)$/https:\/\/\2/')
4242

4343
if [[ $# -ge 1 && "$1" != '' ]]; then
44-
mapfile -t extras < <(echo "$content" |eval "$1")
44+
extras=$(echo "$content" |eval "$1")
4545
fi
4646

4747
items=$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}" "${extras[@]}" |
@@ -51,7 +51,7 @@ items=$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}" "${extr
5151
)
5252
[ -z "$items" ] && tmux display 'tmux-fzf-url: no URLs found' && exit
5353

54-
mapfile -t chosen < <(fzf_filter <<< "$items" | awk '{print $2}')
54+
chosen=$(fzf_filter <<< "$items" | awk '{print $2}')
5555

5656
for item in "${chosen[@]}"; do
5757
open_url "$item" &>"/tmp/tmux-$(id -u)-fzf-url.log"

0 commit comments

Comments
 (0)