From eac660293c025232b7e45a392bbdf5b19af72331 Mon Sep 17 00:00:00 2001 From: Mehdi Sadeghi Date: Sun, 29 Aug 2021 19:28:47 +0200 Subject: Reorganize bash startup files and minor fixes. - Move PATH exports to .env - Move aliases to .env - Avoid loading .env twice - Load .bashrc only on login shell and bash only --- .bashrc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to '.bashrc') diff --git a/.bashrc b/.bashrc index 721f68d..0ed5f77 100644 --- a/.bashrc +++ b/.bashrc @@ -1,16 +1,17 @@ -[ -n "$ENV" ] && . "$ENV" || [ -e ~/.env ] && . ~/.env +# .bashrc +[ -n "$ENV" ] && . "$ENV" || ([ -e ~/.env ] && . ~/.env) -# Prompt for Bash -export PS1='\[\033[1;33m\]$(prompt)\[\033[0m\]' -export HISTCONTROL=ignoredups -export HISTIGNORE="gst:gl" -export HISTTIMEFORMAT="%F %R:%S " -export PROMPT_COMMAND="history -a;history -n" +PS1='\[\033[1;33m\]$(prompt)\[\033[0m\]' +HISTCONTROL=ignoreboth:erasedups +HISTIGNORE="gst" +# see man strftime +HISTTIMEFORMAT="%F " -# Verify before running history command -shopt -s histverify +# Uncomment this line and remove `histappend' to enable shared history. +# PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r;" +shopt -s histappend -# See Bash man +# See Bash manual _completion_loader() { # Completion files on Arch @@ -31,11 +32,8 @@ _direnv_hook() { trap - SIGINT; return $previous_exit_status; }; + if ! [[ "${PROMPT_COMMAND:-}" =~ _direnv_hook ]]; then PROMPT_COMMAND="_direnv_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}" fi -alias gl='git pull' -alias gcm='git checkout master' -alias gco='git checkout' -alias gst='git status' -- cgit v1.2.3