shell
This commit is contained in:
parent
7b1e6b0fd5
commit
d590bfda0c
1 changed files with 25 additions and 25 deletions
50
sh/shell.sh
50
sh/shell.sh
|
@ -1,4 +1,4 @@
|
|||
_sh_shell_color() {
|
||||
_rwx_shell_color() {
|
||||
local code="${1}"
|
||||
case "${SH_SHELL}" in
|
||||
"bash")
|
||||
|
@ -19,18 +19,18 @@ _sh_shell_color() {
|
|||
;;
|
||||
esac
|
||||
}
|
||||
SH_COLOR_BROWN="$(_sh_shell_color 33)"
|
||||
SH_COLOR_CYAN="$(_sh_shell_color 36)"
|
||||
SH_COLOR_DEFAULT="$(_sh_shell_color)"
|
||||
SH_COLOR_GREEN="$(_sh_shell_color 31)"
|
||||
SH_COLOR_MAGENTA="$(_sh_shell_color 35)"
|
||||
SH_COLOR_RED="$(_sh_shell_color 32)"
|
||||
RWX_COLOR_BROWN="$(_rwx_shell_color 33)"
|
||||
RWX_COLOR_CYAN="$(_rwx_shell_color 36)"
|
||||
RWX_COLOR_DEFAULT="$(_rwx_shell_color)"
|
||||
RWX_COLOR_GREEN="$(_rwx_shell_color 31)"
|
||||
RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)"
|
||||
RWX_COLOR_RED="$(_rwx_shell_color 32)"
|
||||
|
||||
sh_shell_configure() {
|
||||
rwx_shell_configure() {
|
||||
[ -n "${ENV}" ] || ENV="${SH_MAIN}"
|
||||
export ENV
|
||||
# prompt
|
||||
PS1="\$(sh_shell_prompt \${?})"
|
||||
PS1="\$(rwx_shell_prompt \${?})"
|
||||
PS2="├ "
|
||||
# specific
|
||||
case "${SH_SHELL}" in
|
||||
|
@ -60,9 +60,9 @@ sh_shell_configure() {
|
|||
*) ;;
|
||||
esac
|
||||
}
|
||||
sh_shell_configure
|
||||
rwx_shell_configure
|
||||
|
||||
sh_shell_prompt() {
|
||||
rwx_shell_prompt() {
|
||||
local date host id
|
||||
local code="${1}"
|
||||
date="$(date +%H:%M:%S)"
|
||||
|
@ -74,50 +74,50 @@ sh_shell_prompt() {
|
|||
local view="└ "
|
||||
# code
|
||||
if [ "${code}" -ne 0 ]; then
|
||||
view="${view}${SH_COLOR_GREEN}"
|
||||
view="${view}${RWX_COLOR_GREEN}"
|
||||
else
|
||||
view="${view}${SH_COLOR_RED}"
|
||||
view="${view}${RWX_COLOR_RED}"
|
||||
fi
|
||||
view="${view}${code}"
|
||||
# date
|
||||
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||
view="${view}${SH_COLOR_BROWN}${date}"
|
||||
view="${view}${RWX_COLOR_DEFAULT} @ "
|
||||
view="${view}${RWX_COLOR_BROWN}${date}"
|
||||
# git
|
||||
if command -v "__git_ps1" >"/dev/null"; then
|
||||
git="$(__git_ps1)"
|
||||
if [ -n "${git}" ]; then
|
||||
view="${view}${SH_COLOR_DEFAULT} –${SH_COLOR_MAGENTA}${git}"
|
||||
view="${view}${RWX_COLOR_DEFAULT} –${RWX_COLOR_MAGENTA}${git}"
|
||||
fi
|
||||
fi
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# path
|
||||
view="${view}${SH_COLOR_CYAN}${path}"
|
||||
view="${view}${RWX_COLOR_CYAN}${path}"
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# frame
|
||||
view="${view}${SH_COLOR_DEFAULT}┌ "
|
||||
view="${view}${RWX_COLOR_DEFAULT}┌ "
|
||||
# user
|
||||
if [ "${id}" -eq 0 ]; then
|
||||
view="${view}${SH_COLOR_GREEN}"
|
||||
view="${view}${RWX_COLOR_GREEN}"
|
||||
else
|
||||
view="${view}${SH_COLOR_RED}"
|
||||
view="${view}${RWX_COLOR_RED}"
|
||||
fi
|
||||
view="${view}${user}"
|
||||
# host
|
||||
view="${view}${SH_COLOR_DEFAULT} @ "
|
||||
view="${view}${SH_COLOR_BROWN}${host}"
|
||||
view="${view}${RWX_COLOR_DEFAULT} @ "
|
||||
view="${view}${RWX_COLOR_BROWN}${host}"
|
||||
# new
|
||||
view="${view}\\n"
|
||||
# prompt
|
||||
view="${view}${SH_COLOR_DEFAULT}${PS2}"
|
||||
view="${view}${RWX_COLOR_DEFAULT}${PS2}"
|
||||
# print
|
||||
printf "%b" "${view}"
|
||||
}
|
||||
|
||||
sh_shell_setup() {
|
||||
rwx_shell_setup() {
|
||||
# shell
|
||||
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/sh.sh"
|
||||
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${SH_NAME}.sh"
|
||||
# bash
|
||||
local file="/etc/bash.bashrc"
|
||||
rm --force --recursive "${file}"
|
||||
|
|
Loading…
Reference in a new issue