2013-12-05 13:38:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Customize the prompt
|
2019-01-24 17:52:48 +01:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
POWERLINE_LOCATION=$(command -v powerline-go || command -v powerline) &>/dev/null
|
|
|
|
POWERLINE=$(basename "$POWERLINE_LOCATION")
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
if [ "${POWERLINE}" = "powerline-go" ]; then
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
echo "Using $POWERLINE"
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
function _update_ps1() {
|
2023-08-27 16:31:17 +02:00
|
|
|
PS1=$($POWERLINE -jobs "$(jobs -p | wc -l)" -error $? -modules "ssh,host,wsl,user,cwd,direnv,venv,perms,git,jobs,exit,root" -modules-right "docker,docker-context,kube,terraform-workspace,termtitle" -newline)
|
2022-12-13 12:08:41 +01:00
|
|
|
}
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
if [ "$TERM" != "linux" ]; then PROMPT_COMMAND="$PROMPT_COMMAND; _update_ps1"; fi
|
|
|
|
|
|
|
|
elif [ "${POWERLINE}" = "powerline" ]; then
|
|
|
|
|
|
|
|
echo "Using $POWERLINE"
|
|
|
|
|
|
|
|
# Run powerline daemon
|
|
|
|
powerline-daemon -q
|
|
|
|
# Cache powerline location
|
|
|
|
# To locate this directory, run: pip show powerline-status
|
|
|
|
export POWERLINE_LOCATION="/home/xavier/.local/lib/python3.10//site-packages/powerline" # Set up powerline environment
|
|
|
|
export POWERLINE_CONFIG_COMMAND=powerline-config
|
|
|
|
export POWERLINE_BASH_CONTINUATION=1
|
|
|
|
export POWERLINE_BASH_SELECT=1# Invoke binding script
|
|
|
|
. "$POWERLINE_LOCATION/bindings/bash/powerline.sh"
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2013-12-05 13:38:25 +01:00
|
|
|
else
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2022-12-13 12:08:41 +01:00
|
|
|
if [ "$UID" -eq 0 ]; then
|
|
|
|
export PS1='\[\e[01;31m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
|
|
|
|
else
|
|
|
|
export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
|
|
|
|
fi
|
2021-05-02 21:32:03 +02:00
|
|
|
|
2013-12-05 13:38:25 +01:00
|
|
|
fi
|
|
|
|
|
2015-09-18 12:14:41 +02:00
|
|
|
# Limit the path to 3 levels
|
|
|
|
PROMPT_DIRTRIM=3
|
|
|
|
|
2013-12-05 13:38:25 +01:00
|
|
|
# Add a smiley at end of prompt showing last command status code
|
|
|
|
#smiley() {
|
|
|
|
# ret_val=$?
|
|
|
|
# if [ "$ret_val" = "0" ]
|
|
|
|
# then
|
|
|
|
# echo -e "\e[01;32m:)\e[0m"
|
|
|
|
# else
|
|
|
|
# echo -e "\e[01;31m:(\e[0m"
|
|
|
|
# fi
|
|
|
|
#}
|
|
|
|
#export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '"\$(smiley) "
|