Add support for displaying time in 12-hour format

- Introduces a flag, `$BULLETTRAIN_TIME_12HR`, indicating if 12-hour format should be used
- Default to 24 hour time
- Document new option in README
This commit is contained in:
Mario Zigliotto
2015-08-23 14:56:48 -07:00
committed by Caio Gondim
parent fe2d8d81fb
commit c93bb14ffb
2 changed files with 6 additions and 1 deletions

View File

@@ -121,6 +121,7 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
|Variable|Default|Meaning |Variable|Default|Meaning
|--------|-------|-------| |--------|-------|-------|
|`BULLETTRAIN_TIME_SHOW`|`true`|Show/hide that segment |`BULLETTRAIN_TIME_SHOW`|`true`|Show/hide that segment
|`BULLETTRAIN_TIME_12HR`|`false`|Format time using 12-hour clock (am/pm)
|`BULLETTRAIN_TIME_BG`|`''`|Background color |`BULLETTRAIN_TIME_BG`|`''`|Background color
|`BULLETTRAIN_TIME_FG`|`''`|Foreground color |`BULLETTRAIN_TIME_FG`|`''`|Foreground color

View File

@@ -369,7 +369,11 @@ prompt_time() {
return return
fi fi
prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG '%D{%H:%M:%S}' if [[ $BULLETTRAIN_TIME_12HR == true ]] then
prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG %D{%r}
else
prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG %D{%R}
fi
} }
# Status: # Status: