From 4253185fe0747949f29d002bfd152ea6ad30440d Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 29 Nov 2013 01:31:31 +0900 Subject: [PATCH] shrc: add RPROMPT for zsh --- shrc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/shrc b/shrc index 92f50e8..e3c82d0 100755 --- a/shrc +++ b/shrc @@ -1195,20 +1195,32 @@ __my_ps1_info(){ echo "${__my_ps1_sh}$(__my_ps1_scale)$(__my_ps1_git)$(__my_ps1_bttry)$(__my_ps1_ipaddr)$(__my_ps1_moc)" } -_ps1_bash="\ +__my_ps1_save_pos="\[\033[s\]" +__my_ps1_restore_pos="\[\033[u\]" +__my_ps1_move_rightmost="\[\033[\$(tput cols)C\]" +__my_ps1_move_15left="\[\033[15D\]" +# collapse when command line is too long and try to write over this string +# __my_ps1_right="${__my_ps1_save_pos}${__my_ps1_move_rightmost}\ +# ${__my_ps1_move_15left}\D{%Y/%m/%d %H:%M}${__my_ps1_restore_pos}" + +$inbash && PS1="\ ${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_info)\n\ -${__my_c4}:: ${__my_cdef}\D{%Y/%m/%d %H:%M} \$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)\$ " -$inbash && PS1="$_ps1_bash" +${__my_c4}:: ${__my_cdef}\D{%Y/%m/%d %H:%M} \$(__my_ps1_jobs \j)${__my_ps1_str}\$(__my_alert_fail)${__my_ps1_right}\$ " -_ps1_zsh="\ +if $inzsh +then + PROMPT="\ ${__my_c4}:: ${__my_cdef}[${__my_c2}%n@%M${__my_cdef}:${__my_c1}%~/${__my_cdef}]\$(__my_ps1_info) -${__my_c4}:: ${__my_cdef}%D{%Y/%m/%d %H:%M} \$(__my_ps1_jobs)${__my_ps1_str}\$(__my_alert_fail)%# " -$inzsh && PROMPT="$_ps1_zsh" +${__my_c4}:: ${__my_cdef} \$(__my_ps1_jobs)${__my_ps1_str}\$(__my_alert_fail)%# " + RPROMPT="%D{%Y/%m/%d %H:%M}" +fi __my_set_header_line(){ # save current position printf "\033[s" + # move to 0,0 printf "\033[0;0H" + # clear curent to eol printf "\033[K" printf "\033[7m" printf "$1"