|
7 | 7 | #
|
8 | 8 | # Polyglot Prompt
|
9 | 9 | #
|
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 |
11 | 11 | # busybox ash
|
12 | 12 | #
|
13 | 13 | #
|
|
30 | 30 | # ~/.../bar/bat/quux
|
31 | 31 | #
|
32 | 32 | #
|
33 |
| -# Copyright 2017-2021 Alexandros Kozak |
| 33 | +# Copyright 2017-2022 Alexandros Kozak |
34 | 34 | #
|
35 | 35 | # Permission is hereby granted, free of charge, to any person obtaining a copy
|
36 | 36 | # of this software and associated documentation files (the "Software"), to
|
@@ -327,17 +327,8 @@ _polyglot_basename() {
|
327 | 327 | # Tests to see if the current shell is busybox ash
|
328 | 328 | ###########################################################
|
329 | 329 | _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 ;; |
341 | 332 | *) return 1 ;;
|
342 | 333 | esac
|
343 | 334 | }
|
@@ -727,51 +718,24 @@ elif _polyglot_is_pdksh || [ "${0#-}" = 'dash' ] || _polyglot_is_busybox ||
|
727 | 718 | PS1=$PS1'$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
728 | 719 | PS1=$PS1$(print "$POLYGLOT_NP\033[0m$POLYGLOT_NP")
|
729 | 720 | PS1=$PS1' \$ '
|
730 |
| - |
| 721 | + |
731 | 722 | elif _polyglot_is_yash && _polyglot_has_colors; then
|
732 | 723 | PS1='\[\e[01;31m\]$(_polyglot_exit_status $?)\[\e[0m\]'
|
733 | 724 | 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 |
735 | 730 | PS1=$PS1'\[\e[01;34m\]$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")\[\e[0m\]'
|
736 | 731 | 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'# ' |
764 | 738 | 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) # ' |
775 | 739 | fi
|
776 | 740 | else
|
777 | 741 | printf '%s\n' 'Polyglot Prompt does not support your shell.' >&2
|
|
0 commit comments