How can the last command's wall time be put in the Bash prompt?

后端 未结 14 2821
無奈伤痛
無奈伤痛 2020-12-04 05:16

Is there a way to embed the last command\'s elapsed wall time in a Bash prompt? I\'m hoping for something that would look like this:

[last: 0s][/my/dir]$ sl         


        
14条回答
  •  不思量自难忘°
    2020-12-04 06:16

    If you hadn't set up any of the other answers before you kicked off your long-running job and you just want to know how long the job took, you can do the simple

    $ HISTTIMEFORMAT="%s " history 2
    

    and it will reply with something like

      654  1278611022 gvn up
      655  1278611714 HISTTIMEFORMAT="%s " history 2
    

    and you can then just visually subtract the two timestamps (anybody know how to capture the output of the shell builtin history command?)

提交回复
热议问题