Files
dao_hades/dotfiles/shells/.bashrc
2025-12-06 21:46:36 +00:00

64 lines
1.9 KiB
Bash

#!/usr/bin/env bash
# Only run for interactive shells
[[ $- != *i* ]] && return
# Load debian_chroot if available
[[ -z ${debian_chroot:-} && -r /etc/debian_chroot ]] && debian_chroot=$(< /etc/debian_chroot)
# Determine if color prompt should be used
color_prompt=
if [[ -n ${force_color_prompt:-} ]] || [[ ${TERM} =~ ^(xterm-color|.*-256color)$ ]]; then
if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then
color_prompt=yes
fi
fi
# Set PS1 based on color support
if [[ ${color_prompt} == yes ]]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
# Set window title for xterm/rxvt
if [[ ${TERM} =~ ^(xterm|rxvt) ]]; then
PS1="\[\e]0;${debian_chroot:+(${debian_chroot})}\u@\h: \w\a\]${PS1}"
fi
# Clean up
unset color_prompt force_color_prompt
# Enable color support for ls and grep if available
if [[ -x /usr/bin/dircolors ]]; then
if [[ -r ~/.dircolors ]]; then
eval "$(dircolors -b ~/.dircolors)"
else
eval "$(dircolors -b)"
fi
# Color aliases
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# Alert alias for desktop notifications
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Load custom aliases if file exists
[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases
# Enable bash completion if available and not in posix mode
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
fi
fi
# Load custom prompt script if it exists
[[ -f /usr/local/bin/prompt.sh ]] && . /usr/local/bin/prompt.sh