summaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
Diffstat (limited to '.bashrc')
-rwxr-xr-x.bashrc30
1 files changed, 30 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
new file mode 100755
index 0000000..7b7478f
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# Prompt
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+git_branch() {
+ local branch
+ branch=$(git symbolic-ref --short HEAD 2>/dev/null) || return
+ local dirty=""
+ [ -n "$(git status --porcelain 2>/dev/null)" ] && dirty="*"
+ echo " (${branch}${dirty})"
+}
+
+# Colors
+RESET='\[\e[0m\]'
+BOLD='\[\e[1m\]'
+GREEN='\[\e[32m\]'
+BLUE='\[\e[34m\]'
+YELLOW='\[\e[33m\]'
+RED='\[\e[31m\]'
+
+# Exit-status-aware prompt (shows red if last command failed)
+set_prompt() {
+ local exit_code=$?
+ local status_color="${GREEN}"
+ [ $exit_code -ne 0 ] && status_color="${RED}"
+
+ PS1="${status_color}\u${RESET}@${GREEN}\h${RESET}:${YELLOW}\w${RESET}\$(git_branch)${BOLD} \$ ${RESET}"
+}
+PROMPT_COMMAND="set_prompt; ${PROMPT_COMMAND}"