config-bash/rc.d/prompt

46 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Customize the prompt
# 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
if (which powerline-go &> /dev/null); then
function _update_ps1() {
#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)
}
if [ "$TERM" != "linux" ] ; then
export PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
else
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) "