Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: print runtime of command in human readable format in prompt #2272

Open
sinexton opened this issue Jan 21, 2023 · 0 comments
Open

Comments

@sinexton
Copy link

It would be nice to see the total runtime of the last command in human readable format in the prompt if it took more then a couple of seconds to run.

If someone runs time heavy tasks then it may improve efficiency and it can be automatic and stay hidden if no heavy tasks have been run. An implementation for converting seconds to human format:

def time_human( sec )
	res = nil
	mul = 1.0
	[ [60,"s"], [60,"m"], [24,"h"], [30.4375,"d"], [12,"mo"], [-1,"y"] ].each{|time,text|
		mul *= time
		if sec < mul or time < 0
			res = "#{ round( sec.to_f * time / mul ) }#{ text }"
			break
		end
	}
	return res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant