Skip to main content

IMPORTANT: As pointed out by Gilles 'SO- stop being evil'. The approach below can expose your shell to attacks and leak information unintendedly. Proceed with care.


Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

IMPORTANT: As pointed out by Gilles 'SO- stop being evil'. The approach below can expose your shell to attacks and leak information unintendedly. Proceed with care.


Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Building off the answer provided by GroggleGroggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

replaced http://askubuntu.com/ with https://askubuntu.com/
Source Link

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this postthis post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.

function ch () { cd "$@" export HISTFILE="$(pwd)/.bash_history" } 

automatically exporting the new HISTFILE value each time ch is called.

The default behavior in bash only updates your history when you end a terminal session, so this alone will simply save the history to a .bash_history file in whichever folder you happen to end your session from. A solution is mentioned in this post and detailed on this page, allowing you to update your HISTFILE in realtime.

A complete solution consists of adding two more lines to your ~/.bash_profile,

shopt -s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND" 

changing the history mode to append with the first line and then configuring the history command to run at each prompt.

edit history belongs in the edit history, not in the post
Source Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Loading
added 191 characters in body
Source Link
Loading
Source Link
Loading