NixOS/dotfiles/bash_prompt
Leo Alho 551f5c913a Configure alacritty shell, expand tmux config, and add bash prompt
- Alacritty: auto-attach to tmux session on launch
- tmux: full config with pane/window styling, TPM, and keybindings
- bash: add Powerline-style git-aware prompt via dotfiles/bash_prompt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016fnKHtb2XA4Y5Pcxc1qpC2
2026-07-28 13:43:55 +03:00

34 lines
868 B
Bash

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
function __set_prompt() {
local branch
branch=$(git branch --show-current 2>/dev/null)
# Colors (wrapped in \[ \] for proper length calculation)
local yellow_bg='\[\033[43;30m\]'
local blue_bg='\[\033[44;30m\]'
local yellow_on_blue='\[\033[44;33m\]'
local blue='\[\033[0;34m\]'
local yellow='\[\033[0;33m\]'
local reset='\[\033[0m\]'
local arrow=$''
if [[ -n "$branch" ]]; then
PS1="${yellow_bg} \w ${yellow_on_blue}${arrow}${blue_bg} ${branch} ${blue}${arrow}${reset} "
else
PS1="${yellow_bg} \w ${yellow}${arrow}${reset} "
fi
}
if [ "$color_prompt" = yes ]; then
PROMPT_COMMAND=__set_prompt
else
PS1='\w\$ '
fi
unset color_prompt
printf '\033[3 q'