0

I am looking for functionality which can quickly allow me to select a command from a list of commands and paste it to command line. tmux prefix+= provides a buffer from which I can choose and select the copied item however I am looking for similar way to operate on static list of commands & paste as needed.

testcase: Once you are in tmux, use shortcut to open command list ( similar to tmux buffer),choose the command, hit enter which should paste it in command line

1 Answer 1

1

This is not possible to do in regular tmux but luckily there's a mod allowing to do that http://ershov.github.io/tmux/ (I'm the author).

Also, it adds full-fledged scripting support, allows multiple 'mode' commands binding, variables, loops, and so on.

There is an example doing similar thing to what you need in https://github.com/ershov/tmux/blob/master/example_tcl_tmux.tcl :

bind H tcl {
    if {[f #{pane_current_command}] eq "bash"} {
        choose-from-list -onselect {
            send-keys $_
        } -- {*}[
            lcomp {$x} for x in [
                split [read_file ~/.bash_history] "\n"
            ] if {[string range $x 0 0] ne "#"}
        ]
        end-of-list
        up
    } else {
        print "Bash?"
    }
}

What this binding does is:

  1. Reads .bash_history making selection list from it
  2. Once selected, sends the string to bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.