From a2a6fa2812e6b3afdf865bea2956aead22e0c261 Mon Sep 17 00:00:00 2001 From: MunifTanjim Date: Tue, 18 Oct 2016 20:25:51 +0600 Subject: [PATCH] refactor themes to support standardized clock functions --- themes/axin/axin.theme.bash | 6 ++++- themes/base.theme.bash | 6 ++--- themes/binaryanomaly/binaryanomaly.theme.bash | 18 +++++-------- themes/bobby/bobby.theme.bash | 20 +++++++++++--- themes/brunton/brunton.theme.bash | 10 ++++--- themes/candy/candy.theme.bash | 6 ++++- themes/doubletime/doubletime.theme.bash | 9 ++----- .../doubletime_multiline.theme.bash | 8 +----- .../doubletime_multiline_pyonly.theme.bash | 8 +----- themes/emperor/emperor.theme.bash | 12 +++++++-- themes/luan/luan.theme.bash | 8 ++++-- themes/nwinkler/nwinkler.theme.bash | 12 ++++----- .../nwinkler_random_colors.theme.bash | 4 ++- themes/pete/pete.theme.bash | 2 +- themes/powerline-multiline/README.md | 2 +- .../powerline-multiline.theme.bash | 4 +-- themes/primer/primer.theme.bash | 7 +++-- themes/roderik/roderik.theme.bash | 4 +-- themes/tonka/tonka.theme.bash | 26 +++++++++++++++++-- themes/wanelo/wanelo.theme.bash | 4 ++- 20 files changed, 110 insertions(+), 66 deletions(-) diff --git a/themes/axin/axin.theme.bash b/themes/axin/axin.theme.bash index 32684fbc..edca238b 100644 --- a/themes/axin/axin.theme.bash +++ b/themes/axin/axin.theme.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" # thanks to them @@ -32,7 +34,9 @@ else fi 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 diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 8895ef60..eae38254 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -345,7 +345,7 @@ function git_user_info { function 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"} if [[ "${SHOW_CLOCK_CHAR}" = "true" ]]; then @@ -354,10 +354,10 @@ function clock_char { } 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"} 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 CLOCK_STRING=$(date +"${CLOCK_FORMAT}") diff --git a/themes/binaryanomaly/binaryanomaly.theme.bash b/themes/binaryanomaly/binaryanomaly.theme.bash index 38afe72b..4c580eb5 100644 --- a/themes/binaryanomaly/binaryanomaly.theme.bash +++ b/themes/binaryanomaly/binaryanomaly.theme.bash @@ -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="" diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 3ec7cbda..1c78025c 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -1,4 +1,5 @@ #!/usr/bin/env bash + SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" @@ -12,9 +13,22 @@ GIT_THEME_PROMPT_SUFFIX="${green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" -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) $(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} " +__bobby_clock() { + printf "$(clock_prompt) " + + 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 diff --git a/themes/brunton/brunton.theme.bash b/themes/brunton/brunton.theme.bash index b085725a..baa05788 100644 --- a/themes/brunton/brunton.theme.bash +++ b/themes/brunton/brunton.theme.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" @@ -25,10 +27,10 @@ scm_prompt() { } prompt() { - PS1="${white}${background_blue} \u${normal}${background_blue}@${red}${background_blue}\h ${blue}${background_white} \t ${reset_color}${normal} $(battery_charge) -${bold_black}${background_white} \w ${normal}$(scm_prompt)$(is_vim_shell) -${white}>${normal} " - + 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} " } +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue$background_white"} +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-" %H:%M:%S"} + safe_append_prompt_command prompt diff --git a/themes/candy/candy.theme.bash b/themes/candy/candy.theme.bash index fe3c2dff..f3f0abfc 100644 --- a/themes/candy/candy.theme.bash +++ b/themes/candy/candy.theme.bash @@ -1,6 +1,10 @@ #!/usr/bin/env bash + 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 diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 6146b215..3f686668 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -1,4 +1,5 @@ #!/usr/bin/env bash + SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_CLEAN='' SCM_GIT_CHAR="${bold_cyan}±${normal}" @@ -43,14 +44,8 @@ function prompt_setter() { history -a history -c history -r - if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]] - then - clock="\t" - else - clock=$THEME_PROMPT_CLOCK_FORMAT - fi 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 $ " PS2='> ' PS4='+ ' diff --git a/themes/doubletime_multiline/doubletime_multiline.theme.bash b/themes/doubletime_multiline/doubletime_multiline.theme.bash index 759917c2..6da88253 100644 --- a/themes/doubletime_multiline/doubletime_multiline.theme.bash +++ b/themes/doubletime_multiline/doubletime_multiline.theme.bash @@ -7,14 +7,8 @@ function prompt_setter() { history -a history -c history -r - if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]] - then - clock="\t" - else - clock=$THEME_PROMPT_CLOCK_FORMAT - fi 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 $(doubletime_scm_prompt)$reset_color $ " PS2='> ' diff --git a/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash b/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash index a77ce55f..5f1951e9 100644 --- a/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash +++ b/themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.bash @@ -7,14 +7,8 @@ function prompt_setter() { history -a history -c history -r - if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]] - then - clock="\t" - else - clock=$THEME_PROMPT_CLOCK_FORMAT - fi 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 $(doubletime_scm_prompt)$reset_color $ " PS2='> ' diff --git a/themes/emperor/emperor.theme.bash b/themes/emperor/emperor.theme.bash index 2f365f31..e3f2df8c 100644 --- a/themes/emperor/emperor.theme.bash +++ b/themes/emperor/emperor.theme.bash @@ -1,4 +1,5 @@ #!/usr/bin/env bash + SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" @@ -27,8 +28,15 @@ function get_hour_color { echo "$hour_color" } -function prompt_command() { - 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} " +__emperor_clock() { + 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 diff --git a/themes/luan/luan.theme.bash b/themes/luan/luan.theme.bash index cb122e50..8b7059e1 100644 --- a/themes/luan/luan.theme.bash +++ b/themes/luan/luan.theme.bash @@ -1,4 +1,5 @@ #!/usr/bin/env bash + SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX="(${yellow}" @@ -13,7 +14,7 @@ RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" function prompt_command() { - dtime="${yellow}\T${normal}" + dtime="$(clock_prompt)" user_host="${green}\u@${cyan}\h${normal}" current_dir="${bold_blue}\w${normal}" rvm_ruby="${bold_red}$(ruby_version_prompt)${normal}" @@ -22,8 +23,11 @@ function prompt_command() { arrow="${bold_white}▶${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" } +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$yellow"} +THEME_CLOCK_FORMAT=${THEME_TIME_FORMAT:-"%I:%M:%S "} + safe_append_prompt_command prompt_command diff --git a/themes/nwinkler/nwinkler.theme.bash b/themes/nwinkler/nwinkler.theme.bash index d1d3f503..f9fe4933 100644 --- a/themes/nwinkler/nwinkler.theme.bash +++ b/themes/nwinkler/nwinkler.theme.bash @@ -1,12 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash # 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: -# (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: # * Green: 0 exit status @@ -32,7 +32,7 @@ prompt_setter() { history -a history -c 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='> ' PS4='+ ' } diff --git a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash index 20da931f..f6eff908 100644 --- a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash +++ b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash @@ -55,6 +55,7 @@ function randomize_nwinkler { USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} HOSTNAME_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[@]} ]} echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE @@ -67,6 +68,7 @@ then USERNAME_COLOR=${COLORS[0]} HOSTNAME_COLOR=${COLORS[1]} TIME_COLOR=${COLORS[2]} + THEME_CLOCK_COLOR=$TIME_COLOR PATH_COLOR=${COLORS[3]} else # No colors stored yet. Generate them! @@ -97,7 +99,7 @@ prompt_setter() { history -a history -c 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='> ' PS4='+ ' } diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index b573cb81..73fdb053 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -5,7 +5,7 @@ prompt_setter() { history -a history -c 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='> ' PS4='+ ' } diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index 8f353ac6..d8d1aa34 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -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: - 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. diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 604c022f..93ac2f00 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -40,7 +40,7 @@ BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 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_TEXT="vim" @@ -136,7 +136,7 @@ function __powerline_cwd_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 { diff --git a/themes/primer/primer.theme.bash b/themes/primer/primer.theme.bash index cc5ba536..c9cdb35d 100644 --- a/themes/primer/primer.theme.bash +++ b/themes/primer/primer.theme.bash @@ -2,7 +2,10 @@ # based of the candy theme, but minimized by odbol 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 \ No newline at end of file +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"} +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"} + +safe_append_prompt_command prompt_command diff --git a/themes/roderik/roderik.theme.bash b/themes/roderik/roderik.theme.bash index 2f32e4d1..8a1c1045 100644 --- a/themes/roderik/roderik.theme.bash +++ b/themes/roderik/roderik.theme.bash @@ -8,9 +8,9 @@ export PROMPT_DIRTRIM=3 function prompt_command() { 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 - 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 } diff --git a/themes/tonka/tonka.theme.bash b/themes/tonka/tonka.theme.bash index 53fbd64c..e97a5712 100644 --- a/themes/tonka/tonka.theme.bash +++ b/themes/tonka/tonka.theme.bash @@ -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() { # Named "Tonka" because of the colour scheme @@ -23,8 +42,8 @@ $YELLOW\$PWD\ $LIGHT_BLUE)-$YELLOW-\ \n\ $YELLOW-$LIGHT_BLUE-(\ -$YELLOW\$(date +%H%M)$LIGHT_BLUE:$YELLOW\$(date \"+%a,%d %b %y\")\ -$LIGHT_BLUE:$WHITE\\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR " +$(__tonka_clock)\ +$WHITE\$ $LIGHT_BLUE)-$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 +THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"\[\033[1;33m\]"} + 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:'; diff --git a/themes/wanelo/wanelo.theme.bash b/themes/wanelo/wanelo.theme.bash index e3cb7617..437fd327 100644 --- a/themes/wanelo/wanelo.theme.bash +++ b/themes/wanelo/wanelo.theme.bash @@ -18,7 +18,9 @@ function prompt_command() { else status=💔 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;