2017-11-11 11:36:23 +00:00
|
|
|
source /etc/profile 2>/dev/null
|
|
|
|
source /etc/profile.d/* 2>/dev/null
|
|
|
|
|
2017-11-03 08:46:24 +00:00
|
|
|
# Change prompt if root
|
2017-11-03 07:49:05 +00:00
|
|
|
if [ $UID -eq 0 ] ; then
|
|
|
|
PROMPT_SUFFIX='\[\033[1;31m\] # \[\033[0m\]'
|
|
|
|
else
|
|
|
|
PROMPT_SUFFIX='\[\033[0;32m\] $ \[\033[0m\]'
|
|
|
|
fi
|
|
|
|
|
2017-11-03 08:46:24 +00:00
|
|
|
# Shorten long usernames
|
|
|
|
if [ $(whoami | wc -c) -gt 10 ] ; then
|
|
|
|
USER="me"
|
|
|
|
else
|
|
|
|
USER=$(whoami)
|
|
|
|
fi
|
|
|
|
|
2017-11-03 07:09:33 +00:00
|
|
|
export PATH=$PATH:~/bin:~/local/bin
|
|
|
|
|
|
|
|
function tmux_title {
|
|
|
|
printf '\033]2;%s\033\\' $@
|
|
|
|
}
|
2019-08-02 05:41:01 +00:00
|
|
|
#tmux_title $(hostname -s)
|
2017-11-03 07:09:33 +00:00
|
|
|
|
2021-04-19 10:08:05 +00:00
|
|
|
# load powerline
|
|
|
|
if which powerline-daemon &>/dev/null; then
|
|
|
|
powerline-daemon -q
|
|
|
|
POWERLINE_BASH_CONTINUATION=1
|
|
|
|
POWERLINE_BASH_SELECT=1
|
|
|
|
else
|
|
|
|
# otherwise Git prompt
|
|
|
|
PS1='\[\033[0;32m\]${USER}@\h\[\033[0m\] [\[\033[0;33m\]\w\[\]\[\033[0;32m\]]\n'$PROMPT_SUFFIX
|
|
|
|
GIT_PROMPT_ONLY_IN_REPO=1
|
|
|
|
GIT_PROMPT_FETCH_REMOTE_STATUS=0
|
|
|
|
GIT_PROMPT_IGNORE_STASH=1
|
|
|
|
GIT_PROMPT_THEME=Noldorized
|
|
|
|
source ~/.bash-git-prompt/gitprompt.sh
|
2017-11-03 07:09:33 +00:00
|
|
|
|
2021-04-19 10:08:05 +00:00
|
|
|
function prompt_callback {
|
|
|
|
REPO=$(git remote -v | sed -r 's/^origin.*\/(.*)\ .*/\1/' | head -1)
|
2021-04-20 11:14:16 +00:00
|
|
|
tmux_title "$REPO($GIT_BRANCH)"
|
2021-04-19 10:08:05 +00:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
PYVERSION=$(python3 --version | grep -Eo '[0-9]\.[0-9]')
|
2021-04-20 11:14:16 +00:00
|
|
|
if [ -f $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ]; then
|
|
|
|
export VIRTUAL_ENV="$HOME/.venv"
|
|
|
|
export PATH=$VIRTUAL_ENV/bin:$PATH
|
|
|
|
# powerline-daemon -q
|
|
|
|
POWERLINE_BASH_CONTINUATION=1
|
|
|
|
POWERLINE_BASH_SELECT=1
|
|
|
|
|
|
|
|
function _update_ps1() {
|
|
|
|
if git log --oneline -n1 &>/dev/null ; then
|
|
|
|
REPO=$(git remote -v | sed -r 's/^origin.*\/(.*)\ .*/\1/' | sed 's/.git$//'| head -1)
|
|
|
|
BRANCH=$(git branch --show-current)
|
|
|
|
tmux_title "$REPO($BRANCH)"
|
|
|
|
else
|
|
|
|
tmux_title "$(hostname)"
|
|
|
|
fi
|
|
|
|
PS1=$(powerline-shell $?)
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
|
|
|
|
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# source $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
|
|
|
|
elif [ -f ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ] ; then
|
|
|
|
#source ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
|
|
|
|
echo no
|
|
|
|
elif [ -f /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh ]; then
|
|
|
|
source /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh
|
2021-04-19 10:08:05 +00:00
|
|
|
fi
|
2021-04-20 11:14:16 +00:00
|
|
|
set +x
|
2017-11-03 07:09:33 +00:00
|
|
|
|
|
|
|
# LS_COLORS
|
|
|
|
eval $(dircolors -b $HOME/.dircolors)
|
|
|
|
|
|
|
|
# Global Options
|
|
|
|
export LS_OPTIONS=""
|
|
|
|
export LESS='-R'
|
2017-11-03 07:45:03 +00:00
|
|
|
export TERM=xterm-256color
|
2020-03-13 17:00:12 +00:00
|
|
|
export MC_SKIN=$HOME/.mc/lib/solarized.ini
|
2017-11-03 07:09:33 +00:00
|
|
|
|
2020-03-13 17:05:03 +00:00
|
|
|
if [ -e ~/.local/bin/virtualenvwrapper.sh ] ; then
|
|
|
|
# Python stuff
|
|
|
|
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
|
|
|
|
source ~/.local/bin/virtualenvwrapper.sh
|
|
|
|
export WORKON_HOME=/home/nold/.virtualenvs
|
|
|
|
export PIP_VIRTUALENV_BASE=/home/nold/.virtualenvs
|
|
|
|
fi
|
2017-11-03 07:09:33 +00:00
|
|
|
|
|
|
|
# Aliases
|
|
|
|
alias ls="ls --color=always --time-style=long-iso -F"
|
2020-03-13 17:05:03 +00:00
|
|
|
alias dfh="df -hT -t ext4 -t zfs"
|
|
|
|
alias lsof='lsof 2>/dev/null | grep'
|
|
|
|
|
|
|
|
# Git
|
2017-11-03 07:09:33 +00:00
|
|
|
alias gs="git status"
|
|
|
|
alias gc="git commit -m"
|
|
|
|
alias gco="git checkout"
|
|
|
|
alias gl="git l"
|
|
|
|
alias ga="git add"
|
|
|
|
alias gpush="git push"
|
|
|
|
alias gpull="git pull"
|
2017-11-11 11:36:23 +00:00
|
|
|
|
2020-03-13 17:05:03 +00:00
|
|
|
# Docker-Compose
|
2017-11-11 11:36:23 +00:00
|
|
|
alias dcu="docker-compose up -d --remove-orphans"
|
|
|
|
alias dcd="docker-compose down"
|
|
|
|
alias dcp="docker-compose pull"
|
2020-03-13 17:00:12 +00:00
|
|
|
alias dcb="docker-compose build"
|
|
|
|
alias dcl="docker-compose logs"
|
|
|
|
alias dclf="docker-compose logs --tail=50 -f"
|
|
|
|
|
|
|
|
# k3s / k8s / helm
|
|
|
|
alias k="kubectl"
|
|
|
|
alias kga="kubectl get all --all-namespaces -o wide"
|
|
|
|
alias kgn="kubectl get nodes -o wide"
|
|
|
|
alias kgp="kubectl get pods -o wide"
|
|
|
|
|
2021-04-19 10:08:05 +00:00
|
|
|
# Completions for various tools...
|
|
|
|
for bin in kubectl helm talosctl ; do
|
|
|
|
type $bin &>/dev/null && source <($bin completion bash)
|
|
|
|
done
|