A bash “plugin”: timelast

Did you ever run a process in a terminal that took longer than you expected to finish, and like such, you wanted to know how long it took? Since you didn’t know it would be a long one, you thought running it with time was unnecessary, or maybe you just forgot it… Now what?

Wouldn’t it be awesome if you could find out how long that process took to run? How about if it were as simple as typing timelast or another command that makes sense to you? Well, awesomeness now exists. 😎

I’ve poked around and have put together a script that, once sourced from your .bashrc, will give you this exact functionality I just talked about. Take a look at a quick example:

[eduardo@dudubuntu:~]$ sleep 3s
[eduardo@dudubuntu:~]$ timelast
3s
[eduardo@dudubuntu:~]$ sleep 90s
[eduardo@dudubuntu:~]$ timelast
1m30s
[eduardo@dudubuntu:~]$ sleep 3666s
[eduardo@dudubuntu:~]$ timelast
1h1m6s

Cool, uh? The source code is available here (sorry about the pastebin, I can’t upload it to the blog). I’d say it is fairly well commented, but feel free to contact me if you’re wondering what is going on under the hood.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: