mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
fix fortune for really long prompts
This commit is contained in:
parent
c923906df9
commit
d004017350
1 changed files with 6 additions and 2 deletions
|
|
@ -42,15 +42,19 @@ rkj_retcode() {
|
|||
return $?
|
||||
}
|
||||
|
||||
type rkj_debug >/dev/null || rkj_debug() { }
|
||||
|
||||
short_fortune() {
|
||||
rkj_debug fortune start
|
||||
local prompt_variable_part=$'%n%m%~%D{"$PROMPT_DATE_FORMAT"}'
|
||||
if hash fortune 2>/dev/null; then
|
||||
local left=$(( $COLUMNS - ${#${(%)prompt_variable_part}} - 15))
|
||||
#echo -ne $left
|
||||
fortune -s -n $left | tr -s "\n\t " " "
|
||||
rkj_debug Left $left, $COLUMNS available
|
||||
[[ $left -gt 30 ]] && fortune -s -n $left | tr -s "\n\t " " "
|
||||
else
|
||||
echo "no fortunes for you"
|
||||
fi
|
||||
rkj_debug fortune finished
|
||||
}
|
||||
PROMPT_DATE_FORMAT=$'%Y-%m-%d %I:%M:%S'
|
||||
LINE1=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"${PROMPT_DATE_FORMAT}"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue