Initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/.env
|
||||
@@ -0,0 +1,11 @@
|
||||
# Thayol's Bash Prompt
|
||||
|
||||
Clone this repo:
|
||||
```
|
||||
git clone git@uncensored.hu:thayol/bash-prompt.git ~/.bash-prompt
|
||||
```
|
||||
|
||||
Add this to your `.bashrc`:
|
||||
```
|
||||
. $HOME/.bash-prompt/prompt.sh
|
||||
```
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Defaults (override in .env)
|
||||
PROMPT_ICON=""
|
||||
PROMPT_HOST_COLOR="255;255;255"
|
||||
PROMPT_DIR_COLOR="100;149;237"
|
||||
PROMPT_VPN_NAME=""
|
||||
PROMPT_VPN_COLOR="255;255;255"
|
||||
|
||||
_prompt_dir="${BASH_SOURCE[0]%/*}"
|
||||
[[ -f "$_prompt_dir/.env" ]] && . "$_prompt_dir/.env"
|
||||
|
||||
__prompt_git() {
|
||||
local branch
|
||||
branch=$(git branch --show-current 2>/dev/null) || return
|
||||
[[ -z $branch ]] && return
|
||||
echo -n " (${branch})"
|
||||
}
|
||||
|
||||
__prompt_vpn() {
|
||||
[[ -z $PROMPT_VPN_NAME ]] && return
|
||||
nmcli -f GENERAL.STATE con show "$PROMPT_VPN_NAME" &>/dev/null || return
|
||||
echo -n " → \[\e[38;2;${PROMPT_VPN_COLOR}m\]${PROMPT_VPN_NAME}\[\e[0m\]"
|
||||
}
|
||||
|
||||
__prompt_build() {
|
||||
local white='\[\e[37m\]'
|
||||
local reset='\[\e[0m\]'
|
||||
local host_color="\[\e[38;2;${PROMPT_HOST_COLOR}m\]"
|
||||
local dir_color="\[\e[38;2;${PROMPT_DIR_COLOR}m\]"
|
||||
|
||||
PS1="${white}[${reset}"
|
||||
PS1+="${host_color}\u@\h${r}"
|
||||
PS1+="$(__prompt_vpn)"
|
||||
PS1+="${white}:${reset}"
|
||||
PS1+="${dir_color}${PWD}${reset}"
|
||||
PS1+="${white}]${reset}"
|
||||
PS1+=" ${PROMPT_ICON}"
|
||||
PS1+="$(__prompt_git)"
|
||||
PS1+=' \$ '
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=__prompt_build
|
||||
Reference in New Issue
Block a user