Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ Clone this repo somewhere and source `fzf-url.tmux` at the config file.

### 📝 Usage

The default key-binding is `u`(of course prefix hit is needed), it can be modified by
The default main key-binding is `u`(of course prefix hit is needed), it can be modified by
setting value to `@fzf-url-bind` at the tmux config like this:

``` tmux
set -g @fzf-url-bind 'x'
```

A secondary key-binding, eliminating newlines from the capture, is `U` , it can be modified by
setting value to `@fzf-url-bind-no-newlines`:

``` tmux
set -g @fzf-url-bind-no-newlines 'X'
```

You can also extend the capture groups by defining `@fzf-url-extra-filter`:

``` tmux
Expand Down Expand Up @@ -68,6 +75,7 @@ set -g @fzf-url-open "firefox"

- You can mark multiple urls and open them at once.
- The tmux theme showed in the screenshot is [tmux-power](https://github.com/wfxr/tmux-power).
- The no-newlines key-binding is useful for some programs badly wrapping long Urls, e.g., neomutt mail client.

### 🔗 Other plugins

Expand Down
6 changes: 5 additions & 1 deletion fzf-url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fzf_filter() {

custom_open=$3
open_url() {
if [[ -n $custom_open ]]; then
if [[ -n $custom_open ]]; then
$custom_open "$@"
elif hash xdg-open &>/dev/null; then
nohup xdg-open "$@"
Expand All @@ -37,6 +37,10 @@ else
content="$(tmux capture-pane -J -p -e -S -"$limit")"
fi

if [[ $4 == 'no-newlines' ]]; then
content=$(echo "$content" | tr -d '\n')
fi

urls=$(echo "$content" |grep -oE '(https?|ftp|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]')
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/')
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/')
Expand Down
5 changes: 4 additions & 1 deletion fzf-url.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ tmux_get() {
}

key="$(tmux_get '@fzf-url-bind' 'u')"
key2="$(tmux_get '@fzf-url-bind-no-newlines' 'U')"
history_limit="$(tmux_get '@fzf-url-history-limit' 'screen')"
extra_filter="$(tmux_get '@fzf-url-extra-filter' '')"
custom_open="$(tmux_get '@fzf-url-open' '')"
echo "$extra_filter" > /tmp/filter

tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit '$custom_open'";
tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit '$custom_open' ''";
tmux bind-key "$key2" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit '$custom_open' 'no-newlines'";