From bafde3b7b048cb551ae9ad7c084a98105920da46 Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Wed, 23 Aug 2023 16:26:07 +0000 Subject: [PATCH] new git history setting, and update to vim to include defaults --- one-time-stuff/basic-settings.sh | 61 ++++++++++++++++++++++++++++++++ one-time-stuff/vim/vimrc | 3 ++ 2 files changed, 64 insertions(+) diff --git a/one-time-stuff/basic-settings.sh b/one-time-stuff/basic-settings.sh index f7ff9e1..dba854c 100755 --- a/one-time-stuff/basic-settings.sh +++ b/one-time-stuff/basic-settings.sh @@ -75,6 +75,67 @@ esac # ---------------------------------------------------------- +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' + cp "$HOME/.bashrc" "$HOME/.bashrc.backup" + + echo 'commenting out existing bash 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' + ( + cat << 'TERM' + +# ABS improved shell history +shopt -s histappend # append to the history file, don't overwrite it +HISTSIZE=10000 # cache the last 10,000 commands +HISTFILESIZE=100000 # remember the last 100,000 commands +HISTCONTROL="ignoredups" # ignore duplicates +HISTIGNORE="l:la:ll:ls *:clear:history:pwd" # ignore select simple commands +HISTFILE="${HOME}/.bash_history/$(tty | sed 's/\//-/g;s/^-//g')" # bash_history as folder split by tty + +# if we have already sourced this file, don't do it again +if [[ "${PROMPT_COMMAND}" != *"history"* ]]; then + # append history as you go + PROMPT_COMMAND="${PROMPT_COMMAND:+${PROMPT_COMMAND/%;};}history -a" + # also, build a history of other ttys + ls "${HOME}/.bash_history/"* | grep -v "${HOME}/.bash_history/others" | grep -v "${HISTFILE}" | xargs cat > "${HOME}/.bash_history/others" + # then read from the other ttys history, so our history is complete + history -n "${HOME}/.bash_history/others" +fi + +TERM +) >> "$HOME/.bashrc" + + echo 'move existing history file' + mv "$HISTFILE" "$HOME/tmp_hist_file" + mkdir "${HOME}/.bash_history" + mv "$HOME/tmp_hist_file" "${HOME}/.bash_history/$(tty | sed 's/\//-/g;s/^-//g')" + + echo 'update live config' + shopt -s histappend + shopt -u histreedit + shopt -u histverify + export HISTSIZE=10000 + export HISTFILESIZE=100000 + export HISTCONTROL="ignoredups" + export HISTIGNORE="l:la:ll:ls *:clear:history:pwd" + export HISTFILE="${HOME}/.bash_history/$(tty | sed 's/\//-/g;s/^-//g')" + if [[ "${PROMPT_COMMAND}" != *"history"* ]]; then + export PROMPT_COMMAND="${PROMPT_COMMAND:+${PROMPT_COMMAND/%;};}history -a" + fi + + ;; + * ) + echo 'Skipping' + ;; +esac + +# ---------------------------------------------------------- + echo "----- Auto save screen layout? edits ~/.screenrc ----" read -p 'Add "layour save default" to screen config? [y/N]: ' add_layout case $add_layout in diff --git a/one-time-stuff/vim/vimrc b/one-time-stuff/vim/vimrc index 47b514a..be9b783 100644 --- a/one-time-stuff/vim/vimrc +++ b/one-time-stuff/vim/vimrc @@ -1,3 +1,5 @@ +silent! source $VIMRUNTIME/defaults.vim + set tabstop=4 set shiftwidth=4 set softtabstop=4 @@ -10,3 +12,4 @@ colorscheme colorful256 map OH map OF +