From 795caf46a9b48b753d1af8837e2e3353ecd41814 Mon Sep 17 00:00:00 2001 From: Fred Smith Jr <7189895+ShiftedMr@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:27:46 +0100 Subject: [PATCH] adding in some of the bashrc customizations --- .bash_aliases | 8 +-- .bashrc_additions | 172 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 6 deletions(-) create mode 100755 .bashrc_additions diff --git a/.bash_aliases b/.bash_aliases index f3624e1..77414e4 100755 --- a/.bash_aliases +++ b/.bash_aliases @@ -14,15 +14,11 @@ alias ta='tmux attach' #git alias show_all_git_changes="find ~/proj -type d -maxdepth 1 -exec bash ~/bin/git_branch.sh {} 1 \; |sed \"s/^\\s*//"\" +alias gcan='git commit --no-edit --amend' +alias gpf='git push --force-with-lease' #circlesudo alias fudo='/Users/fsmith/bin/fudo.sh' alias cudo='/Users/fsmith/bin/cudo.sh' alias gacp="git add . && git commit -S && git push" - -#sqsp -alias kubelogin='kubectl sqsp-config update' -alias glogin='gcloud auth login' -alias gcan='git commit --no-edit --amend' -alias gpf='git push --force-with-lease' diff --git a/.bashrc_additions b/.bashrc_additions new file mode 100755 index 0000000..be1cf77 --- /dev/null +++ b/.bashrc_additions @@ -0,0 +1,172 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +export EDITOR='vi' +export GOPATH=$HOME/code/golang +export PATH="/Users/fsmith/bin/jdk-13.0.1+9/Contents/Home/bin:/Users/fsmith/Library/Python/2.7/bin:"$GOPATH":/usr/local/homebrew:~/bin/:"$PATH +export PATH=$PATH":/Users/username/src/sre/kubectl-plugins" +##COLOR DEF BEGIN +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +# ... or force ignoredups and ignorespace +HISTCONTROL=ignoredups:ignorespace +HISTFILESIZE= +HISTSIZE= + +# append to the history file, don't overwrite it +shopt -s histappend +#give bash tcsh history completion +bind '"\e[B": history-search-forward' +bind '"\e[A": history-search-backward' + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=100000 +HISTFILESIZE=200000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} + +export PROMPT_COMMAND=__prompt_command # Func to gen PS1 after CMDs +export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" +function __prompt_command() { + local EXIT="$?" # This needs to be first + PS1="\n" + local RCol='\[\e[0m\]' + local Red='\[\e[0;31m\]' + local BRed='\[\e[1;31m\]' + local Pin='\[\e[0;37m\]' + local BPin='\[\e[1;37m\]' + local Grn='\[\e[0;32m\]' + local BGrn='\[\e[1;32m\]' + local Gry='\[\e[0;37m\]' + local DGry='\[\e[1;30m\]' + local BYel='\[\e[1;33m\]' + local BBlu='\[\e[1;34m\]' + local Pur='\[\e[0;35m\]' + local BPur='\[\e[1;35m\]' + local BCya='\[\e[1;36m\]' + local star=`echo -e "\xE2\x9b\xA4"` + local timestamp=`date +"%H:%M:%S"` + local dateee=`date +"%F"` + local username="$BCya\u$RCol" + local hostname="${BYel}$(hostname)${RCol}" + + if [ $EXIT != 0 ]; then + PS1+="$BRed$timestamp$RCol$BPur$star$RCol $BGry$dateee$RCol" + else + PS1+="$BBlu$timestamp$RCol$BPur$star $BGrn$dateee$RCol" + fi + if test -z "$VIRTUAL_ENV" ; then + PYTHON_VIRTUALENV="" + else + PYTHON_VIRTUALENV="${BYel}[`basename \"$VIRTUAL_ENV\"`]${RCol} " + fi +# PS1+="{RCol}@${BBlu}\h ${Pur}\W${BYel}$ ${RCol}" + PS1+="\n${debian_chroot:+($debian_chroot)}${PYTHON_VIRTUALENV}$username@$hostname:$BBlu\w$BPur$(parse_git_branch)$RCol\n$ " +} + + + +if [[ $? -ne 0 ]]; then + PS1="\[\e[0;31m\]\@\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n$ " +else + PS1="\[\e[1;34m\]\@\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n$ " +fi +unset color_prompt force_color_prompt + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi +if [ -f ~/.bash_aws ] ; then + . ~/.bash_aws +fi + +# if [ -d ~/.profile_additions -a -d ~/.profile_additions/bash ] ; then +# if [ -f ~/.profile_additions/bash/bash_functions ] ; then +# . ~/.profile_additions/bash/bash_functions +# fi +# fi + +if [ -f ~/.bash_work ] ; then + . ~/.bash_work +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi + + +man() { + env LESS_TERMCAP_mb=$'\E[01;31m' \ + LESS_TERMCAP_md=$'\E[01;38;5;74m' \ + LESS_TERMCAP_me=$'\E[0m' \ + LESS_TERMCAP_se=$'\E[0m' \ + LESS_TERMCAP_so=$'\E[38;5;246m' \ + LESS_TERMCAP_ue=$'\E[0m' \ + LESS_TERMCAP_us=$'\E[04;38;5;146m' \ + man "$@" +} +