tmux-url-select
is a perl script that lets you select URLs with the keyboard.
It integrates with tmux to capture the current pane buffer, switch to a window with highlighted links, and let you select the link you want to open/yank.
It's like the urxvtperls url-select script or urlview, except that it's inspired by the interface of the former and the capture-pane method usually used with the latter.
- Tightly integrated to tmux to prevent flickering when switching to url selection
- No dependencies (Not even ncurses, so no portability either!)
- Uses colors! Configurable colors!
- Configurable external commands too!
- vi-like keybindings (actually just
j
andk
)
Depends on perl
, tmux
and stty
.
Optional and configurable: xdg-open
(can be any url opener or browser) and
xclip
(for yank)
Place it somewhere in your path with name tmux-url-select
and chmod +x
it.
Add this to your .tmux.conf
:
bind some-key-here run tmux-url-select
Where some-key-here is any key you want to use to start url selection.
Personally I use "z" which is an unused keybinding that is really close to my
tmux prefix key (`
)
bind z run tmux-url-select
Once you're inside tmux-url-select, keybindings:
j
or down arrow: downk
or up arrow: up0
-9
: select link by numbery
: yank (copy to clipboard)- Enter or
o
: open link Y
/O
: yank or open link without closingq
: quit
There's a bunch of constants near the top of the file, you can modify them to your liking.
use constant COMMAND => 'xdg-open %s';
use constant YANK_COMMAND => 'echo %s | xclip -i';
use constant SHOW_STATUS_BAR => 1;
use constant VERBOSE_MESSAGES => 0;
use constant TMUX_WINDOW_TITLE => 'Select URL';
use constant PROMPT_COLOR => "\033[42;30m";
use constant ACTIVE_LINK_HIGHLIGHT => "\033[44;4m";
use constant NORMAL_LINK_HIGHLIGHT => "\033[94;1;4m";
Probably should add some explanations. Maybe. For now just go ahead and experiment with stuff.
If a line with a link has a background color, it will get reset after the link. I have no idea how to do this without writing a parser of ansi escape codes or using ncurses properly, so I'm leaving it unfixed as a reminder that as humans we're all flawed in different ways.
Might flicker when selecting links because the whole screen is redrawn. It can't be helped. Works fine for me most of the time.
There used to be a section here about problems launching process but that should be fixed now.
Q: Why perl? It's dead and it sucks, cool kids use node.js nowadays.
A: It's fun. Fun things are fun.