dotfiles/.bashrc
2023-04-27 14:49:01 +01:00

75 lines
3.2 KiB
Bash

#!/bin/bash
#--------------------------------------------------------------------------------
# Exit for non-interactive sessions
#--------------------------------------------------------------------------------
if [ -z "$PS1" ]; then
return
fi
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Function to prepend PATH only if it doesn't already exist
#--------------------------------------------------------------------------------
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# The best editor
#--------------------------------------------------------------------------------
export EDITOR=vim
alias vi='vim'
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Make less use visual bell
#--------------------------------------------------------------------------------
export LESS="-qr"
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Default directories
#--------------------------------------------------------------------------------
mkdir -p ~/src ~/tmp ~/var/log
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Update the path with local overrides
#--------------------------------------------------------------------------------
pathadd /usr/local/sbin
pathadd /usr/local/bin
pathadd ~/.local/bin
pathadd ~/bin
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# A useful prompt
#--------------------------------------------------------------------------------
function __PROMPT_COMMAND() {
history -a
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"
}
export PS1="[\u@\h \W \[\033[32m\]\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ <\1>/')\[\033[00m\]]\\$ "
export PROMPT_COMMAND=__PROMPT_COMMAND
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Command alias functions
#--------------------------------------------------------------------------------
GIT_SSH_COMMAND="$(which ssh) -o RemoteCommand=none"
export GIT_SSH_COMMAND
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Include deployed bash config
#--------------------------------------------------------------------------------
for include in ~/.bashrc.d/*; do
source "${include}"
done
#--------------------------------------------------------------------------------