193 lines
4.6 KiB
Bash
193 lines
4.6 KiB
Bash
# Source .bashrc for non-interactive Bash shells
|
|
export BASH_ENV=~/.bashrc
|
|
|
|
if [[ $- != *i* ]] ; then
|
|
# Shell is non-interactive. Be done now!
|
|
return
|
|
fi
|
|
|
|
THISOS=$(uname | awk '{print tolower($1)}')
|
|
THISHOST=$(uname -n)
|
|
|
|
|
|
# History control
|
|
# don't use duplicate lines or lines starting with space
|
|
HISTCONTROL=ignoreboth
|
|
HISTSIZE=1000
|
|
HISTFILESIZE=2000
|
|
# append to the history file instead of overwrite
|
|
shopt -s histappend
|
|
|
|
_setpath() {
|
|
local paths=(
|
|
/usr/local/bin
|
|
/usr/local/sbin
|
|
/usr/local/sqlite/bin
|
|
)
|
|
|
|
local i
|
|
for i in ${paths[@]}; do
|
|
# Move these paths to the front
|
|
PATH=$(echo $PATH | sed -e "s#$i##g")
|
|
if [ -d $i ]; then
|
|
PATH=$i:$PATH
|
|
fi
|
|
done
|
|
|
|
PATH=`echo $PATH | sed -e 's/^\://' -e 's/\:\:/:/g'`
|
|
|
|
export PATH
|
|
}
|
|
|
|
_setldpath() {
|
|
local paths=(
|
|
/usr/local/sqlite/lib
|
|
)
|
|
|
|
local i
|
|
for i in ${paths[@]}; do
|
|
# Move these paths to the front
|
|
LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed -e "s#$i##g")
|
|
if [ -d $i ]; then
|
|
LD_LIBRARY_PATH=$i:$LD_LIBRARY_PATH
|
|
fi
|
|
done
|
|
|
|
LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed -e 's/^\://' -e 's/\:\:/:/g'`
|
|
|
|
export LD_LIBRARY_PATH
|
|
}
|
|
|
|
_setldrunpath() {
|
|
local paths=(
|
|
/usr/local/sqlite/lib
|
|
)
|
|
|
|
local i
|
|
for i in ${paths[@]}; do
|
|
# Move these paths to the front
|
|
LD_RUN_PATH=$(echo $LD_RUN_PATH | sed -e "s#$i##g")
|
|
if [ -d $i ]; then
|
|
LD_RUN_PATH=$i:$LD_RUN_PATH
|
|
fi
|
|
done
|
|
|
|
LD_RUN_PATH=`echo $LD_RUN_PATH | sed -e 's/^\://' -e 's/\:\:/:/g'`
|
|
|
|
export LD_RUN_PATH
|
|
}
|
|
|
|
_setprompt() {
|
|
local SAVEHISTORY="history -a"
|
|
local SETWINDOWTITLE='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
|
|
|
|
local TMUXCMD=''
|
|
if [ -n $TMUX ]; then
|
|
local TMUXENV='tmux set-environment -g CWD "$PWD"'
|
|
local TMUXPATH='tmux set-option default-path $PWD'
|
|
local TMUXCMD="($TMUXENV 2>/dev/null && $TMUXPATH 2>/dev/null >&2)"
|
|
fi
|
|
|
|
export PROMPT_COMMAND="$SETWINDOWTITLE;$SAVEHISTORY;$TMUXCMD"
|
|
|
|
# Reset
|
|
local Color_Off='\[\e[0m\]' # Text Reset
|
|
|
|
# Regular Colors
|
|
local Black='\[\e[0;30m\]' # Black
|
|
local Red='\[\e[0;31m\]' # Red
|
|
local Green='\[\e[0;32m\]' # Green
|
|
local Yellow='\[\e[0;33m\]' # Yellow
|
|
local Blue='\[\e[0;34m\]' # Blue
|
|
local Purple='\[\e[0;35m\]' # Purple
|
|
local Cyan='\[\e[0;36m\]' # Cyan
|
|
local White='\[\e[0;37m\]' # White
|
|
local NEWLINE="\n"
|
|
|
|
# Use for chroots, venvs, or other info that should be stuck in the prompt
|
|
EXTRAPROMPT=$2
|
|
|
|
case "$1" in
|
|
simple)
|
|
export PS1="\[\[\e[32;1m\]\h$EXTRAPROMPT \W> \[\e[0m\]"
|
|
;;
|
|
2line)
|
|
# Default PROMPT_COLOR values
|
|
: ${PROMPT_COLOR:=Yellow}
|
|
: ${PROMPT_COLOR2:=Blue}
|
|
local C1=${!PROMPT_COLOR}
|
|
local C2=${!PROMPT_COLOR2}
|
|
|
|
# ┌(jer@myhost)─(✗)─(10:18 PM Sun Apr 14)
|
|
# └─(~/dev/git/myproject)─>
|
|
local DASH="\342\224\200"
|
|
local X="\342\234\227"
|
|
local ERRCODE="\$([[ \$? != 0 ]] && echo \"${DASH}(${Red}${X}${White})\")${DASH}"
|
|
|
|
LINE1="${White}\342\224\214(${C1}\u@\h$EXTRAPROMPT${White})${ERRCODE}(${C1}\@ \d${White})"
|
|
local LINE2="\342\224\224\342\224\200(${C2}\w${White})-> "
|
|
export PS1="${NEWLINE}${LINE1}${NEWLINE}${LINE2}${Color_Off}"
|
|
;;
|
|
3line)
|
|
_setprompt 2line
|
|
export PS1="$PS1${NEWLINE}${White}\342\224\224\342\224\200>${Color_Off} "
|
|
;;
|
|
esac
|
|
|
|
}
|
|
|
|
_sethistory() {
|
|
export HISTFILE=~/.bash_history
|
|
export HISTSIZE=10000
|
|
export HISTFILESIZE=${HISTSIZE}
|
|
export HISTCONTROL=ignoredups:ignorespace
|
|
shopt -s histappend
|
|
|
|
# Do *not* append the following to our history:
|
|
HISTIGNORE='\&:fg:bg:ls:pwd:cd ..:cd ~-:cd -:cd:jobs:set -x:ls -l:ls -l'
|
|
HISTIGNORE=${HISTIGNORE}':%1:%2:popd:top:shutdown*'
|
|
export HISTIGNORE
|
|
|
|
# Save multi-line commands in history as single line
|
|
shopt -s cmdhist
|
|
}
|
|
|
|
_manpagecolor() {
|
|
export LESS_TERMCAP_mb=$'\E[01;31m'
|
|
export LESS_TERMCAP_md=$'\E[01;31m'
|
|
export LESS_TERMCAP_me=$'\E[0m'
|
|
export LESS_TERMCAP_se=$'\E[0m'
|
|
export LESS_TERMCAP_so=$'\E[01;44;33m'
|
|
export LESS_TERMCAP_ue=$'\E[0m'
|
|
export LESS_TERMCAP_us=$'\E[01;32m'
|
|
}
|
|
|
|
|
|
_setpath
|
|
_setldpath
|
|
_setldrunpath
|
|
_setprompt 2line
|
|
_sethistory
|
|
_manpagecolor
|
|
|
|
export EDITOR=vi
|
|
|
|
# Correct minor spelling errors in cd commands
|
|
shopt -s cdspell
|
|
# Enable egrep-style pattern matching
|
|
shopt -s extglob
|
|
shopt -s checkwinsize
|
|
|
|
export CLICOLOR=1
|
|
export LSCOLORS=ExFxCxDxBxegedabagacad
|
|
export TERM=xterm-256color
|
|
export GOPATH=${HOME}/dev/go
|
|
|
|
export ANSIBLE_STDOUT_CALLBACK=yaml
|
|
export GPODDER_HOME=~/DocumentsPodcasts/config
|
|
export GPODDER_DOWNLOAD_DIR=~/DocumentsPodcasts/downloads
|
|
|
|
PATH=${PATH}:.local/bin ; export PATH
|
|
export SIGNAL_PHONE_NUMBER=
|
|
|