How do I make my bash login session âautosaveâ its history? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
How to protect against purge of bash history?
1 answer
Preserve bash history in multiple terminal windows
20 answers
IIANM, bash saves its history to ~/.bash_history
(or to $HISTFILE
) on exit from a login shell session. But - what if you want to occasionally persist it for fear of the shell getting prematurely killed (as in SIGKILL or power failure)? Is this possible without burdening the system or the shell session experience?
bash command-history
marked as duplicate by Kiwy, Jeff Schaller, Romeo Ninov, Gilles
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 12:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
How to protect against purge of bash history?
1 answer
Preserve bash history in multiple terminal windows
20 answers
IIANM, bash saves its history to ~/.bash_history
(or to $HISTFILE
) on exit from a login shell session. But - what if you want to occasionally persist it for fear of the shell getting prematurely killed (as in SIGKILL or power failure)? Is this possible without burdening the system or the shell session experience?
bash command-history
marked as duplicate by Kiwy, Jeff Schaller, Romeo Ninov, Gilles
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 12:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
Read about bash eternal history.
â Isaac
May 3 at 10:54
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How to protect against purge of bash history?
1 answer
Preserve bash history in multiple terminal windows
20 answers
IIANM, bash saves its history to ~/.bash_history
(or to $HISTFILE
) on exit from a login shell session. But - what if you want to occasionally persist it for fear of the shell getting prematurely killed (as in SIGKILL or power failure)? Is this possible without burdening the system or the shell session experience?
bash command-history
This question already has an answer here:
How to protect against purge of bash history?
1 answer
Preserve bash history in multiple terminal windows
20 answers
IIANM, bash saves its history to ~/.bash_history
(or to $HISTFILE
) on exit from a login shell session. But - what if you want to occasionally persist it for fear of the shell getting prematurely killed (as in SIGKILL or power failure)? Is this possible without burdening the system or the shell session experience?
This question already has an answer here:
How to protect against purge of bash history?
1 answer
Preserve bash history in multiple terminal windows
20 answers
bash command-history
edited May 3 at 12:32
Gilles
504k1189951522
504k1189951522
asked May 3 at 6:48
einpoklum
1,93641845
1,93641845
marked as duplicate by Kiwy, Jeff Schaller, Romeo Ninov, Gilles
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 12:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Kiwy, Jeff Schaller, Romeo Ninov, Gilles
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
May 3 at 12:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
Read about bash eternal history.
â Isaac
May 3 at 10:54
add a comment |Â
2
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
Read about bash eternal history.
â Isaac
May 3 at 10:54
2
2
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
Read about bash eternal history.
â Isaac
May 3 at 10:54
Read about bash eternal history.
â Isaac
May 3 at 10:54
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
By default, Bash saves it's history on exit from shell. Thus it will lose it's current history if it's killed non-gracefully.
You can save your current Bash history by running:
$ history -a
Knowing that, you can make Bash save it's history after each executed command, by running history -a
after each executed command. One way to do is via the Bash prompt:
PROMPT_COMMAND='history -a'
This works because the Bash prompt will execute $PS1
, $PROMPT_COMMAND
, and more, on each new prompt.
Here is a great blog post that got me onto the idea: https://sanctum.geek.nz/arabesque/better-bash-history/
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
By default, Bash saves it's history on exit from shell. Thus it will lose it's current history if it's killed non-gracefully.
You can save your current Bash history by running:
$ history -a
Knowing that, you can make Bash save it's history after each executed command, by running history -a
after each executed command. One way to do is via the Bash prompt:
PROMPT_COMMAND='history -a'
This works because the Bash prompt will execute $PS1
, $PROMPT_COMMAND
, and more, on each new prompt.
Here is a great blog post that got me onto the idea: https://sanctum.geek.nz/arabesque/better-bash-history/
add a comment |Â
up vote
0
down vote
By default, Bash saves it's history on exit from shell. Thus it will lose it's current history if it's killed non-gracefully.
You can save your current Bash history by running:
$ history -a
Knowing that, you can make Bash save it's history after each executed command, by running history -a
after each executed command. One way to do is via the Bash prompt:
PROMPT_COMMAND='history -a'
This works because the Bash prompt will execute $PS1
, $PROMPT_COMMAND
, and more, on each new prompt.
Here is a great blog post that got me onto the idea: https://sanctum.geek.nz/arabesque/better-bash-history/
add a comment |Â
up vote
0
down vote
up vote
0
down vote
By default, Bash saves it's history on exit from shell. Thus it will lose it's current history if it's killed non-gracefully.
You can save your current Bash history by running:
$ history -a
Knowing that, you can make Bash save it's history after each executed command, by running history -a
after each executed command. One way to do is via the Bash prompt:
PROMPT_COMMAND='history -a'
This works because the Bash prompt will execute $PS1
, $PROMPT_COMMAND
, and more, on each new prompt.
Here is a great blog post that got me onto the idea: https://sanctum.geek.nz/arabesque/better-bash-history/
By default, Bash saves it's history on exit from shell. Thus it will lose it's current history if it's killed non-gracefully.
You can save your current Bash history by running:
$ history -a
Knowing that, you can make Bash save it's history after each executed command, by running history -a
after each executed command. One way to do is via the Bash prompt:
PROMPT_COMMAND='history -a'
This works because the Bash prompt will execute $PS1
, $PROMPT_COMMAND
, and more, on each new prompt.
Here is a great blog post that got me onto the idea: https://sanctum.geek.nz/arabesque/better-bash-history/
edited May 3 at 8:47
answered May 3 at 8:23
aude
333
333
add a comment |Â
add a comment |Â
2
This is a good read - BashFAQ/088 - How can I avoid losing any history lines?
â Inian
May 3 at 6:53
@Yaron: That question is related, not the same, since I'm not addressing the race condition. Also, it doesn't have a very satisying answer...
â einpoklum
May 3 at 7:46
@einpoklum - the answer describes: How turn history on with every command - won't it answer your needs?
â Yaron
May 3 at 7:53
Read about bash eternal history.
â Isaac
May 3 at 10:54