From f338301bd6de59efae91746e5bbac4b0c09a1639 Mon Sep 17 00:00:00 2001 From: Wenxuan Zhang Date: Sun, 30 May 2021 17:11:08 +0800 Subject: refactor: option name and default behavior (#14) --- fzf-url.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'fzf-url.sh') diff --git a/fzf-url.sh b/fzf-url.sh index 4bd4fd8..1631d09 100755 --- a/fzf-url.sh +++ b/fzf-url.sh @@ -19,7 +19,15 @@ open_url() { fi } -content="$(tmux capture-pane -J -p -S -"$2")" + +limit='screen' +[[ $# -ge 2 ]] && limit=$2 + +if [[ $limit == 'screen' ]]; then + content="$(tmux capture-pane -J -p)" +else + content="$(tmux capture-pane -J -p -S -"$limit")" +fi mapfile -t urls < <(echo "$content" |grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]') mapfile -t wwws < <(echo "$content" |grep -oE 'www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/\S+)*' |sed 's/^\(.*\)$/http:\/\/\1/') -- cgit v1.2.3