can you make your terminal so that it times all the commands except common ones?

0

1

Is it possible to configure your shell(bash) so that it times all the commands except the common ones(like ls or cd)?

so when I type some command like

command arg1 arg2

I would want my terminal to convert it into behind the scene

time command arg1 arg2

Alby

Posted 2013-03-30T02:07:58.117

Reputation: 317

1

Maybe this will be of use to you: http://unix.stackexchange.com/questions/12059/forcing-an-added-alias-to-every-command

– Rain – 2013-03-30T02:17:10.873

Define common. I use ls,cd,rm,mv,pwd,echo,mkdir,rmdir,cp,more,less,ps,diff etc etc every day. It would probably be better to configure your shell to time the few specific commands you actually want to time or all commands as described in the link that @Rain posted. – terdon – 2013-03-30T02:18:28.020

Answers

2

I believe an alias is the answer. create as many aliases as you want.

alias cp='time cp'

cybernard

Posted 2013-03-30T02:07:58.117

Reputation: 11 200

I haven't done this outside of scripting, so I don't know if alias is smart enough, but but it might be a good idea to use time \cp instead of time cp so it forces it to use the system cp command instead of the alias. – Ben Richards – 2013-04-03T22:50:08.960

0

You just need to execute the following command to add the time stamp to the history:

export HISTTIMEFORMAT='%F %T '

Then if you logout and log back in whenever you invoke the history command you will see a time stamp for the commands you executed. Unfortunately it doesn't seem like it appends a time stamp to the .bash_history file in a user's local home profile. It would also appears it doesn't have a way of distinguishing common vs. uncommon executed commands.

Dion Pezzimenti

Posted 2013-03-30T02:07:58.117

Reputation: 514

Thanks for the reply. However, here I am referring "time" as a unix command time for benchmarking – Alby – 2013-03-30T13:15:37.503