diff options
-rw-r--r-- | README.md | 7 | ||||
-rwxr-xr-x | fzf-url.sh | 10 | ||||
-rwxr-xr-x | fzf-url.tmux | 4 |
3 files changed, 17 insertions, 4 deletions
@@ -33,6 +33,13 @@ setting value to `@fzf-url-bind` at the tmux config like this: set -g @fzf-url-bind 'x' ``` +You can also extend the capture groups by defining `@fzf-url-extra-filter`: + +``` tmux +# simple example for capturing files like 'abc.txt' +set -g @fzf-url-extra-filter 'grep -oE "\b[a-zA-Z]+\.txt\b"' +``` + ### 💡 Tips - Use `tab` to mark multiple urls and open them at once. @@ -9,7 +9,7 @@ fzf_cmd() { 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 +if hash xdg-open &>/dev/null; then open_cmd='nohup xdg-open' elif hash open &>/dev/null; then open_cmd='open' @@ -23,16 +23,20 @@ wwws=($(echo "$content" |grep -oE 'www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/ 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/')) +if [[ $# -ge 1 && "$1" != '' ]]; then + extras=($(echo "$content" |eval "$1")) +fi + merge() { for item in "$@" ; do echo "$item" done } -merge "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}"| +merge "${urls[@]}" "${wwws[@]}" "${ips[@]}" "${gits[@]}" "${extras[@]}"| sort -u | nl -w3 -s ' ' | fzf_cmd | awk '{print $2}'| - xargs -n1 -I {} $open_cmd {} &>/dev/null || + xargs -n1 -I {} "$open_cmd" {} &>/dev/null || true diff --git a/fzf-url.tmux b/fzf-url.tmux index f4ab019..6eb145c 100755 --- a/fzf-url.tmux +++ b/fzf-url.tmux @@ -15,5 +15,7 @@ tmux_get() { } key="$(tmux_get '@fzf-url-bind' 'u')" +extra_filter="$(tmux_get '@fzf-url-extra-filter' '')" +echo "$extra_filter" > /tmp/filter -tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh"; +tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter'"; |