Bash history handling with multiple terminals


I use mainly Terminator, and it's usually opened with 3 split terminal windows. I also use Gnome terminal for various reasons.
I'm wondering how is bash history handled in this case as I sometimes miss previously issued commands when I run history

For example, my prompt shows current bash history line (\!) and if I launch Terminator with 3 split terminal windows I get same history line (let's say 100) on all terminals. Which history will be saved?

Also launching Gnome Terminal after using Terminator I get line 100 at startup regardless all commands issued before in Terminator

The bash session that is saved is the one for the terminal that is closed the latest. If you want to save the commands for every session, you could use the trick explained here.

export PROMPT_COMMAND='history -a'

To quote the manpage: “If set, the value is executed as a command prior to issuing each primary prompt.”

So every time my command has finished, it appends...

0 0

Bash shell is the default linux distribution you get with a Linux image, including MacOS. It is also available for installation on Windows 10. Just like a smart shell would do, it save the history of commands you run and save them in a history file.

Bash maintains the list of commands internally in memory while it’s running. They are written into .bash_history on exit.

If you want to make sure that they’re always written immediately, you can put that command into your PROMPT_COMMAND variable:

export PROMPT_COMMAND='history -a'

Setting History Defaults

Before we start using the history, let’s modify some bash settings to make it more useful.

Bash allows us to adjust the number of previous commands that it stores in history. It handles it in two different ways: the HISTFILESIZE parameter configures how many commands are stored in the history file, while the HISTSIZE controls the number stored in memory for the current session.

Open the...

0 0

This question already has an answer here:

Everyone knows (or should know!) that on a terminal the up and down arrow keys are used to navigate through the history of used commands.

When you use the terminal on a daily basis, your command history will likely be a long list of many different commands, thus causing navigation less easy. Just as an example, let's say that a month ago I used the iwconfig with a determined set of parameters (like I said, it's just an example, I don't need to mess with it right now), how can I recall that particular command with all its arguments and parameters without having to navigate back through hundreds of history commands?

I know that I could use history to have a list of previously used commands and !n to re-execute the n command on the said list, but when the history grows large, it is not very practical too.

The ideal thing would be to have something that will let me use some hotkey to navigate through history but just...

0 0

Many packages could be listed in any of several categories, but for the table here just one has to be chosen, usually following the Free Software Directory.

Bug reports: for any discussion about specific manuals, please contact the package maintainers. For discussion about this page in particular (for example, if you are a GNU maintainer and want to correct or discuss your entry), contact .

Archiving* Cpio Manage cpio and tar file archives. [cpio home]* Gzip General file (de)compression (using lzw). [gzip home]* Paxutils Manage cpio, tar, and pax file archives. [paxutils home]* Sharutils Archives in shell scripts, uuencode/uudecode. [sharutils home]* Tar Managing tar archives. [tar home]* Xorriso Create, manipulate, burn ISO-9660 filesystems. [xorriso home]Audio* Ccd2cue CCD to CUE sheet conversion. [ccd2cue home]* EMMS Emacs Multimedia System. [emms home]* Gmediaserver UPnP compatible media server. [gmediaserver home]* GNUfm ...
0 0
0 0