From b720fd6bc0d07856f8a5577e3c3fc4e6618fb535 Mon Sep 17 00:00:00 2001 From: spongle Date: Sun, 28 Aug 2022 20:11:02 +0100 Subject: [PATCH] .. --- shared/bash_profile | 242 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 1 deletion(-) diff --git a/shared/bash_profile b/shared/bash_profile index 7363b97..dfff578 100755 --- a/shared/bash_profile +++ b/shared/bash_profile @@ -1,3 +1,83 @@ +# 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 +} + _setaliases() { case "$THISOS" in darwin) @@ -54,6 +134,127 @@ _setaliases() { alias path='echo -e ${PATH//:/\\n}' } +_setlocalaliases() { + case "$THISHOST" in + MINT660) + alias ansible-playbook='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-playbook' + alias ansible-lint='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-lint' + alias vgit='docker run -ti --rm -v ${HOME}:/root -v $(pwd):/git alpine/git "$@" ' + alias mycicd='/volume17/zNFS2/Sync${THISHOST}/zNFS2/zDocky/mycicd.sh' + ;; + MINT661) + alias ansible-playbook='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-playbook' + alias ansible-lint='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-lint' + alias vgit='docker run -ti --rm -v ${HOME}:/root -v $(pwd):/git alpine/git "$@" ' + alias mycicd='/volume12/zTools/Sync${THISHOST}/zTools/zDocky/mycicd.sh' + ;; + MINT662) + alias ansible-playbook='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-playbook' + alias ansible-lint='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-lint' + alias vgit='docker run -ti --rm -v ${HOME}:/root -v $(pwd):/git alpine/git "$@" ' + alias mycicd='/volume12/zTools/Sync${THISHOST}/zTools/zDocky/mycicd.sh' + ;; + MINT663) + alias ansible-playbook='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-playbook' + alias ansible-lint='docker run -it --rm -v /volume12/zTools/Sync${THISHOST}/zTools/zAnsible:/ansible dansible:latest ansible-lint' + alias vgit='docker run -ti --rm -v ${HOME}:/root -v $(pwd):/git alpine/git "$@" ' + alias mycicd='/volume12/zTools/Sync${THISHOST}/zTools/zDocky/mycicd.sh' + ;; + esac +} + +_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' +} + + + + + + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH @@ -81,4 +282,43 @@ export EDITOR #localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 -_setaliases \ No newline at end of file + +_setpath +_setldpath +_setldrunpath +_setaliases +_setlocalaliases +_setprompt 2line +_sethistory +_moreless +_manpagecolor + +export EDITOR=vim + +# 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=ansi +export TERM=xterm-256color +#export PIP_REQUIRE_VIRTUALENV=true + +export GOPATH=${HOME}/dev/go + +_sources +# Mac likes to discard ctl-o +if [[ $THISOS == darwin ]]; then + stty discard undef +fi + +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= +