tmux: list command-prompt history?
Asked Answered
G

1

14

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?

Grainfield answered 8/2, 2017 at 1:0 Comment(2)
Voting to close this question as off-topic. Please note that Stackoverflow is for programming related questions only. Please review the help center for what topics can be asked here. The help also has suggestions for other SE sites where this question may be appropriate.Outspoken
Please read stackoverflow.com/help/how-to-ask , stackoverflow.com/help/dont-ask , stackoverflow.com/help/mcve and take the tour before posting more Qs here. Good luck.Knute
H
10

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.

Hydromagnetics answered 13/2, 2017 at 9:56 Comment(3)
It works only if I put -s option : set -sg history-file ~/.tmux_historyValenba
Where does it store the history when it's not set?Illassorted
@NikhilCSB From docs history-file path If not empty, a file to which tmux will write command prompt history on exit and load it from on start. So history is available while your server is active, and after you close it history is dropped. Or you could have history-file set somewhere you can check it with tmux show-option -g history-fileHydromagnetics

© 2022 - 2024 — McMap. All rights reserved.