refactor themes to support standardized clock functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set term to 256color mode, if 256color is not supported, colors won't work properly
|
||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
|
||||
@@ -7,7 +7,6 @@ elif infocmp xterm-256color >/dev/null 2>&1; then
|
||||
export TERM=xterm-256color
|
||||
fi
|
||||
|
||||
|
||||
# Detect whether a rebbot is required
|
||||
function show_reboot_required() {
|
||||
if [ ! -z "$_bf_prompt_reboot_info" ]; then
|
||||
@@ -17,7 +16,6 @@ function show_reboot_required() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Set different host color for local and remote sessions
|
||||
function set_host_color() {
|
||||
# Detect if connection is through SSH
|
||||
@@ -28,7 +26,6 @@ function set_host_color() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Set different username color for users and root
|
||||
function set_user_color() {
|
||||
case $(id -u) in
|
||||
@@ -41,7 +38,6 @@ function set_user_color() {
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
scm_prompt() {
|
||||
CHAR=$(scm_char)
|
||||
if [ $CHAR = $SCM_NONE_CHAR ]
|
||||
@@ -52,8 +48,6 @@ scm_prompt() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define custom colors we need
|
||||
# non-printable bytes in PS1 need to be contained within \[ \].
|
||||
# Otherwise, bash will count them in the length of the prompt
|
||||
@@ -68,10 +62,12 @@ function set_custom_colors() {
|
||||
powder_blue="\[$(tput setaf 153)\]"
|
||||
}
|
||||
|
||||
__ps_time() {
|
||||
echo "$(clock_prompt)${normal}\n"
|
||||
}
|
||||
|
||||
function prompt_command() {
|
||||
ps_reboot="${bright_yellow}$(show_reboot_required)${normal}\n"
|
||||
ps_time="${dark_grey}\t${normal}\n"
|
||||
|
||||
ps_username="$(set_user_color)\u${normal}"
|
||||
ps_uh_separator="${dark_grey}@${normal}"
|
||||
@@ -84,14 +80,14 @@ function prompt_command() {
|
||||
ps_user_input="${normal}"
|
||||
|
||||
# Set prompt
|
||||
PS1="$ps_reboot$ps_time$ps_username$ps_uh_separator$ps_hostname $ps_path $ps_scm_prompt$ps_user_mark$ps_user_input"
|
||||
PS1="$ps_reboot$(__ps_time)$ps_username$ps_uh_separator$ps_hostname $ps_path $ps_scm_prompt$ps_user_mark$ps_user_input"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Initialize custom colors
|
||||
set_custom_colors
|
||||
|
||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$dark_grey"}
|
||||
|
||||
# scm theming
|
||||
SCM_THEME_PROMPT_PREFIX=""
|
||||
SCM_THEME_PROMPT_SUFFIX=""
|
||||
|
||||
Reference in New Issue
Block a user