How do you share history between terminals in zsh?
How can it be achieved so that every command that is entered, is visible in every open terminal's history?
When having multiple terminals open, the history isn't shared, i.e. what you entered in one terminals history, doesn't show up in another one. Think of an alternative to Bash's PROMPT_COMMAND="history -a"
(which saves the history before the prompt is beeing displayed).
command-line history zsh
add a comment |
How can it be achieved so that every command that is entered, is visible in every open terminal's history?
When having multiple terminals open, the history isn't shared, i.e. what you entered in one terminals history, doesn't show up in another one. Think of an alternative to Bash's PROMPT_COMMAND="history -a"
(which saves the history before the prompt is beeing displayed).
command-line history zsh
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27
add a comment |
How can it be achieved so that every command that is entered, is visible in every open terminal's history?
When having multiple terminals open, the history isn't shared, i.e. what you entered in one terminals history, doesn't show up in another one. Think of an alternative to Bash's PROMPT_COMMAND="history -a"
(which saves the history before the prompt is beeing displayed).
command-line history zsh
How can it be achieved so that every command that is entered, is visible in every open terminal's history?
When having multiple terminals open, the history isn't shared, i.e. what you entered in one terminals history, doesn't show up in another one. Think of an alternative to Bash's PROMPT_COMMAND="history -a"
(which saves the history before the prompt is beeing displayed).
command-line history zsh
command-line history zsh
edited Jul 12 '12 at 2:47
MJB
asked Jan 28 '11 at 2:04
MJBMJB
1,03411021
1,03411021
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27
add a comment |
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27
add a comment |
2 Answers
2
active
oldest
votes
The following options would be applicable:
To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
To read the history file everytime history is called upon as well as the functionality from
inc_append_history
:
setopt share_history
These can be set in your .zshrc
file.
Related for bash:
- Is it possible to make writing to .bash_history immediate?
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
@opert is correct:setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention ofsetopt inc_append_history
? It obscures the actual answer.
– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if yousetopt | grep hist
will getincappendhistory
andsharehistory
.
– Pablo Bianchi
Oct 5 '17 at 21:16
add a comment |
If you use Robby Russell’s awesome OhMyZSH, it will take care of this and more.
See https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/history.zsh
That includes setopt inc_append_history
.
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f23630%2fhow-do-you-share-history-between-terminals-in-zsh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following options would be applicable:
To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
To read the history file everytime history is called upon as well as the functionality from
inc_append_history
:
setopt share_history
These can be set in your .zshrc
file.
Related for bash:
- Is it possible to make writing to .bash_history immediate?
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
@opert is correct:setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention ofsetopt inc_append_history
? It obscures the actual answer.
– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if yousetopt | grep hist
will getincappendhistory
andsharehistory
.
– Pablo Bianchi
Oct 5 '17 at 21:16
add a comment |
The following options would be applicable:
To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
To read the history file everytime history is called upon as well as the functionality from
inc_append_history
:
setopt share_history
These can be set in your .zshrc
file.
Related for bash:
- Is it possible to make writing to .bash_history immediate?
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
@opert is correct:setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention ofsetopt inc_append_history
? It obscures the actual answer.
– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if yousetopt | grep hist
will getincappendhistory
andsharehistory
.
– Pablo Bianchi
Oct 5 '17 at 21:16
add a comment |
The following options would be applicable:
To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
To read the history file everytime history is called upon as well as the functionality from
inc_append_history
:
setopt share_history
These can be set in your .zshrc
file.
Related for bash:
- Is it possible to make writing to .bash_history immediate?
The following options would be applicable:
To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
To read the history file everytime history is called upon as well as the functionality from
inc_append_history
:
setopt share_history
These can be set in your .zshrc
file.
Related for bash:
- Is it possible to make writing to .bash_history immediate?
edited 11 mins ago
Chris Stryczynski
2721212
2721212
answered Jan 28 '11 at 2:18
MJBMJB
1,03411021
1,03411021
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
@opert is correct:setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention ofsetopt inc_append_history
? It obscures the actual answer.
– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if yousetopt | grep hist
will getincappendhistory
andsharehistory
.
– Pablo Bianchi
Oct 5 '17 at 21:16
add a comment |
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
@opert is correct:setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention ofsetopt inc_append_history
? It obscures the actual answer.
– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if yousetopt | grep hist
will getincappendhistory
andsharehistory
.
– Pablo Bianchi
Oct 5 '17 at 21:16
4
4
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
"SHARE_HISTORY: This option both imports new commands from the history file, and also causes your typed commands to be appended to the history file (the latter is like specifying INC_APPEND_HISTORY, which should be turned off if this option is in effect)." (From manual emphasis added) i.e. just the INC_APPEND_HISTORY option will do what you want.
– artfulrobot
Oct 20 '14 at 10:30
3
3
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
Actually, just the SHARE_HISTORY option alone will do what you want. The phrase "which should be turned off if this option is in effect" translates to "[INC_APPEND_HISTORY] should be turned off if [SHARE_HISTORY] option is in effect". I've tested this on zsh 5.1.1 on Ubuntu Xenial.
– Linus Arver
Feb 2 '17 at 0:33
1
1
@opert is correct:
setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention of setopt inc_append_history
? It obscures the actual answer.– bonh
Feb 22 '17 at 16:40
@opert is correct:
setopt share_history
is what will accomplish the desired result. @MJB would you be willing to edit your answer to remove the mention of setopt inc_append_history
? It obscures the actual answer.– bonh
Feb 22 '17 at 16:40
Names are case insensitive and underscores are ignored so if you
setopt | grep hist
will get incappendhistory
and sharehistory
.– Pablo Bianchi
Oct 5 '17 at 21:16
Names are case insensitive and underscores are ignored so if you
setopt | grep hist
will get incappendhistory
and sharehistory
.– Pablo Bianchi
Oct 5 '17 at 21:16
add a comment |
If you use Robby Russell’s awesome OhMyZSH, it will take care of this and more.
See https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/history.zsh
That includes setopt inc_append_history
.
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
add a comment |
If you use Robby Russell’s awesome OhMyZSH, it will take care of this and more.
See https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/history.zsh
That includes setopt inc_append_history
.
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
add a comment |
If you use Robby Russell’s awesome OhMyZSH, it will take care of this and more.
See https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/history.zsh
That includes setopt inc_append_history
.
If you use Robby Russell’s awesome OhMyZSH, it will take care of this and more.
See https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/history.zsh
That includes setopt inc_append_history
.
edited Sep 12 '18 at 14:46
bfirsh
32
32
answered Apr 13 '15 at 16:57
james_womackjames_womack
1414
1414
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
add a comment |
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
It's his/hers/its. Important for shell work.
– Cees Timmerman
Oct 13 '16 at 12:36
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
@CeesTimmerman fixed, thank you. It's important for communication in general I believe. What did you mean by "Important for shell work"?
– james_womack
Oct 13 '16 at 19:01
1
1
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
A typo in the shell can corrupt your entire system.
– Cees Timmerman
Oct 13 '16 at 21:52
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f23630%2fhow-do-you-share-history-between-terminals-in-zsh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
See also related and advanced Q&A: superuser.com/questions/446594/…
– lumbric
Dec 22 '13 at 18:27