Bash Profile

Bash profile Automation

Download this html file to your computer, Convert all html characters back to ascii. Recode is used for characters such as carrots, < >. Try it without recode to see for yourself.

sudo apt install curl
sudo apt install recode
curl https://michaeltrottier.com/en/linux/bash-profile/ | recode html..ascii > /tmp/.bashrc

Only grab the bash profile from the html file we downloaded programatically. I added little automation helpers: removeMeAutmationHelper

sed -n '/removeMeAutmationHelper/,/removeMeAutmationHelper/p' /tmp/.bashrc  | grep -v "#removeMeAutmationHelper" > ~/.bashrc

Activate this new bash profile

source ~/.bashrc

Here is a copy and paste of the above if you've been through this all before.

sudo apt install curl -y
sudo apt install recode -y
curl https://michaeltrottier.com/en/linux/bash-profile/ | recode html..ascii > /tmp/.bashrc
sed -n '/removeMeAutmationHelper*/,/removeMeAutmationHelper/p' /tmp/.bashrc  | grep -v "#removeMeAutmationHelper" > ~/.bashrc
source ~/.bashrc

 

Actual Profile

Here is my actual bash profile, short and sweet.

#removeMeAutmationHelper
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi

# ANSI color codes
RS="\[\033[0m\]"    # reset
FBLK="\[\033[0;30m\]" # foreground black
FRED="\[\033[0;31m\]" # foreground red
FGRN="\[\033[0;32m\]" # foreground green
FYEL="\[\033[0;33m\]" # foreground yellow
FBLE="\[\033[0;34m\]" # foreground blue
FMAG="\[\033[0;35m\]" # foreground magenta
FCYN="\[\033[0;36m\]" # foreground cyan
FWHT="\[\033[0;37m\]" # foreground white
BBLK="\[\033[1;30m\]" # background black
BRED="\[\033[1;31m\]" # background red
BGRN="\[\033[1;32m\]" # background green
BYEL="\[\033[1;33m\]" # background yellow
BBLE="\[\033[1;34m\]" # background blue
BMAG="\[\033[1;35m\]" # background magenta
BCYN="\[\033[1;36m\]" # background cyan
BWHT="\[\033[1;37m\]" # background white
IBLK="\[\033[0;90m\]" # intense black
IRED="\[\033[0;91m\]" # intense red
IGRN="\[\033[0;92m\]" # intense green
IYEL="\[\033[0;93m\]" # intense yellow
IBLE="\[\033[0;94m\]" # intense blue
IMAG="\[\033[0;95m\]" # intense magenta
ICYN="\[\033[0;96m\]" # intense cyan
IWHT="\[\033[0;97m\]" # intense white
BIBLK="\[\033[1;90m\]" # bold intense black
BIRED="\[\033[1;91m\]" # bold intense red
BIGRN="\[\033[1;92m\]" # bold intense green
BIYEL="\[\033[1;93m\]" # bold intense yellow
BIBLE="\[\033[1;94m\]" # bold intense blue
BIMAG="\[\033[1;95m\]" # bold intense magenta
BICYN="\[\033[1;96m\]" # bold intense cyan
BIWHT="\[\033[1;97m\]" # bold intense white

PROMPT_COMMAND=__prompt_command

__prompt_command() {
   EXIT=$?
   PS1=""
   
   if [ $EXIT -eq 0 ]; then
     PS1+="$BIGRN[\$?]$BIGRN[\u@$(hostname -f | awk -F. '{print $1"."$2}')] $BICYN[\t] $FYEL[\w]\n$RS>"
   else
     PS1+="$BIRED[\$?]$BIGRN[\u@$(hostname -f | awk -F. '{print $1"."$2}')] $BICYN[\t] $FYEL[\w]\n$RS>"
   fi
 
   # write history after every command so I don't have to remember which terminal I was in
   history -a
}

export EDITOR=vim
alias vi='vim'
alias grep='grep --color=auto'
alias ls='ls --color=always'
alias la='ls -lha --color=always'
alias ll='ls -lha --color=always'
alias sortcount='sort | uniq -c | sort -n'
alias screen='screen -c /home/mtrottie/.screenrc'
alias file="file -L" # want to follow symlinks so file will work for apollo-hosted commands

bind '"^[[1;9A":history-search-backward'
bind '"^[[1;9B":history-search-forward'

set -o notify # don't wait for the next prompt to print background job status
shopt -s cdspell # fix simple typos in cd directory names
shopt -s checkwinsize # checks window size after every command, should fix my mobaxterm issue with weird line wrapping
shopt -s histappend # append, don't overwrite, the history
shopt -u mailwarn # I really don't care if I have mail on hosts
unset MAILCHECK

# make man pages prettier
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'

#removeMeAutmationHelper