From 5139c4367ea1fd0f6fc06849435650289c9551b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 03:21:30 +0100 Subject: [PATCH] fixes --- shell/main.sh | 6 ------ shell/shell.sh | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/shell/main.sh b/shell/main.sh index c8d2607..0ccf86b 100644 --- a/shell/main.sh +++ b/shell/main.sh @@ -1,11 +1,5 @@ [ -n "${ENV}" ] || export ENV="/etc/shell/main.sh" -main_link_bashrc() { - local file="/etc/bash.bashrc" - rm --force "${file}" - ln --symbolic "${MAIN_USERS_FILE}" "${file}" -} - main_source_directory() { local path="${1}" if [ -d "${path}" ]; then diff --git a/shell/shell.sh b/shell/shell.sh index 5e100fa..d8df42b 100644 --- a/shell/shell.sh +++ b/shell/shell.sh @@ -1,4 +1,4 @@ -PS1="\$(ps1 \${?})" +PS1="\$(shell_prompt \${?})" PS2="\ ├ " SH="$(cat /proc/$$/comm)" @@ -30,25 +30,26 @@ SH_GREEN="$(shell_color 31)" SH_MAGENTA="$(shell_color 35)" SH_RED="$(shell_color 32)" -case "${SH}" in -"bash") - # completion - file="/usr/share/bash-completion/bash_completion" - if [ -f "${file}" ]; then - . "${file}" - fi - # history - HISTCONTROL="ignorespace" - HISTSIZE=-1 - HISTTIMEFORMAT="%Y%m%d %H%M%S " - ;; -*) - ;; -esac +shell_configure() { + case "${SH}" in + "bash") + # completion + file="/usr/share/bash-completion/bash_completion" + if [ -f "${file}" ]; then + . "${file}" + fi + # history + HISTCONTROL="ignorespace" + HISTSIZE=-1 + HISTTIMEFORMAT="%Y%m%d %H%M%S " + ;; + *) + ;; + esac +} +shell_configure -# prompt - -ps1() { +shell_prompt() { local date host id local code="${1}" date="$(date +%H:%M:%S)" @@ -103,3 +104,12 @@ ps1() { # print printf "%s" "${view}" } + +shell_setup() { + # shell + echo "export ENV=\"${ENV}\"" >"/etc/profile.d/shell.sh" + # bash + local file="/etc/bash.bashrc" + rm --force --recursive "${file}" + ln --symbolic "${ENV}" "${file}" +}