4 ms·
For p10k users, adding extra info to your prompt is really easy. Here's my epoch-seconds display: function prompt_epoch() { MYEPOCH=$(/bin/date +%s |
by bloopernova 5y ago
For p10k users, adding extra info to your prompt is really easy. Here's my epoch-seconds display:
function prompt_epoch() {
MYEPOCH=$(/bin/date +%s | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')
p10k segment -f 66 -t ${MYEPOCH}
}
It looks like this in action:
https://i.imgur.com/0IT5zXi.png https://i.imgur.com/0IT5zXi.png
- tomtom1337 5y agoYour imgur link isn't working for me. I'm getting an "oops we can't find the image".
- bloopernova 5y agoDoes this work? https://imgur.com/0IT5zXi https://imgur.com/0IT5zXi
- JNRowe 5y agoIn the spirit of p10k speed, you can perform that task without forks: $ zmodload -F zsh/datetime p:EPOCHSECONDS $ printf "%'d" $EPOCHSECONDS 1,648,943,504
- bloopernova 5y agoNice, thank you!
- bloopernova 5y agoDo you know how to do that printf within a zsh variable? i.e. here: function prompt_epoch() { p10k segment -f 66 -t ${MYEPOCH} <-- replace MYEPOCH with EPOCHSECONDS but with commas? } EDIT: printf can assign output to a variable using -v. Therefore my function can be rewritten as: function prompt_epoch() { printf -v COMMA_EPOCH "%'d" ${EPOCHSECONDS} p10k segment -f 66 -t ${COMMA_EPOCH} }