cleanups and headers

This commit is contained in:
Andrew Davidson 2023-01-06 15:20:53 -08:00
parent f70893deea
commit f7ff6b60c5

View file

@ -1,5 +1,53 @@
### @amdavidson's bashrc
# _ _
# ___ _ ____ _(_)_ __ ___ _ __ _ __ ___ ___ _ __ | |_
# / _ \ '_ \ \ / / | '__/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
# | __/ | | \ V /| | | | (_) | | | | | | | | | __/ | | | |_
# \___|_| |_|\_/ |_|_| \___/|_| |_|_| |_| |_|\___|_| |_|\__|
# Set some defaults.
export EDITOR="nvim"
export PATH=".:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:~/bin"
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"
# checks (stolen from zshuery)
if [[ $(uname) = 'Linux' ]]; then
IS_LINUX=1
fi
if [[ $(uname) = 'Darwin' ]]; then
IS_MAC=1
fi
if [[ -x `which brew >/dev/null 2>&1` ]]; then
HAS_BREW=1
fi
if [[ -x `which apt-get >/dev/null 2>&1` ]]; then
HAS_APT=1
fi
if [[ -x `which yum >/dev/null 2>&1` ]]; then
HAS_YUM=1
fi
# _
# _ __ _ __ ___ _ __ ___ _ __ | |_
# | '_ \| '__/ _ \| '_ ` _ \| '_ \| __|
# | |_) | | | (_) | | | | | | |_) | |_
# | .__/|_| \___/|_| |_| |_| .__/ \__|
# |_| |_|
# define useful aliases for color codes
sh_norm="\[\033[0m\]"
sh_black="\[\033[0;30m\]"
@ -19,13 +67,6 @@ sh_yellow="\[\033[1;33m\]"
sh_light_gray="\[\033[0;37m\]"
sh_white="\[\033[1;37m\]"
# Set some defaults.
export EDITOR="nvim"
export PATH=".:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:~/bin"
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"
export DOTFILES_DIR=$HOME'/.dotfiles'
# Make a pretty prompt.
export PROMPT_COMMAND='history -a; if [ $? -ne 0 ];then ERROR_FLAG=1;else ERROR_FLAG=;fi;'
export PS1=${HOSTCOLOUR}${sh_light_gray}'\t | \h'${sh_green}':\w'${sh_light_gray}' '${sh_light_gray}'${ERROR_FLAG:+'${sh_light_red}'}\$ '${sh_norm}
@ -41,6 +82,19 @@ PROMPT_DIRTRIM=2
# Update window size after every command
shopt -s checkwinsize
# _ _ _
# | |__ (_)___| |_ ___ _ __ _ _
# | '_ \| / __| __/ _ \| '__| | | |
# | | | | \__ \ || (_) | | | |_| |
# |_| |_|_|___/\__\___/|_| \__, |
# |___/
# Append history don't overwrite
shopt -s histappend
@ -58,7 +112,15 @@ HISTSIZE=500000
HISTFILESIZE=100000
# Aliases!
# _ _
# __ _| (_) __ _ ___ ___ ___
# / _` | | |/ _` / __|/ _ \/ __|
# | (_| | | | (_| \__ \ __/\__ \
# \__,_|_|_|\__,_|___/\___||___/
# jump down the tree.
alias ..="cd .."
@ -105,6 +167,28 @@ alias pc='python -ic "from __future__ import division; from math import *"'
# Start nano with line numbering no wrapping and autoindenting
alias nano='nano -ciw '
# shortcut for tmux command
alias tm="tmux new-session -A -s main"
# always use nvim
alias vim='nvim'
alias vi='nvim'
alias nv='nvim'
# __ _ _
# / _|_ _ _ __ ___| |_(_) ___ _ __ ___
# | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
# | _| |_| | | | | (__| |_| | (_) | | | \__ \
# |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
# General purpose extract command.
extract () {
if [ -f $1 ] ; then
@ -133,33 +217,32 @@ extract () {
# General purpose backup command.
bu () { tar czf ~/.backup/`basename $1`-`date +%Y%m%d%H%M`.tgz $1; }
# Repeat function, do something until you ^C out of it.
# Syntax: r sleep_time_in_seconds command_to_run
r () {
if [ ! -z $1 ]
then
if [ ! -z $2 ]
then
if [ ! -z $2 ]
then
while [ yes ]
do
$2
echo ""
sleep $1
done
else
echo "Must have a command for second argument"
fi
else
echo "Simple function to loop a command."
echo "Example, to print the date every 5 seconds:"
echo "$ r 5 date"
fi
# create an archive of a list of files, compress the archive, and encrypt the compressed archive
function archive-and-encrypt {
echo -n "Enter desired output filename: "
read filename
tar cJ $1 | \
gpg -q -r andrew@amdavidson.com -s -e -o "$filename.tar.xz.gpg"
}
# run mosh and tmux to a specific host
function mt {
mosh $1 -- tmux new-session -A -s main
}
# _ _
# (_)_ __ ___ _ __ ___ _ __| |_ ___
# | | '_ ` _ \| '_ \ / _ \| '__| __/ __|
# | | | | | | | |_) | (_) | | | |_\__ \
# |_|_| |_| |_| .__/ \___/|_| \__|___/
# |_|
# Import local extensions if needed.
if [ -f $HOME/.bashrc_local ]; then
source $HOME/.bashrc_local