dotfiles/shell/bashrc
2025-01-05 11:02:24 -06:00

52 lines
1.2 KiB
Bash

#!/bin/bash
if test -d ~/.config/shell/profile.d/; then
for profile in ~/.config/shell/profile.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
case $- in
*i*) ;;
*) return;;
esac
if ! shopt -oq posix; then
[ -f /usr/share/bash-completion/bash_completion ] &&
. /usr/share/bash-completion/bash_completion
[ -f /etc/bash_completion ] &&
. /etc/bash_completion
fi
bind "set completion-ignore-case on"
shopt -s checkwinsize
shopt -s histappend
shopt -s cdspell
shopt -s autocd
set -o vi
if [ -n "$HISTFILE" ] && ! [ -d "${HISTFILE%/*}" ] ; then
mkdir -p "${HISTFILE%/*}" && touch "$HISTFILE"
fi
_prompt_git_branch() {
GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')"
[ -n "$GIT_BRANCH" ] && printf '%s ' "$GIT_BRANCH"
}
PROMPT_COMMAND='if [ "$?" = 0 ]; then EXIT_COLOR="\033[32m"; else EXIT_COLOR="\033[31m"; fi'
PS1='\
\[\033[2m\]\A\[\033[0m\] \
\[\033[34m\]\w\[\033[0m\] \
\[\033[35m\]\[\033[1m\]$(_prompt_git_branch)\[\033[0m\]\
\[$(echo -ne $EXIT_COLOR)\]>\[\033[0m\] \
'
if [ -f ~/.config/shell/aliases.sh ] ; then
. ~/.config/shell/aliases.sh
fi
if [ -f ~/.config/shell/gui.sh ] ; then
. ~/.config/shell/gui.sh
fi