radian icon indicating copy to clipboard operation
radian copied to clipboard

Add Timestamp to Radian Prompt

Open mcooper opened this issue 4 years ago • 5 comments

Hi there, I'm trying to figure out of it is possible to add a timestamp to the prompt. I tried adding one via my .Rprofile, but that broke a lot of great radian functionality, so now I'm looking at configuring options(radian.prompt) in radian_profile.

It looks like the default string specifies bash colors, so I'm guessing the syntax for customizing the radian prompt is similar to a bash prompt. According to this site, it looks like inserting \D{%H:%m:%s} or %T should add a timestamp to a bash-style prompt. However, adding that to the profile string like: "\033[0;34mr$%T>\033[0m " just gives me a prompt that looks like [ins] r$%T>.

Is there a specific type of prompt syntax that radian uses? Are there different escape characters I should look into?

Thanks for the help, and the great console.

mcooper avatar Nov 09 '20 17:11 mcooper

You could set options(radian.prompt = paste(Sys.time(), "\033[0;34mr$>\033[0m ", sep = " ")) in radian_profile.

meriops avatar Jan 04 '21 13:01 meriops

Thank you!

mcooper avatar Jan 04 '21 14:01 mcooper

So, the approach recommended by @meriops does not seem to update the time, the prompt is just frozen with the time at which the R session was started.

mcooper avatar Jan 13 '21 15:01 mcooper

Ha yes, this is static of course... Stupid me. Sorry about that...

meriops avatar Jan 13 '21 16:01 meriops

basically, we will need to set refresh_interval of prompt-toolkit to a non zero value and have a mechanism to render arbitrary information in the prompt.

randy3k avatar Jan 13 '21 17:01 randy3k