Wondering if there is a way to run time command in Linux by default when certain commands are run.
Asked
Active
Viewed 74 times
2
1 Answers
3
You may alias the commands that you want to time:
alias ls='time command ls'
alias firefox='time command firefox'
or, with shell functions:
ls () { time command ls "$@"; }
firefox () { time command firefox "$@"; }
The command
command is not strictly needed in the aliases, but required in the shell function, or otherwise you get a nice infinite recursion that probably ends with a core-dump of the shell. The command
command will bypass any shell function lookup for the command you're executing.

Kusalananda
- 333,661
alias
suffice? e.g.alias ls='time ls'
(note: may not be a good idea depending on the command and how it is used) – thrig Feb 13 '17 at 17:02