# Source Default /etc/bashrc if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Add .local/bin to PATH if ! [[ "$PATH" =~ "$HOME/.local/bin:" ]]; then PATH="$HOME/.local/bin:$PATH" fi export PATH # Custom Shell variables, aliases, and functions [ -f "$HOME/.config/shell/alias" ] && source "$HOME/.config/shell/alias" [ -f "$HOME/.config/shell/vars" ] && source "$HOME/.config/shell/vars" [ -f "$HOME/.config/shell/functions" ] && source "$HOME/.config/shell/functions" # Custom Prompt USER_COLOR="\[\e[35m\]" # magenta VENV_COLOR="\[\e[33m\]" # yellow DIR_COLOR="\[\e[32m\]" # green GIT_COLOR="\[\e[34m\]" # blue GIT_DIRTY_COLOR="\[\e[31m\]" # red PROMPT_SYMBOL_COLOR="\[\e[33m\]" # yellow RESET_COLOR="\[\e[0m\]" # blank WHITE_COLOR="\[\e[37m\]" # white TOOLBOX_COLOR="\[\e[36m\]" # cyan shorten_path() { if [[ "$PWD" == "$HOME" ]]; then echo "~" return fi if [[ "$PWD" == "$HOME/"* ]]; then local rel="${PWD#$HOME/}" local depth IFS='/' read -ra parts <<< "$rel" depth=${#parts[@]} if (( depth == 1 )); then echo "~/${parts[0]}" elif (( depth == 2 )); then echo ".../${parts[0]}/${parts[1]}" else echo ".../${parts[-2]}/${parts[-1]}" fi return fi IFS='/' read -ra parts <<< "$PWD" if (( ${#parts[@]} > 3 )); then echo ".../${parts[-2]}/${parts[-1]}" else echo "$PWD" fi } git_branch() { git symbolic-ref --short HEAD 2>/dev/null \ || git rev-parse --short HEAD 2>/dev/null } git_dirty() { if [[ -n "$(git status --porcelain 2>/dev/null)" ]]; then echo " ✗" else echo " ✓" fi } set_prompt() { local user="${USER_COLOR}\u${RESET_COLOR}" local toolbox="" if [[ -n "$TOOLBOX_PATH" ]]; then toolbox="${TOOLBOX_COLOR}(tlbx)${RESET_COLOR}" fi local venv="" if [[ -n "$VIRTUAL_ENV" ]]; then venv="${VENV_COLOR}($(basename "$VIRTUAL_ENV"))${RESET_COLOR} " fi local path="${DIR_COLOR}$(shorten_path)${RESET_COLOR}" local git_info="" local branch="$(git_branch)" if [[ -n "$branch" ]]; then git_info=" ${WHITE_COLOR}on${RESET_COLOR} ${GIT_COLOR}${branch}${RESET_COLOR}${GIT_DIRTY_COLOR}$(git_dirty)${RESET_COLOR}" fi PS1="${user}${toolbox} ${WHITE_COLOR}in${RESET_COLOR} ${venv}${path}${git_info}\n${PROMPT_SYMBOL_COLOR}λ${RESET_COLOR} " } PROMPT_COMMAND="set_prompt${PROMPT_COMMAND:+; $PROMPT_COMMAND}"