refactor themes to support standardized clock functions

pull/806/head
MunifTanjim 2016-10-18 20:25:51 +06:00
parent 8dde691671
commit a2a6fa2812
20 changed files with 110 additions and 66 deletions

View File

@ -1,3 +1,5 @@
#!/usr/bin/env bash
# Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" # Axin Bash Prompt, inspired by theme "Sexy" and "Bobby"
# thanks to them # thanks to them
@ -32,7 +34,9 @@ else
fi fi
function prompt_command() { function prompt_command() {
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]${white}\t \[$PURPLE\]\$(scm_prompt_info) \n\$ \[$RESET\]" PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]$(clock_prompt) \[$PURPLE\]\$(scm_prompt_info) \n\$ \[$RESET\]"
} }
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${white}"}
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -345,7 +345,7 @@ function git_user_info {
function clock_char { function clock_char {
CLOCK_CHAR=${THEME_CLOCK_CHAR:-"⌚"} CLOCK_CHAR=${THEME_CLOCK_CHAR:-"⌚"}
CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:="${red}"} CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$normal"}
SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"} SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
if [[ "${SHOW_CLOCK_CHAR}" = "true" ]]; then if [[ "${SHOW_CLOCK_CHAR}" = "true" ]]; then
@ -354,10 +354,10 @@ function clock_char {
} }
function clock_prompt { function clock_prompt {
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"}
[ -z $THEME_SHOW_CLOCK ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"} [ -z $THEME_SHOW_CLOCK ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
SHOW_CLOCK=$THEME_SHOW_CLOCK SHOW_CLOCK=$THEME_SHOW_CLOCK
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"}
if [[ "${SHOW_CLOCK}" = "true" ]]; then if [[ "${SHOW_CLOCK}" = "true" ]]; then
CLOCK_STRING=$(date +"${CLOCK_FORMAT}") CLOCK_STRING=$(date +"${CLOCK_FORMAT}")

View File

@ -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 # 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 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 export TERM=xterm-256color
fi fi
# Detect whether a rebbot is required # Detect whether a rebbot is required
function show_reboot_required() { function show_reboot_required() {
if [ ! -z "$_bf_prompt_reboot_info" ]; then if [ ! -z "$_bf_prompt_reboot_info" ]; then
@ -17,7 +16,6 @@ function show_reboot_required() {
fi fi
} }
# Set different host color for local and remote sessions # Set different host color for local and remote sessions
function set_host_color() { function set_host_color() {
# Detect if connection is through SSH # Detect if connection is through SSH
@ -28,7 +26,6 @@ function set_host_color() {
fi fi
} }
# Set different username color for users and root # Set different username color for users and root
function set_user_color() { function set_user_color() {
case $(id -u) in case $(id -u) in
@ -41,7 +38,6 @@ function set_user_color() {
esac esac
} }
scm_prompt() { scm_prompt() {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]
@ -52,8 +48,6 @@ scm_prompt() {
fi fi
} }
# Define custom colors we need # Define custom colors we need
# non-printable bytes in PS1 need to be contained within \[ \]. # non-printable bytes in PS1 need to be contained within \[ \].
# Otherwise, bash will count them in the length of the prompt # Otherwise, bash will count them in the length of the prompt
@ -68,10 +62,12 @@ function set_custom_colors() {
powder_blue="\[$(tput setaf 153)\]" powder_blue="\[$(tput setaf 153)\]"
} }
__ps_time() {
echo "$(clock_prompt)${normal}\n"
}
function prompt_command() { function prompt_command() {
ps_reboot="${bright_yellow}$(show_reboot_required)${normal}\n" ps_reboot="${bright_yellow}$(show_reboot_required)${normal}\n"
ps_time="${dark_grey}\t${normal}\n"
ps_username="$(set_user_color)\u${normal}" ps_username="$(set_user_color)\u${normal}"
ps_uh_separator="${dark_grey}@${normal}" ps_uh_separator="${dark_grey}@${normal}"
@ -84,14 +80,14 @@ function prompt_command() {
ps_user_input="${normal}" ps_user_input="${normal}"
# Set prompt # 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 # Initialize custom colors
set_custom_colors set_custom_colors
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$dark_grey"}
# scm theming # scm theming
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_PREFIX=" |"
@ -12,9 +13,22 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"
RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|" RVM_THEME_PROMPT_SUFFIX="|"
function prompt_command() { __bobby_clock() {
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " printf "$(clock_prompt) "
PS1="\n$(battery_char) $(clock_prompt) $(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then
printf "$(clock_char) "
fi
} }
function prompt_command() {
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
PS1="\n$(battery_char) $(__bobby_clock)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$red"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_cyan"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"}
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -1,3 +1,5 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""
@ -25,10 +27,10 @@ scm_prompt() {
} }
prompt() { prompt() {
PS1="${white}${background_blue} \u${normal}${background_blue}@${red}${background_blue}\h ${blue}${background_white} \t ${reset_color}${normal} $(battery_charge) PS1="${white}${background_blue} \u${normal}${background_blue}@${red}${background_blue}\h $(clock_prompt) ${reset_color}${normal} $(battery_charge)\n${bold_black}${background_white} \w ${normal}$(scm_prompt)$(is_vim_shell)\n${white}>${normal} "
${bold_black}${background_white} \w ${normal}$(scm_prompt)$(is_vim_shell)
${white}>${normal} "
} }
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue$background_white"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-" %H:%M:%S"}
safe_append_prompt_command prompt safe_append_prompt_command prompt

View File

@ -1,6 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function prompt_command() { function prompt_command() {
PS1="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} "; PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
} }
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_DIRTY=''
SCM_THEME_PROMPT_CLEAN='' SCM_THEME_PROMPT_CLEAN=''
SCM_GIT_CHAR="${bold_cyan}±${normal}" SCM_GIT_CHAR="${bold_cyan}±${normal}"
@ -43,14 +44,8 @@ function prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
then
clock="\t"
else
clock=$THEME_PROMPT_CLOCK_FORMAT
fi
PS1=" PS1="
$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w $(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(doubletime_scm_prompt)$reset_color $ " $(doubletime_scm_prompt)$reset_color $ "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -7,14 +7,8 @@ function prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
then
clock="\t"
else
clock=$THEME_PROMPT_CLOCK_FORMAT
fi
PS1=" PS1="
$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
\w \w
$(doubletime_scm_prompt)$reset_color $ " $(doubletime_scm_prompt)$reset_color $ "
PS2='> ' PS2='> '

View File

@ -7,14 +7,8 @@ function prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
then
clock="\t"
else
clock=$THEME_PROMPT_CLOCK_FORMAT
fi
PS1=" PS1="
$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt) $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
\w \w
$(doubletime_scm_prompt)$reset_color $ " $(doubletime_scm_prompt)$reset_color $ "
PS2='> ' PS2='> '

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_PREFIX=" |"
@ -27,8 +28,15 @@ function get_hour_color {
echo "$hour_color" echo "$hour_color"
} }
function prompt_command() { __emperor_clock() {
PS1="\n$(get_hour_color)$(date +%H) ${purple}\h ${reset_color}in ${prompt_color}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " THEME_CLOCK_COLOR=$(get_hour_color)
clock_prompt
} }
function prompt_command() {
PS1="\n$(__emperor_clock)${purple}\h ${reset_color}in ${prompt_color}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H "}
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX="(${yellow}" SCM_THEME_PROMPT_PREFIX="(${yellow}"
@ -13,7 +14,7 @@ RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX="" RVM_THEME_PROMPT_SUFFIX=""
function prompt_command() { function prompt_command() {
dtime="${yellow}\T${normal}" dtime="$(clock_prompt)"
user_host="${green}\u@${cyan}\h${normal}" user_host="${green}\u@${cyan}\h${normal}"
current_dir="${bold_blue}\w${normal}" current_dir="${bold_blue}\w${normal}"
rvm_ruby="${bold_red}$(ruby_version_prompt)${normal}" rvm_ruby="${bold_red}$(ruby_version_prompt)${normal}"
@ -22,8 +23,11 @@ function prompt_command() {
arrow="${bold_white}${normal} " arrow="${bold_white}${normal} "
prompt="${bold_green}\$${normal} " prompt="${bold_green}\$${normal} "
PS1="${dtime} ${user_host}:${current_dir} ${rvm_ruby} ${git_branch} PS1="${dtime}${user_host}:${current_dir} ${rvm_ruby} ${git_branch}
$arrow $prompt" $arrow $prompt"
} }
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$yellow"}
THEME_CLOCK_FORMAT=${THEME_TIME_FORMAT:-"%I:%M:%S "}
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/usr/bin/env bash
# Two line prompt showing the following information: # Two line prompt showing the following information:
# (time) SCM [username@hostname] pwd (SCM branch SCM status) # (time) SCM [username@hostname] pwd (SCM branch SCM status)
# → # →
# #
# Example: # Example:
# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓) # (14:00:26) ± [foo@bar] ~/.bash_it (master ✓)
# → # →
# #
# The arrow on the second line is showing the exit status of the last command: # The arrow on the second line is showing the exit status of the last command:
# * Green: 0 exit status # * Green: 0 exit status
@ -32,7 +32,7 @@ prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
PS1="(\t) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) " PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '
} }

View File

@ -55,6 +55,7 @@ function randomize_nwinkler {
USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
HOSTNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} HOSTNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
TIME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} TIME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
THEME_CLOCK_COLOR=$TIME_COLOR
PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE
@ -67,6 +68,7 @@ then
USERNAME_COLOR=${COLORS[0]} USERNAME_COLOR=${COLORS[0]}
HOSTNAME_COLOR=${COLORS[1]} HOSTNAME_COLOR=${COLORS[1]}
TIME_COLOR=${COLORS[2]} TIME_COLOR=${COLORS[2]}
THEME_CLOCK_COLOR=$TIME_COLOR
PATH_COLOR=${COLORS[3]} PATH_COLOR=${COLORS[3]}
else else
# No colors stored yet. Generate them! # No colors stored yet. Generate them!
@ -97,7 +99,7 @@ prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
PS1="(${TIME_COLOR}\t${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) " PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '
} }

View File

@ -5,7 +5,7 @@ prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
PS1="(\t) $(scm_char) [$blue\u$reset_color@$green\H$reset_color] $yellow\w${reset_color}$(scm_prompt_info)$(ruby_version_prompt) $reset_color " PS1="($(clock_prompt)) $(scm_char) [$blue\u$reset_color@$green\H$reset_color] $yellow\w${reset_color}$(scm_prompt_info)$(ruby_version_prompt) $reset_color "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '
} }

View File

@ -33,7 +33,7 @@ For now, the only supported value is `sudo`, which hides the username and hostna
By default, the current time is shown on the right hand side, you can change the format using the following variable: By default, the current time is shown on the right hand side, you can change the format using the following variable:
POWERLINE_PROMPT_CLOCK_FORMAT="%H:%M:%S" THEME_CLOCK_FORMAT="%H:%M:%S"
The time/date is printed by the `date` command, so refer to its man page to change the format. The time/date is printed by the `date` command, so refer to its man page to change the format.

View File

@ -40,7 +40,7 @@ BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
THEME_PROMPT_CLOCK_FORMAT=${POWERLINE_PROMPT_CLOCK_FORMAT:="%H:%M:%S"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim" IN_VIM_THEME_PROMPT_TEXT="vim"
@ -136,7 +136,7 @@ function __powerline_cwd_prompt {
} }
function __powerline_clock_prompt { function __powerline_clock_prompt {
echo "$(date +"${THEME_PROMPT_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}" echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}"
} }
function __powerline_battery_prompt { function __powerline_battery_prompt {

View File

@ -2,7 +2,10 @@
# based of the candy theme, but minimized by odbol # based of the candy theme, but minimized by odbol
function prompt_command() { function prompt_command() {
PS1="${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} "; PS1="$(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
} }
safe_append_prompt_command prompt_command THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
safe_append_prompt_command prompt_command

View File

@ -8,9 +8,9 @@ export PROMPT_DIRTRIM=3
function prompt_command() { function prompt_command() {
if [[ ${EUID} == 0 ]] ; then if [[ ${EUID} == 0 ]] ; then
PS1="[\t]${yellow}[${red}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ " PS1="[$(clock_prompt)]${yellow}[${red}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ "
else else
PS1="[\t]${yellow}[${cyan}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ " PS1="[$(clock_prompt)]${yellow}[${cyan}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ "
fi fi
} }

View File

@ -1,3 +1,22 @@
#!/usr/bin/env bash
__tonka_time() {
THEME_CLOCK_FORMAT="%H%M"
clock_prompt
}
__tonka_date() {
THEME_CLOCK_FORMAT="%a,%d %b %y"
clock_prompt
}
__tonka_clock() {
local LIGHT_BLUE="\[\033[1;34m\]"
if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then
echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:"
fi
}
prompt_setter() { prompt_setter() {
# Named "Tonka" because of the colour scheme # Named "Tonka" because of the colour scheme
@ -23,8 +42,8 @@ $YELLOW\$PWD\
$LIGHT_BLUE)-$YELLOW-\ $LIGHT_BLUE)-$YELLOW-\
\n\ \n\
$YELLOW-$LIGHT_BLUE-(\ $YELLOW-$LIGHT_BLUE-(\
$YELLOW\$(date +%H%M)$LIGHT_BLUE:$YELLOW\$(date \"+%a,%d %b %y\")\ $(__tonka_clock)\
$LIGHT_BLUE:$WHITE\\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR " $WHITE\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR "
PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR " PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR "
@ -32,6 +51,9 @@ PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR "
safe_append_prompt_command prompt_setter safe_append_prompt_command prompt_setter
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"\[\033[1;33m\]"}
export PS3=">> " export PS3=">> "
LS_COLORS='no=00:fi=00:di=00;33:ln=01;36:pi=40;34:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:'; LS_COLORS='no=00:fi=00:di=00;33:ln=01;36:pi=40;34:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:';

View File

@ -18,7 +18,9 @@ function prompt_command() {
else else
status=💔 status=💔
fi fi
PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w $status \n${bold_cyan} ${blue}|\t|${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w $status \n${bold_cyan} ${blue}|$(clock_prompt)|${green}$(scm_prompt_info) ${green}${reset_color} "
} }
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
PROMPT_COMMAND=prompt_command; PROMPT_COMMAND=prompt_command;