blob: e613146f35cf4c72ce0cc83f04bb52d7f0909827 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# This file contains examples of some of the things you may want to
# include in a user startup file.
# Set the shell options
set -o emacs -o notify -o globstar
[[ -o nobackslashctrl ]] && set -o nobackslashctrl
[[ -o globcasedetect ]] && set -o globcasedetect
#[[ -o noarrowkeysearch ]] && set -o noarrowkeysearch
# Specify search path for autoloadable functions
FPATH=/usr/share/ksh/functions:~/.func
# Optional: Autoload functions installed with ksh
#autoload autocd cd dirs man mcd popd pushd
# Optional: Set the precision of the time keyword to six and use %C
#((.sh.version >= 20220606)) && TIMEFORMAT=$'\nreal\t%6lR\ncpu\t%6lC'
# Optional: Avoid certain file types in completion
#FIGNORE='@(*.o|~*)'
# Save more commands in history
HISTSIZE=2000
#HISTEDIT=$EDITOR
# Remove the problematic default 'r' alias (this is only
# done when it's safe, as old versions of ksh can crash
# after 'unalias r').
((.sh.version >= 20220806)) && unalias r
# Below is a basic example that provides extra tilde expansions
if ((.sh.version >= 20210318)) && [[ $(id -u) != 0 ]]; then
.sh.tilde.get()
{
case ${.sh.tilde} in
'~docs') .sh.tilde=~/Documents ;;
'~dls') .sh.tilde=~/Downloads ;;
'~share') .sh.tilde=~/.local/share ;;
esac
}
fi
# Associative array containing a set of RGB color codes.
# Terminals emulators with support for wide color ranges
# can take better advantage of this.
typeset -A color=(
[bright_lavender]=$'\E[38;2;191;148;228m'
[red]=$'\E[38;2;255;0;0m'
[cyan_process]=$'\E[38;2;0;183;235m'
[ultramarine_blue]=$'\E[38;2;65;102;245m'
[reset]=$'\E[0m'
# Some extra examples
#[start_title]=$'\E]0;'
#[bell]=$'\a'
#[underline]=$'\E[4m'
#[spaced_dots]=$'\E[4:5m'
)
# Get the effective user ID now to avoid running id(1) every time $PS1 is printed
integer euid=$(id -u)
PS1.get()
{
ret=$? # Workaround $? bug in ksh < 2021-03-16 (cf. https://github.com/ksh93/ksh/pull/226)
pwd=$(pwd 2>/dev/null)
case ${pwd} in
~) pwd='~' ;;
~docs) pwd='~docs' ;;
~dls) pwd='~dls' ;;
~share) pwd='~share' ;;
'') pwd="${color[red]}No pwd found" ;;
/) ;; # Do nothing
*) pwd=${pwd##*/} ;;
esac
if ((euid == 0)); then
.sh.value='${color[bright_lavender]}${pwd} ${color[red]}#${color[reset]} '
else
.sh.value='${color[ultramarine_blue]}${pwd} ${color[cyan_process]}\$${color[reset]} '
fi
return $ret
}
|