add "eternal" bash history, fix ssh-agents auth sock which was completely broken

This commit is contained in:
2022-01-14 12:44:35 -05:00
parent 8dd0abb090
commit 0fcef9985d
2 changed files with 40 additions and 3 deletions

25
bashrc
View File

@@ -104,7 +104,7 @@ fi
ssh_auth_link="${auth_sock_dir}/ssh_auth_sock"
pgrep ssh-agent &>/dev/null
if [[ "$?" == "1" ]]; then
eval "$(ssh-agent &>"$auth_sock_log")"
. <(ssh-agent | sed 's/echo/#echo/' | tee "$auth_sock_log")
if [[ -L "$ssh_auth_link" ]]; then
rm "$ssh_auth_link"
fi
@@ -114,6 +114,25 @@ if [[ "$?" == "1" ]]; then
else
ln -s "$SSH_AUTH_SOCK" "$ssh_auth_link"
fi
else
[[ -L "${ssh_auth_link}" ]] && [[ -e "${ssh_auth_link}" ]] && export SSH_AUTH_SOCK="$ssh_auth_link"
fi
[[ -L "${ssh_auth_link}" ]] && [[ -e "${ssh_auth_link}" ]] && export SSH_AUTH_SOCK="$ssh_auth_link"
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTCONTROL=ignoredups:erasedups
export HISTTIMEFORMAT="[%F %T] "
shopt -s histappend
# export HISTTIMEFORMAT="[%F %T] $(/home/luke/bin/history_status) "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
# PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"