From a817a3153d54b4189a993bbd861cc1fd91ae573b Mon Sep 17 00:00:00 2001 From: frosty Date: Wed, 29 May 2024 06:20:41 -0400 Subject: [PATCH] add new bash options --- bash/.bashrc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index bc23734..8006ef3 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -1,8 +1,29 @@ -[ -z "$PS1" ] && return +[[ $- != *i* ]] && return shopt -s autocd +shopt -s checkwinsize +shopt -s noclobber +shopt -s histappend +shopt -s cmdhist -PS1='\u@\h \w \$ ' +HISTFILESIZE=100000 +export HISTCONTROL="ignoredups" + +git_branch() { + branch=$(git branch 2>/dev/null | grep '^*' | colrm 1 2) + if [ ! -z "$branch" ]; then + if [ -n "$(git status --porcelain)" ]; then + color="31" # Red for changes + elif [ "$(git stash list)" ]; then + color="33" # Yellow for stashed changes + else + color="32" # Green for a clean state + fi + echo -e "\\e[0;${color}m${branch}\\e[0m" + fi +} + +PS1='\[\e[1;32m\]\u@\h \[\e[1;34m\]\w \$(git_branch) \[\e[0m\]\$ ' [ -f "$XDG_CONFIG_HOME/shell/shortcuts" ] && . "$XDG_CONFIG_HOME/shell/shortcuts"