aboutsummaryrefslogtreecommitdiff
path: root/shell/ksh
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-09-12 23:10:58 -0400
committerMitch Riedstra <mitch@riedstra.us>2019-09-12 23:10:58 -0400
commit75ed7b4f86cd883f32b88d5613ff46d8a21f6794 (patch)
treed38260dd255458b2a02193d4e0e2e0f6fe9f6027 /shell/ksh
parent879d857e0eafa1f716d9e156862154baf49d7655 (diff)
downloaddotfiles-75ed7b4f86cd883f32b88d5613ff46d8a21f6794.tar.gz
dotfiles-75ed7b4f86cd883f32b88d5613ff46d8a21f6794.tar.xz
Split my shell configuration into multiple files and a build script to generate for multiple shells
Diffstat (limited to 'shell/ksh')
-rw-r--r--shell/ksh79
1 files changed, 79 insertions, 0 deletions
diff --git a/shell/ksh b/shell/ksh
new file mode 100644
index 0000000..811b15b
--- /dev/null
+++ b/shell/ksh
@@ -0,0 +1,79 @@
+# If you wish to prevent non KSH shells from running this
+# [ -z "$KSH_VERSION" ] && return
+
+# Restrict this to KSH only
+if ! [ -z "$KSH_VERSION" ] ; then
+ precmd() {
+ typeset e=$?
+
+ (( e )) && print -n "$e|"
+ }
+ set_ps1() {
+ PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${USER_C}${USER:=$(id -un)}@$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C}
+ ${END_P} '
+ export PS1;
+ }
+ set_root_ps1() {
+ PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${HOST_C}$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C}
+ ${END_P} '
+ export PS1;
+ }
+ # RED: 31, GREEN: 32, YELLOW: 33, BLUE: 34, MAGENTA: 35, CYAN: 36, WHITE: 37, GREY 38. and No color which is 0.
+ set_prompt() {
+ if [ `id -u` -eq 0 ] ; then
+ # Previously
+ # Red for root, and no username
+ # PS1="$(hostname) \$PWD
+ echo $TERM | grep "256color$" > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ BG=""
+ ACCENT_C=""
+ ACCENT_P="|"
+ HOST_C=""
+ PATH_C=""
+ END_C=""
+ set_root_ps1
+ END_P="#"
+ else
+ BG=""
+ ACCENT_C=""
+ ACCENT_P="|"
+ HOST_C=""
+ PATH_C=""
+ END_P="#"
+ fi
+ set_root_ps1
+ else
+ # Previously
+ # PS1="${USER:=$(id -un)}@$(hostname) \$PWD
+ echo $TERM | grep "256color$" > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ BG=""
+ ACCENT_C=""
+ ACCENT_P="|"
+ USER_C=""
+ PATH_C=""
+ END_C=""
+ END_P="%"
+ else
+ BG=""
+ ACCENT_C=""
+ ACCENT_P="|"
+ USER_C=""
+ PATH_C=""
+ END_C=""
+ END_P="$"
+ fi
+ set_ps1
+ fi
+ }
+ set_basic_prompt() {
+ if [ $(id -u) -eq 0 ] ; then
+ PS1='$(precmd)'"${USER:=$(id -un)}@$(hostname) \$PWD # "
+ else
+ PS1='$(precmd)'"${USER:=$(id -un)}@$(hostname) \$PWD $ "
+ fi
+ export PS1;
+ }
+fi
+