PS1="\$(shell_prompt \${?})" PS2="\ ├ " shell_color() { local code="${1}" # shellcheck disable=SC2154 case "${SH}" in "bash") printf "\x01\e[0" if [ -n "${code}" ]; then printf "%s" ";${code}" fi printf "m\x02" ;; *) printf "\033[" if [ -n "${code}" ]; then printf "%s" "${code}" else printf "0" fi printf "m" ;; esac } SH_BROWN="$(shell_color 33)" SH_CYAN="$(shell_color 36)" SH_DEFAULT="$(shell_color)" SH_GREEN="$(shell_color 31)" SH_MAGENTA="$(shell_color 35)" SH_RED="$(shell_color 32)" shell_configure() { case "${SH}" in "bash") # completion local 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 shell_prompt() { local date host id local code="${1}" date="$(date +%H:%M:%S)" local git host="$(hostname)" id="$(id --user)" local path="${PWD}" local user="${USER}" local view="└ " # code if [ "${code}" -ne 0 ]; then view="${view}${SH_GREEN}" else view="${view}${SH_RED}" fi view="${view}${code}" # date view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${date}" # git if command -v "__git_ps1" >"/dev/null"; then git="$(__git_ps1)" if [ -n "${git}" ]; then view="${view}${SH_DEFAULT} –${SH_MAGENTA}${git}" fi fi # new view="${view}\\n" # path view="${view}${SH_CYAN}${path}" # new view="${view}\\n" # frame view="${view}${SH_DEFAULT}┌ " # user if [ "${id}" -eq 0 ]; then view="${view}${SH_GREEN}" else view="${view}${SH_RED}" fi view="${view}${user}" # host view="${view}${SH_DEFAULT} @ " view="${view}${SH_BROWN}${host}" # new view="${view}\\n" # prompt view="${view}${SH_DEFAULT}${PS2}" # print printf "%b" "${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}" }