Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux: list command-prompt history?

I know you can scroll line by line through the tmux command-prompt history (C-b :, then arrow through them).

I'm looking for a way to see a list of the last N-number of commands from that history, but I'm not finding a way to do this.

Is it possible?

like image 655
async_fm Avatar asked Feb 08 '17 01:02

async_fm


People also ask

How do I view tmux history?

copy-mode is the way to view history (and optionally copy stuff out of it). Just run: echo "set -g mouse on" >> ~/. tmux. conf and you'll be able to scroll.

How can I see all command line history?

After you have typed what you are looking for, use the CTRL-R key combination to scroll backward through the history. Use CTRL-R repeatedly to find every reference to the string you've entered. Once you've found the command you're looking for, use [Enter] to execute it.

Where does tmux save history?

Capture History Using Command Terminal After saving the contents to the capture buffer, the next step is to save it in the ~/tmux. log file. This is the designated file where the information gets stored.

Which command is used to view the history list of a terminal?

The GNU history command keeps a list of all the other commands that have been run from that terminal session, then allows you to replay or reuse those commands instead of retyping them.


1 Answers

I don't think there is a way to do this without setting history-file setting(Can tmux save commands to a file, like .bash_history?)

In .tmux.conf add the line

set -g history-file ~/.tmux_history

After that is set, you can use standard file reading programs to get the Nth line. For example:

tail -n N ~/.tmux_history | head -n 1

where N is number of your line.

like image 188
Sardorbek Imomaliev Avatar answered Oct 20 '22 23:10

Sardorbek Imomaliev