diff options
-rwxr-xr-x | fzf-url.sh | 5 | ||||
-rwxr-xr-x | fzf-url.tmux | 9 |
2 files changed, 8 insertions, 6 deletions
@@ -16,8 +16,9 @@ elif hash open &>/dev/null; then fi content="$(tmux capture-pane -J -p)" -urls=($(echo "$content" |grep -oE '\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')) -ips=($(echo "$content" |grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9].*)?' | sed 's/\(.*\)/http:\/\/\1/')) +IFS=' \n' +read -ra urls <<< "$(echo "$content" |grep -oE '\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')" +read -ra ips <<< "$(echo "$content" |grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9].*)?' | sed 's/\(.*\)/http:\/\/\1/')" merge() { for item in "$@" ; do diff --git a/fzf-url.tmux b/fzf-url.tmux index a156cec..f4ab019 100755 --- a/fzf-url.tmux +++ b/fzf-url.tmux @@ -4,15 +4,16 @@ # Email: wenxuangm@gmail.com # Created: 2018-04-06 09:30 #=============================================================================== -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) && cd "$SCRIPT_DIR" +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # $1: option # $2: default value tmux_get() { - local value="$(tmux show -gqv "$1")" - [ -n "$value" ] && echo $value || echo $2 + local value + value="$(tmux show -gqv "$1")" + [ -n "$value" ] && echo "$value" || echo "$2" } -key="$(tmux_get "@fzf-url-bind" "u")" +key="$(tmux_get '@fzf-url-bind' 'u')" tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh"; |