Is there a way I can store some unique cmds in a central location while using tmux?

I just want to stash some forgettable cmds in a central location such that I can use that command across windows or panes in tmux.

CTRL + R - gives me access to past commands only from that particular pane or window. Also I tend to lose the history if I reboot or close the tmux session.

1 Answer 1


I'm going to assume your shell is bash, but it really shouldn't matter all that much.

Ctrl+R and history search are typically shell features, not from tmux. Most shells should save the history automatically when exited. See this link for some information on how bash handles history. It explains:

By default, Bash updates its history only on exit, and it overwrites the existing history with the new version. This prevents you from keeping a complete history log, for two reasons:

  • If a user is logged in multiple times, the overwrite will ensure that only the last shell to exit will save its history.
  • If your shell terminates abnormally - for example because of network problems, firewall changes or because it was killed - no history will be written.

And in the next line, gives (hopefully) the answer for how to prevent that:

To solve the first problem, we set the shell option histappend which causes all new history lines to be appended, and ensures that multiple logins do not overwrite each other's history.

Some other shells handle have other ways of dealing with it. For instance, my choice, the fish shell, has a history merge command which "immediately incorporates history changes from other sessions." So if you are running fish in multiple panes, and you need a command from a different pane in your current one, history merge to the rescue.

You must log in to answer this question.

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