42

In your .tmux.conf file you can set the window history with something like:

set -g history-limit 4096

Is there a way to set an unlimited history for each window?

1
  • The question title could be veeeeeeeeeery misleading. The actual topic discussed is "scrollback length" and not "history of executed commands"
    – mega.venik
    Commented Jul 4 at 17:07

4 Answers 4

57

Do NOT set it to something like:

set -g history-limit 999999999

This will pre-allocate that many lines (and hence memory) for all windows, which is going to cripple your machine the more history is stored over time.

Set it to something large, by all means but not THIS large.

8
  • Thanks, this is good to know. I guess you just have to balance the size with comfort that everything you dump will be there.
    – kenny
    Commented Dec 18, 2013 at 21:18
  • 2
    Looks like the time is comming where we need to do actual benchmarks :-) Commented Jun 20, 2014 at 15:00
  • 14
    Ha, I did a comparison, starting tmux with either of the history-limit values; Memory is the same after start, so tmux does not preallocate the scrollback buffer. (Of course, that does not solve the practical problem) Commented Jun 20, 2014 at 16:07
  • 4
    I found another interesting investigation into tmux's memory usage at blog.42.be/2015/02/tmux-memory-usage-on-linux.html
    – Silveri
    Commented Aug 13, 2015 at 7:44
  • 4
    To sum up @Silveri's link: tmux had a bug, as it did not release its buffers. Fixed. (as of google group and also merged if I did not misunderstand github.com/42wim/tmux/network)
    – serv-inc
    Commented Apr 18, 2016 at 13:25
36

From what I can tell, you can only do this in a "practical" fashion, by setting the history to an absurdly large number. e.g.:

set -g history-limit 999999999

UPDATE: see the other answer as to why you don't want to use a number this high. Something more reasonable (less 9's) would be best.

UPDATE again: perhaps pre-allocation doesn't occur. @Volker Siegel's comment on the other answer indicates that setting the value does not cause memory allocation.

3
  • See warning in the answer of @ThomasAdam. Commented Jun 19, 2014 at 10:32
  • 1
    See my comment on his answer. :)
    – kenny
    Commented Jun 20, 2014 at 13:54
  • @kenny how do you know its set? is there a way to query the currently active limit on tmux?
    – Hossein
    Commented Aug 3, 2020 at 2:55
3

An alternative is to have a reasonably big history and install the tmux logging plugin

I like to have logging in all tmux windows turned on by default. I log to a 'tmux_log' directory and have a cron job to delete very old logs.

1

If you're worried about your memory exploding and only care about a temporary solution (like one noisy pane), you can just set the value in your tmux prompt. (assuming you have you prefix set to the <Ctrl+B> default)

<Ctrl+B>:

Then you'll see a prompt at the bottom of the screen where you can type:

set history-limit 9999999

or whatever limit you want and then press enter.

This lasts for the whole tmux session, in all panes and windows, but won't be persisted in the config and is easily reset in the same way it was set.

2
  • 2
    You can also simply run internal tmux commands like these on the command line, eg tmux set history-limit 9999
    – Kusalananda
    Commented Apr 19, 2023 at 14:46
  • not change current window history size ,why? need restart ?
    – CS QGB
    Commented Apr 16 at 9:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .