How can I set my Pry prompt to be the current time

2019-08-11 09:48发布

问题:

When I put the following line into ~/.pryrc it doesn't work as expected:

Pry.config.prompt_name = Time.now.to_s

Every prompt is equal to the time that Pry was launched.

How do I update the prompt with the current timestamp, each time the prompt is displayed (after each call)?

回答1:

You need to use prompt not prompt_name

Pry.config.prompt = Proc.new { |output, value| Time.now.to_s[0..-6] }