Skip to content

Instantly share code, notes, and snippets.

@oprypin
Last active March 17, 2022 22:14
Show Gist options
  • Save oprypin/1d39d8d82ffa2f1295495931df853b01 to your computer and use it in GitHub Desktop.
Save oprypin/1d39d8d82ffa2f1295495931df853b01 to your computer and use it in GitHub Desktop.
Display execution time of last command
last_duration = 0
_orig = __xonsh_history__.append
def _append(cmd):
nonlocal last_duration
last_duration = cmd['ts'][1] - cmd['ts'][0]
_orig(cmd)
__xonsh_history__.append = _append
def _last_duration():
if last_duration >= 1:
return '{:.1f} '.format(last_duration)
$FORMATTER_DICT['last_duration'] = _last_duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment