'How would I repeat TMUX send command x number of times

Sometimes I find myself coding in some repl, writing and debugging some function/logic with a little bit of trial and error, kind of testing some thought process out.

If it's a simple function, I can tap the up arrow until I find the start, hit enter, do the same thing for a few lines until I hit the spot I want to edit.

But if I run a few other commands and play around with a few other things before my mind gets back to the other idea I'd like to play with more, I might find myself hitting up repeatedly, like 25 times, then enter, and repeat, until I'm ready to edit.

I do this because I had a ahha moment and I don't want to have to rethink all that work and forget my ahha.

Since I'm always in tmux, I figured maybe I could find some way of sending keypresses x number of times.

What I found was, I could hit ctrl+b, then :send Up to simulate my up arrow key.

Being a heavy vim user, I figured there might be a way I can enter the quantity as well, like I can in Vim.

For example, Ctrl+b :15 send Up, or :send 15 Up.

No luck.

I've searched for it using different keywords, no luck either.

I feel like I'm missing something simple and easy but am brainfarting it at the moment.

How could I repeat this send command x number of times?



Solution 1:[1]

Something like this, perhaps?

:run-shell 'for i in $(seq 1 25); do tmux send-keys "#$i" Enter; done'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 atomicstack