Skip to content

Commit c70bf88

Browse files
committed
More about yash
1 parent 15430cb commit c70bf88

File tree

3 files changed

+18
-54
lines changed

3 files changed

+18
-54
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2017-2021 Alexandros Kozak
1+
Copyright 2017-2022 Alexandros Kozak
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Polyglot Prompt
1010

11-
The **Polyglot Prompt** is a dynamic prompt for `zsh`, `bash`, `ksh93`, `mksh`, `pdksh`, `dash`, and `busybox ash` that uses basic ASCII symbols (and color, when possible) to show:
11+
The **Polyglot Prompt** is a dynamic prompt for `zsh`, `bash`, `ksh93`, `mksh`, `pdksh`, `dash`, `yash`, and `busybox ash` that uses basic ASCII symbols (and color, when possible) to show:
1212

1313
* the username
1414
* whether a session is local or remote over SSH

polyglot.sh

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Polyglot Prompt
99
#
10-
# A dynamic color Git prompt for zsh, bash, ksh93, mksh, pdksh, dash, and
10+
# A dynamic color Git prompt for zsh, bash, ksh93, mksh, pdksh, dash, yash, and
1111
# busybox ash
1212
#
1313
#
@@ -30,7 +30,7 @@
3030
# ~/.../bar/bat/quux
3131
#
3232
#
33-
# Copyright 2017-2021 Alexandros Kozak
33+
# Copyright 2017-2022 Alexandros Kozak
3434
#
3535
# Permission is hereby granted, free of charge, to any person obtaining a copy
3636
# of this software and associated documentation files (the "Software"), to
@@ -327,17 +327,8 @@ _polyglot_basename() {
327327
# Tests to see if the current shell is busybox ash
328328
###########################################################
329329
_polyglot_is_busybox() {
330-
case $(_polyglot_basename "${0#-}") in
331-
ash|sh)
332-
if command -v readlink > /dev/null 2>&1; then
333-
case $(exec 2> /dev/null; readlink /proc/$$/exe) in
334-
*/busybox) return 0 ;;
335-
*) return 1 ;;
336-
esac
337-
else
338-
return 1
339-
fi
340-
;;
330+
case $(help 2> /dev/null) in
331+
'Built-in commands:'*) return 0 ;;
341332
*) return 1 ;;
342333
esac
343334
}
@@ -727,51 +718,24 @@ elif _polyglot_is_pdksh || [ "${0#-}" = 'dash' ] || _polyglot_is_busybox ||
727718
PS1=$PS1'$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
728719
PS1=$PS1$(print "$POLYGLOT_NP\033[0m$POLYGLOT_NP")
729720
PS1=$PS1' \$ '
730-
721+
731722
elif _polyglot_is_yash && _polyglot_has_colors; then
732723
PS1='\[\e[01;31m\]$(_polyglot_exit_status $?)\[\e[0m\]'
733724
PS1=$PS1'$(_polyglot_venv)'
734-
PS1=$PS1'\[\e[01;32m\]${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\[\e[0m\] '
725+
if ! _polyglot_is_superuser; then
726+
PS1=$PS1'\[\e[01;32m\]${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\[\e[0m\] '
727+
else
728+
PS1=$PS1'\[\e[7m\]${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\[\e[0m\] '
729+
fi
735730
PS1=$PS1'\[\e[01;34m\]$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")\[\e[0m\]'
736731
PS1=$PS1'\[\e[33m\]$(_polyglot_branch_status $POLYGLOT_KSH_BANG)\[\e[0m\] \$ '
737-
elif ! _polyglot_is_superuser; then
738-
PS1='$(_polyglot_exit_status $?)$(_polyglot_venv)${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) \$ '
739-
else # Superuser
740-
741-
##########################################################
742-
# Tests to see if the terminal is the DragonFly BSD system
743-
# console, which displays color in pdksh badly.
744-
##########################################################
745-
_polyglot_is_dragonfly_console() {
746-
case ${POLYGLOT_UNAME:=$(uname -s)} in
747-
DragonFly)
748-
case $(who am i) in
749-
*ttyv*) return 0 ;;
750-
*) return 1 ;;
751-
esac
752-
;;
753-
*) return 1 ;;
754-
esac
755-
}
756-
757-
PS1=
758-
_polyglot_is_pdksh && ! _polyglot_is_dragonfly_console && PS1=$(print "$POLYGLOT_NP\r")
759-
PS1=$PS1'$(_polyglot_exit_status $?)'
760-
if _polyglot_is_pdksh && ! _polyglot_is_dragonfly_console; then
761-
case $POLYGLOT_UNAME in
762-
NetBSD|OpenBSD) PS1="$PS1$(print "$POLYGLOT_NP")" ;;
763-
esac
732+
else
733+
PS1='$(_polyglot_exit_status $?)$(_polyglot_venv)${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) '
734+
if ! _polyglot_is_superuser; then
735+
PS1=$PS1'$ '
736+
else
737+
PS1=$PS1'# '
764738
fi
765-
PS1=$PS1'$(_polyglot_venv)'
766-
# shellcheck disable=SC2025
767-
! _polyglot_is_dragonfly_console && [ "${0#-}" != 'dash' ] && PS1="$PS1\033[7m"
768-
_polyglot_is_pdksh && ! _polyglot_is_dragonfly_console && PS1=$PS1$(print "$POLYGLOT_NP")
769-
PS1=$PS1'${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING'
770-
_polyglot_is_pdksh && ! _polyglot_is_dragonfly_console && PS1=$PS1$(print "$POLYGLOT_NP")
771-
# shellcheck disable=SC2025
772-
! _polyglot_is_dragonfly_console && [ "${0#-}" != 'dash' ] && PS1="$PS1\033[0m"
773-
_polyglot_is_pdksh && ! _polyglot_is_dragonfly_console && PS1=$PS1$(print "$POLYGLOT_NP")
774-
PS1=$PS1' $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) # '
775739
fi
776740
else
777741
printf '%s\n' 'Polyglot Prompt does not support your shell.' >&2

0 commit comments

Comments
 (0)