commit
2728f20354
|
|
@ -141,6 +141,7 @@ themes/brunton
|
||||||
themes/candy
|
themes/candy
|
||||||
themes/command_duration.theme.bash
|
themes/command_duration.theme.bash
|
||||||
themes/easy
|
themes/easy
|
||||||
|
themes/essential
|
||||||
themes/modern
|
themes/modern
|
||||||
themes/powerline
|
themes/powerline
|
||||||
themes/pure
|
themes/pure
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,41 @@
|
||||||
#!/usr/bin/env bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
# https://github.com/koalaman/shellcheck/wiki/Sc2154
|
|
||||||
# shellcheck disable=SC2154
|
|
||||||
|
|
||||||
function _user-prompt() {
|
function _user-prompt() {
|
||||||
local -r user='\\u'
|
local -r user='\u'
|
||||||
|
|
||||||
if [[ "${EUID}" -eq 0 ]]; then
|
if [[ "${EUID}" -eq 0 ]]; then
|
||||||
# Privileged users:
|
# Privileged users:
|
||||||
local -r user_color="${bold_red}"
|
local -r user_color="${bold_red?}"
|
||||||
else
|
else
|
||||||
# Standard users:
|
# Standard users:
|
||||||
local -r user_color="${bold_green}"
|
local -r user_color="${bold_green?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print the current user's name (colored according to their current EUID):
|
# Print the current user's name (colored according to their current EUID):
|
||||||
echo -e "${user_color}${user}${normal}"
|
printf '%b%s%b' "${user_color}" "${user}" "${normal?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _host-prompt() {
|
function _host-prompt() {
|
||||||
local -r host='\\h'
|
local -r host='\h'
|
||||||
|
|
||||||
# Check whether or not $SSH_TTY is set:
|
# Check whether or not $SSH_TTY is set:
|
||||||
if [[ -z "${SSH_TTY}" ]]; then
|
if [[ -z "${SSH_TTY:-}" ]]; then
|
||||||
# For local hosts, set the host's prompt color to blue:
|
# For local hosts, set the host's prompt color to blue:
|
||||||
local -r host_color="${bold_blue}"
|
local -r host_color="${bold_blue?}"
|
||||||
else
|
else
|
||||||
# For remote hosts, set the host's prompt color to red:
|
# For remote hosts, set the host's prompt color to red:
|
||||||
local -r host_color="${bold_red}"
|
local -r host_color="${bold_red?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print the current hostname (colored according to $SSH_TTY's status):
|
# Print the current hostname (colored according to $SSH_TTY's status):
|
||||||
echo -e "${host_color}${host}${normal}"
|
printf '%b%s%b' "${host_color}" "${host}" "${normal?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _user-at-host-prompt() {
|
function _user-at-host-prompt() {
|
||||||
# Concatenate the user and host prompts into: user@host:
|
# Concatenate the user and host prompts into: user@host:
|
||||||
echo -e "$(_user-prompt)${bold_white}@$(_host-prompt)"
|
_user-prompt
|
||||||
|
printf '%b@' "${bold_white?}"
|
||||||
|
_host-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function _exit-status-prompt() {
|
function _exit-status-prompt() {
|
||||||
|
|
@ -47,37 +46,37 @@ function _exit-status-prompt() {
|
||||||
if [[ "${exit_status}" -eq 0 ]]; then
|
if [[ "${exit_status}" -eq 0 ]]; then
|
||||||
# For commands that return an exit status of zero, set the exit status's
|
# For commands that return an exit status of zero, set the exit status's
|
||||||
# notifier to green:
|
# notifier to green:
|
||||||
local -r exit_status_color="${bold_green}"
|
local -r exit_status_color="${bold_green?}"
|
||||||
else
|
else
|
||||||
# For commands that return a non-zero exit status, set the exit status's
|
# For commands that return a non-zero exit status, set the exit status's
|
||||||
# notifier to red:
|
# notifier to red:
|
||||||
local -r exit_status_color="${bold_red}"
|
local -r exit_status_color="${bold_red?}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -ne "${exit_status_color}"
|
|
||||||
if [[ "${prompt_string}" -eq 1 ]]; then
|
if [[ "${prompt_string}" -eq 1 ]]; then
|
||||||
# $PS1:
|
# $PS1:
|
||||||
echo -e " +${normal} "
|
printf '%b +%b' "${exit_status_color}" "${normal?} "
|
||||||
elif [[ "${prompt_string}" -eq 2 ]]; then
|
elif [[ "${prompt_string}" -eq 2 ]]; then
|
||||||
# $PS2:
|
# $PS2:
|
||||||
echo -e " |${normal} "
|
printf '%b |%b' "${exit_status_color}" "${normal?} "
|
||||||
else
|
else
|
||||||
# Default:
|
# Default:
|
||||||
echo -e " ?${normal} "
|
printf '%b ?%b' "${exit_status_color}" "${normal?} "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _ps1() {
|
function _ps1() {
|
||||||
local -r time='\\t'
|
local -r time='\t'
|
||||||
|
local -r pwd='\w'
|
||||||
|
|
||||||
echo -ne "${bold_white}${time} "
|
printf '%b%s ' "${bold_white?}" "${time}"
|
||||||
echo -ne "$(_user-at-host-prompt)"
|
_user-at-host-prompt
|
||||||
echo -e "${bold_white}:${normal}${PWD}"
|
printf '%b:%b%s\n' "${bold_white?}" "${normal?}" "${pwd}"
|
||||||
echo -e "$(_exit-status-prompt 1 "${exit_status}")"
|
_exit-status-prompt 1 "${exit_status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _ps2() {
|
function _ps2() {
|
||||||
echo -e "$(_exit-status-prompt 2 "${exit_status}")"
|
_exit-status-prompt 2 "${exit_status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
|
|
@ -92,5 +91,3 @@ function prompt_command() {
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_append_prompt_command prompt_command
|
safe_append_prompt_command prompt_command
|
||||||
|
|
||||||
# vim: sw=2 ts=2 et:
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue