You could do this:
$ bind '"\C-j": "\C-atime \C-m"'
Or put this in your ~/.inputrc
:
"\C-j": "\C-atime \C-m"
Then when you want to do time sleep 1
you'd type sleep 1
and press Ctrl+J instead of Enter.
I would not recommend swapping the j
and m
in the bind command (or in the .inputrc file). Every time you'd press Enter you'd get time
added which could be pretty annoying and would cause errors when typing a multi-line command.
You could add this to your ~/.bashrc
to make the output of time
more compact:
export TIMEFORMAT='r: %R, u: %U, s: %S'
(similar to my answer here.)