dotfiles/.bashrc

168 lines
3.6 KiB
Bash
Raw Normal View History

2013-09-30 11:20:52 -07:00
# Navigation
2019-05-14 08:53:48 -07:00
#alias ls="ls --color=auto"
alias ls="exa --long --header --git --group"
alias cat="bat --theme=GitHub"
alias tree="exa --tree"
2014-02-10 08:23:01 -08:00
alias ..="cd ..;"
alias la="ls -lhA"
2013-09-30 11:20:52 -07:00
alias rmr="rm -r"
# Disable the lockup of doom from ctrl+s
#stty -ixon
2016-08-08 14:09:41 -07:00
# History
HISTSIZE=50000
HISTFILESIZE=50000
HISTCONTROL=ignoredups:ignorespace
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
# History
shopt -s histappend
for filename in ${HOME}/.ssh/*.pub; do
keyname="$(basename ${filename} .pub)"
eval $(keychain --nogui --eval --quiet ${keyname})
done
2020-05-14 15:02:05 -07:00
#elif [[ "${OSTYPE}" == "darwin"* ]]; then
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
# (f)ind by (n)ame
# usage: fn foo
# to find all files containing 'foo' in the name
function fn() {
2013-09-30 11:20:52 -07:00
if [ $# -eq 2 ]; then
sudo find $1 -name $2
elif [ $# -eq 1 ]; then
find `pwd` -name $1
else
echo "(f)ind by (n)ame"
echo "usage: fn [name]"
echo "Where name is the file name to search for"
2013-09-30 11:20:52 -07:00
fi
}
2014-01-03 08:00:45 -08:00
# (f)ind (i)n (f)ile
# usage: fif "text to search"
function fif() {
rga $1 2>/dev/null
}
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
}
to_md() {
# Convert the input file to markdown and copy to the clipboard
pandoc ${1} -t gfm | xclip -selection clipboard
}
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
2020-05-14 15:02:05 -07:00
#elif [ "$ZSH_NAME" != "" ]; then
fi
2020-03-30 11:20:16 -07:00
source <(navi widget bash)