dotfiles/.bashrc

190 lines
4.5 KiB
Bash
Raw Normal View History

2013-09-30 11:20:52 -07:00
# Navigation
alias ls="exa --long --header --git --group"
alias cat="bat --theme=\"Visual Studio Dark+\""
alias tree="exa --tree"
alias la="ls -lhA"
2022-02-11 17:51:50 -08:00
alias calc="qalc"
alias dedsstore="find . -name \".DS_Store\" -delete"
2022-09-23 10:23:43 -07:00
alias c="clear"
2022-11-18 10:30:32 -08:00
# Difftastic Config
export DFT_TAB_WIDTH=4
export DFT_BACKGROUND=light
2016-08-08 14:09:41 -07:00
# History
HISTSIZE=50000
HISTFILESIZE=50000
2021-11-04 12:46:54 -07:00
HISTCONTROL=ignoreboth:erasedups
2020-12-29 14:43:10 -08:00
HISTIGNORE="ls:ll:cd:pwd:bg:fg:history"
2021-07-27 10:57:51 -07:00
if [ "$BASH" != "" ]; then
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
fi
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
# History
shopt -s histappend
2020-12-29 14:43:10 -08:00
# append and reload the history after each command
PROMPT_COMMAND="history -a; history -n"
2022-09-26 10:29:02 -07:00
if [ -z "$SSH_AUTH_SOCK" ]; then
# Check for a currently running instance of the agent
RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
if [ "$RUNNING_AGENT" = "0" ]; then
# Launch a new instance of the agent
ssh-agent -s &> $HOME/.ssh/ssh-agent
2022-11-22 12:32:32 -08:00
sed -i '/^echo Agent pid.*/d' $HOME/.ssh/ssh-agent
2022-09-26 10:29:02 -07:00
fi
eval `\cat $HOME/.ssh/ssh-agent`
fi
for key in $(find "${HOME}/.ssh" -type f -name "*.pub"); do
ssh-add -q "${key%.*}"
2022-09-26 10:29:02 -07:00
done
2020-12-29 14:43:10 -08:00
# bind -x '"\C-r"':reset
fi
2016-08-08 14:09:41 -07:00
2013-09-30 11:20:52 -07:00
# Applications
alias tmux="tmux -2"
2014-01-07 08:38:34 -08:00
alias grep="grep --color=auto"
2019-10-18 08:37:45 -07:00
# Fix gpg signing
# https://github.com/keybase/keybase-issues/issues/2798
export GPG_TTY=$(tty)
2017-02-20 08:08:45 -08:00
# Golang
export PATH=$PATH:/usr/local/go/bin:${HOME}/go/bin
2017-01-20 15:12:32 -08:00
export TERM="xterm-256color"
2017-05-04 10:06:23 -07:00
export EDITOR=$(which vim)
2017-01-20 15:12:32 -08:00
# Adding applications to path
2022-11-23 15:23:14 -08:00
if [[ -d ${HOME}/.dotfiles/bin/linux ]]; then
export PATH=$PATH:${HOME}/.dotfiles/bin/linux
fi
if [[ -d ${HOME}/bin ]]; then
export PATH=$PATH:${HOME}/bin
fi
2022-09-26 09:33:18 -07:00
# fzf
2022-11-18 10:41:15 -08:00
# TODO: Why are these files in so many different places?
if [ -f ~/.fzf.bash ]; then
source ~/.fzf.bash
fi
2022-09-26 09:33:18 -07:00
if [ -f /usr/share/bash-completion/completions/fzf ]; then
source /usr/share/bash-completion/completions/fzf
fi
2022-02-11 17:51:50 -08:00
2022-09-26 09:33:18 -07:00
if [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then
source /usr/share/doc/fzf/examples/key-bindings.bash
fi
2022-02-11 17:51:50 -08:00
2022-11-18 10:41:15 -08:00
if [ -f /usr/share/doc/fzf/examples/completion.bash ]; then
source /usr/share/doc/fzf/examples/completion.bash
fi
2021-11-04 12:46:54 -07:00
# Add a local un-tracked bash-rc if present
if [[ -f ${HOME}/.bashrc_local ]];
then
source ${HOME}/.bashrc_local
fi
2017-01-20 15:12:32 -08:00
# Git
_git_safedel() {
if [[ "${COMP_LINE}" =~ ^git\ safedel.*$ ]]; then
__gitcomp_nl "$(__git_heads)"
else
__git_main
fi
}
_git_top() {
if [[ "${COMP_LINE}" =~ ^git\ top.*$ ]]; then
__gitcomp_nl "$(__git_heads)"
else
__git_main
fi
}
2015-06-16 09:32:55 -07:00
2017-01-20 15:12:32 -08:00
function up() {
num=1
if [ $# -gt 0 ]; then
num=$1
fi
2015-06-16 09:32:55 -07:00
2017-01-20 15:12:32 -08:00
cd $(printf '../%.0s' $(seq 1 $num))
}
2013-09-30 11:20:52 -07:00
2014-07-16 10:25:52 -07:00
# Add color shortcuts
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset=`tput sgr0`
c_user=`tput setaf 2; tput bold`
c_path=`tput setaf 4; tput bold`
c_git_clean=`tput setaf 2`
c_git_dirty=`tput setaf 1`
else
c_reset=
c_user=
c_path=
c_git_cleanclean=
c_git_dirty=
fi
2021-11-04 12:46:19 -07:00
prev_status_prompt () {
status=$?
if [ $status -ne 0 ]; then
red=`tput setaf 1; tput bold`
echo " -- ${red}${status}${c_reset}"
fi
}
2014-07-16 10:25:52 -07:00
git_prompt () {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="${c_git_clean}"
else
git_color=${c_git_cleanit_dirty}
fi
2014-07-16 10:25:52 -07:00
echo " -- $git_color$git_branch${c_reset}"
}
2018-01-24 08:09:21 -08:00
kubectl_context() {
2018-01-24 08:22:44 -08:00
if [ ! $(which kubectl) ]; then
return 0
fi
kubectl cluster-info > /dev/null 2>&1
if [ $? -ne 0 ]; then
return 0
fi
2018-01-24 08:09:21 -08:00
context=$(kubectl config current-context 2>/dev/null)
namespace=$(kubectl config view -o "jsonpath={.contexts[?(@.name==\"$context\")].context.namespace}")
2019-06-13 08:16:38 -07:00
cluster=$(kubectl config view -o "jsonpath={.contexts[?(@.name==\"$context\")].context.cluster}")
2018-01-24 08:09:21 -08:00
prod_color=`tput setaf 1; tput bold`
dev_color=`tput setaf 4; tput bold`
2021-11-08 11:03:54 -08:00
if [[ "$EKS_CLUSTER_NAME" = "tgrosinger-he-extrahop-com" ]]; then
2019-06-13 08:16:38 -07:00
echo "-- ${dev_color}${cluster}:${namespace}${c_reset}"
2021-11-08 11:03:54 -08:00
else
echo "-- ${prod_color}${cluster}:${namespace}${c_reset}"
2018-01-24 08:09:21 -08:00
fi
}
if [ "$BASH" != "" ]; then
# Prompt
2021-11-04 12:46:19 -07:00
PS1="\n╔ \w\$(prev_status_prompt)\$(git_prompt) \$(kubectl_context)\n╚ \h\$ "
fi
2020-03-30 11:20:16 -07:00