Score:3

Different history for different terminals

in flag

I would like to have something like "history environment", so for different consoles I can access different histories.

I have different terminals defined, I would like to have for each terminal its own history:

enter image description here

terdon avatar
cn flag
Do you need this to survive closing the terminal or opening a new one or do you only need this while the terminal is open? Do you want all commands run in the "Local" terminal, for example, to always be in their own history? So that every time you open a "Local" terminal, you only see commands that were run in such a terminal?
Score:5
cn flag

You can do this by defining different history files for each profile. The history file's name is set by the value of the HISTFILE environment variable. Therefore, setting a custom command for each of your terminal profiles which sets this variable to a specific file and then runs bash will give you a history for each profile:

screenshot of gnome-terminal preferences showing the custom command

The command should be:

env HISTFILE=/home/terdon/.bash_history.one bash

Change /home/terdon/.bash_history.one to a name that works on your system, it can be anything you want, but better to have it in your $HOME. Then just set a different file for each profile and you should be done.

cn flag
Minor detail: I'd go with `env HISTFILE=... bash`, i.e. using `env` exactly what it was designed for, rather than using the much more heavyweight `bash` as the wrapper.
terdon avatar
cn flag
@egmont duh! Of course! Thank you, should have thought of that myself.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.