Using fzf and tmux to find and copy urls

I’ve been using tmux-url-select for a long time now. It works great but will only grab whats on the screen. So any history or urls in any other pane or session can be difficult to find. Lately, I’ve been optimizing my tmux to make the experience better after putting it off for too long.

With the following shell script, I can launch fzf in a popup and capture every url in every pane across all windows and sessions.

Drop this script in your path

#!/usr/bin/env sh

capturePanes() {
    for pane in $(tmux list-panes -a -F "#S:#I.#P"); do
        tmux capture-pane -S - -p -t "$pane"
    done
}

capturePanes | 
    grep -E -o "https?://[^ ]+" | 
    sort | 
    uniq | 
    fzf --header copy-url --bind "enter:execute-silent(wl-copy {})+accept"

I’m using wayland, so I use wl-copy. Replace it with whatever copy tool you use.

And add the following to your tmux config

bind -n M-U display-popup -E "tmuxurls"

Use whatever keybind you want. Here I use alt-U