config-bash/rc.d/prompt

46 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# Customize the prompt
2019-01-24 17:52:48 +01:00
2019-06-26 18:29:51 +02:00
# Limit the path to 3 levels
PROMPT_DIRTRIM=3
# Use powerline-go if availaible
# -modules string
# The list of modules to load, separated by ','
# (valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
# (default "nix-shell,venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root,vgo")
# -modules-right string
# The list of modules to load anchored to the right, for shells that support it, separated by ','
# (valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load
2019-01-24 17:52:48 +01:00
if (which powerline-go &> /dev/null); then
function _update_ps1() {
2019-06-26 18:29:51 +02:00
#eval $(powerline-go -shell bash -mode patched -modules "nix-shell,cwd,perms,jobs,git,venv,docker,kube,aws" -modules-right "exit,ssh,user,host" -newline -error $? -eval)
eval $(powerline-go -shell bash -mode patched -modules "nix-shell,cwd,perms,jobs,git,venv,aws,docker,kube,exit" -newline -error $? -eval)
2019-01-24 17:52:48 +01:00
}
if [ "$TERM" != "linux" ] ; then
export PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
else
2019-01-24 17:52:48 +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
fi
# 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) "