From 41dbd31664c8835c1702ba5991f93b11f79d919a Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Wed, 23 Aug 2023 16:37:42 +0000 Subject: [PATCH] Addendum, $HISTFILE is not accessible within settings script. --- one-time-stuff/basic-settings.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/one-time-stuff/basic-settings.sh b/one-time-stuff/basic-settings.sh index dba854c..c7915eb 100755 --- a/one-time-stuff/basic-settings.sh +++ b/one-time-stuff/basic-settings.sh @@ -79,10 +79,10 @@ echo "----- Setup robust bash history? in ~/.bashrc -------" read -p 'split bash history by tty in realtime? [y/N]: ' add_history case $add_history in [Yy]* ) - echo 'backing up ~/.bashrc' + echo 'Backing up ~/.bashrc' cp "$HOME/.bashrc" "$HOME/.bashrc.backup" - echo 'commenting out existing bash history config' + echo 'Comment existing history config' sed -i '/^\(HISTCONTROL\|HISTFILESIZE\|HISTFILE\|HISTIGNORE\|HISTSIZE\|HISTTIMEFORMAT\|shopt -s histappend\|shopt -s histreedit\|shopt -s histverify\)/s/^/# ABS #/' "$HOME/.bashrc" echo 'Appending ~/.bashrc' @@ -110,12 +110,14 @@ fi TERM ) >> "$HOME/.bashrc" - echo 'move existing history file' - mv "$HISTFILE" "$HOME/tmp_hist_file" + echo 'Move existing history file' + if [ -f "${HOME}/.bash_history" ]; then + mv "${HOME}/.bash_history" "$HOME/tmp_hist_file" + fi mkdir "${HOME}/.bash_history" mv "$HOME/tmp_hist_file" "${HOME}/.bash_history/$(tty | sed 's/\//-/g;s/^-//g')" - echo 'update live config' + echo 'Update live config' shopt -s histappend shopt -u histreedit shopt -u histverify