From 31a6b3abd99cee7ae89f124f8d7325b26e265eb1 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Mon, 30 Oct 2017 11:43:24 +0200 Subject: [PATCH] - Run Bash specifics at the end of .bashrc, otherwise some Bash completions aren't working properly. - Added direnv bash completion. --- .bash_completion.d/direnv | 8 ++++++ .bashrc | 53 ++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 .bash_completion.d/direnv diff --git a/.bash_completion.d/direnv b/.bash_completion.d/direnv new file mode 100644 index 0000000..a1058a5 --- /dev/null +++ b/.bash_completion.d/direnv @@ -0,0 +1,8 @@ +#!/bin/sh + +if which direnv > /dev/null +then + [ -f "$HOME/.bash_completion.d/.direnv" ] || direnv hook bash > "$HOME/.bash_completion.d/.direnv" + # shellcheck disable=SC1090 + . "$HOME/.bash_completion.d/.direnv" +fi diff --git a/.bashrc b/.bashrc index f283b59..cb18d8f 100644 --- a/.bashrc +++ b/.bashrc @@ -2,32 +2,6 @@ # If not running interactively, don't do anything [ -z "$PS1" ] && return -if [ -n "${BASH:-}" ] -then - shopt -s histappend - shopt -s checkwinsize - shopt -s cmdhist - export PROMPT_COMMAND="history -a" - [ -f /etc/bash_completion ] && . /etc/bash_completion - - # shellcheck disable=SC1090 - for sourcefile in $HOME/.bash_completion.d/* - do - [ ! -f "$sourcefile" ] || . "$sourcefile" - done -fi - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - eval "$(dircolors -b)" - alias ls='ls --color=auto' - alias grep='grep --color=auto' - alias diff='diff --color=auto' -fi - export LANG=en_US.UTF8 export HISTFILE="$HOME/.history" export HISTCONTROL=ignoreboth:erasedups @@ -218,4 +192,31 @@ __prompt () { # shellcheck disable=SC1090 . "$HOME/Documents/Shore/bundle_certs/bundle_certs" + +if [ -n "${BASH:-}" ] +then + shopt -s histappend + shopt -s checkwinsize + shopt -s cmdhist + export PROMPT_COMMAND="history -a" + [ -f /etc/bash_completion ] && . /etc/bash_completion + + # shellcheck disable=SC1090 + for sourcefile in $HOME/.bash_completion.d/* + do + [ ! -f "$sourcefile" ] || . "$sourcefile" + done +fi + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias grep='grep --color=auto' + alias diff='diff --color=auto' +fi + prune_prerun -- GitLab