dotfiles/.bashrc

139 lines
3.0 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=GitHub"
alias tree="exa --tree"
alias la="ls -lhA"
2016-08-08 14:09:41 -07:00
# History
HISTSIZE=50000
HISTFILESIZE=50000
2020-12-29 14:53:12 -08:00
HISTCONTROL=ignoreboth
2020-12-29 14:43:10 -08:00
HISTIGNORE="ls:ll:cd:pwd:bg:fg:history"
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"
for filename in ${HOME}/.ssh/*.pub; do
keyname="$(basename ${filename} .pub)"
eval $(keychain --nogui --eval --quiet ${keyname})
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
if [[ -d ${HOME}/bin ]];
then
export PATH=$PATH:${HOME}/bin
fi
# 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
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
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`
if [[ "$context" = *"hopcloud.extrahop.com"* ]]; then
2019-06-13 08:16:38 -07:00
echo "-- ${prod_color}${cluster}:${namespace}${c_reset}"
2018-01-24 08:09:21 -08:00
else
2019-06-13 08:16:38 -07:00
echo "-- ${dev_color}${cluster}:${namespace}${c_reset}"
2018-01-24 08:09:21 -08:00
fi
}
if [ "$BASH" != "" ]; then
# Prompt
PS1="\n╔ \w\$(git_prompt) \$(kubectl_context)\n╚ \h\$ "
2014-07-16 10:25:52 -07:00
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
fi
2020-03-30 11:20:16 -07:00