summaryrefslogtreecommitdiffstats
path: root/ksh/conf/prompt.ksh
blob: 0d654fe7905926db471ff80e093ff3e26cac6e67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#function _promp {
#	if [[ $(id -u) -eq 0 ]]; then
#		local SUFFIX='\w \$:'
#	else
#		local SUFFIX='\033[34m\w \033[1;33m\076\033[0m'
#	fi
#	print "$SUFFIX"
#}
#
#export PS1='
#$(_promp)'

PS1='$(
	case "$PWD/" in
		("$HOME"/*)
			_cwd="~${PWD#"${HOME}"}";;
		(*)
			cwd="$PWD";;
	esac

	_rprompt="$_cwd"
	_cols=$((COLUMNS - ${#_rprompt}))
	
	if [ $(id -u) -eq 0 ]
	then
		_color="1;31m"
	else
		_color="1;33m"
	fi

	printf "\n"
	printf "\\\\[\e[0m\\\\]\\\\[\e[s\\\\]"
	printf "\\\\[\e[%sG\\\\]" "$_cols"
	printf "%s" "$_rprompt"
	printf "\\\\[\e[u\\\\]"
	printf "\\\\[\e[%s\\\\]" "$_color"
	printf "> "
	printf "\\\\[\e[0m\\\\]"
)'

trap 'printf "\e[1;31mEXIT: %s\e[0m\n" "$?"' ERR
Un proyecto texto-plano.xyz