0

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
2
  • 1
    Maybe this will be of use to you: unix.stackexchange.com/questions/12059/…
    – Rain
    Mar 30, 2013 at 2:17
  • 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
    Mar 30, 2013 at 2:18

2 Answers 2

2

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

alias cp='time cp'

1
  • 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. Apr 3, 2013 at 22:50
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.

1
  • Thanks for the reply. However, here I am referring "time" as a unix command time for benchmarking
    – Alby
    Mar 30, 2013 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .