Compare commits

..
6 Commits
Author SHA1 Message Date
thayol 6c17db1aaf Extend prompt command instead of replacing it 2026-09-21 10:40:55 +02:00
thayol 931795fdc2 Update recommended clone URL 2026-07-08 15:47:56 +02:00
thayol 74b2b46d05 Fix nmcli output going to /dev/null 2026-07-08 15:46:37 +02:00
thayol aebebf79cb Fix VPN always being detected 2026-07-08 15:42:26 +02:00
thayol 19c251cc26 Colorize master and main branches 2026-07-08 15:38:55 +02:00
thayol 9ca1af4661 Update README 2026-07-08 15:25:14 +02:00
2 changed files with 27 additions and 4 deletions
+4 -1
View File
@@ -2,10 +2,13 @@
Clone this repo:
```
git clone git@uncensored.hu:thayol/bash-prompt.git ~/.bash-prompt
git clone https://git.uncensored.hu/thayol/bash-prompt.git ~/.bash-prompt
```
Add this to your `.bashrc`:
```
. $HOME/.bash-prompt/prompt.sh
```
Optionally create a `.env` file (in the repo root) to customize the look.
You can find the available variables in `prompt.sh`.
+22 -2
View File
@@ -6,20 +6,31 @@ PROMPT_HOST_COLOR="255;255;255"
PROMPT_DIR_COLOR="100;149;237"
PROMPT_VPN_NAME=""
PROMPT_VPN_COLOR="255;255;255"
PROMPT_HIGHLIGHTED_BRANCH_COLOR="255;84;84"
_prompt_dir="${BASH_SOURCE[0]%/*}"
[[ -f "$_prompt_dir/.env" ]] && . "$_prompt_dir/.env"
__prompt_git() {
local color
local color_reset
local branch
color=""
color_reset=""
branch=$(git branch --show-current 2>/dev/null) || return
[[ -z $branch ]] && return
echo -n " (${branch})"
if [[ $branch =~ main|master ]] && [[ -n $PROMPT_HIGHLIGHTED_BRANCH_COLOR ]]; then
color="\[\e[38;2;${PROMPT_HIGHLIGHTED_BRANCH_COLOR}m\]"
color_reset="\[\e[0m\]"
fi
echo -n " (${color}${branch}${color_reset})"
}
__prompt_vpn() {
[[ -z $PROMPT_VPN_NAME ]] && return
nmcli -f GENERAL.STATE con show "$PROMPT_VPN_NAME" &>/dev/null || return
[[ -z $(nmcli -f GENERAL.STATE con show "$PROMPT_VPN_NAME") ]] && return
echo -n " → \[\e[38;2;${PROMPT_VPN_COLOR}m\]${PROMPT_VPN_NAME}\[\e[0m\]"
}
@@ -46,4 +57,13 @@ __prompt_build() {
PS1+=' \$ '
}
case ";${PROMPT_COMMAND-};" in
*";__prompt_build;"*) ;;
*)
if [[ -n ${PROMPT_COMMAND-} ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND}; __prompt_build"
else
PROMPT_COMMAND=__prompt_build
fi
;;
esac