Skip to content

Commit

Permalink
Add Git SSH URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
igorepst committed Apr 3, 2019
1 parent 02ab9d9 commit f3f7d27
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fzf-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#===============================================================================

fzf_cmd() {
fzf-tmux -d 35% --multi --exit-0 --cycle --reverse --bind='ctrl-r:toggle-all' --bind='ctrl-s:toggle-sort'
fzf-tmux -d 35% --multi --exit-0 --cycle --reverse --bind='ctrl-r:toggle-all' --bind='ctrl-s:toggle-sort' --no-preview
}

if hash xdg-open &>/dev/null; then
Expand All @@ -19,14 +19,15 @@ content="$(tmux capture-pane -J -p)"
urls=($(echo "$content" |grep -oE '(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]'))
wwws=($(echo "$content" |grep -oE 'www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/\S+)*' |sed 's/^\(.*\)$/http:\/\/\1/'))
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/'))
gits=($(echo "$content" |grep -oE '(ssh://)?git@\S*' | sed 's/:/\//g' | sed 's/^\(ssh\/\/\/\)\{0,1\}git@\(.*\)$/https:\/\/\2/'))

merge() {
for item in "$@" ; do
echo "$item"
done
}

merge "${urls[@]}" "${wwws[@]}" "${ips[@]}"|
merge "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}"|
sort -u |
nl -w3 -s ' ' |
fzf_cmd |
Expand Down

0 comments on commit f3f7d27

Please sign in to comment.