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