This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues or pull requests.
bash-shell-base/misc/00-prompt
David Kebler e25e44a98d added setup directory with set of user and system source files that can be copied in new machine
changed setup.sh to load.sh
startup only loads system repos by default and allows passing directory argument
2020-11-10 14:09:08 -08:00

54 lines
1.2 KiB
Bash

#!/bin/bash
# see
# used http://bashrcgenerator.com/
# and
# https://unix.stackexchange.com/questions/148/colorizing-your-terminal-and-shell-environment/174#174
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
function fancy_prompt () {
# if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
function c () {
local color
name=COLOR_$1
color=${!name}
echo '\['$color'\]'
}
case $TERM in
xterm*|rxvt*)
# local TITLEBAR='\[\033]0;\u ${NEW_PWD}\007\]'
local PARENTBASE='${PWD#"${PWD%/*/*}/"}'
;;
*)
local PARENTBASE=''
# local TITLEBAR=""
;;
esac
local UC=WHITE # user's color
[ $UID -eq "0" ] && UC=LIGHT_RED # root's color
# PS1="$PARENTBASE\[${UC}\]\u@\h: \[${COLOR_LIGHT_GREEN}\]→\[${COLOR_NC}\] "
local user
local machine
local dir
local branch
local promptc
user="$(c $UC)\u$(c GREY)@$(c NC)"
machine="$(c CYAN)\h$(c GREY):$(c NC)"
dir="$(c YELLOW)[${PARENTBASE}]$(c NC)"
branch=$(c LIGHT_BLUE)'$(parse_git_branch)'$(c NC)
promptc=$(c GREEN)' $ '$(c NC)
PS1=$(echo "$user$machine$dir$branch$promptc")
# echo $PS1
}
# fancy prompt is on by default comment out to disable default
fancy_prompt