Skip to content

Show long running commands durations in prompt with option to send notification when terminal is not focused.

License

Notifications You must be signed in to change notification settings

jnoortheen/xontrib-cmd-durations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Send notification once long-running command is finished and also show the execution time.

Installation

To install use pip:

xpip install xontrib-cmd-durations
# or: xpip install -U git+https://github.com/jnoortheen/xontrib-cmd-durations

Usage

Add the long_cmd_duration section to the prompt fields and load the xontrib i.e.:

$RIGHT_PROMPT = '{long_cmd_duration:⌛{}}{user:{{BOLD_RED}}🤖{}}{hostname:{{BOLD_#FA8072}}🖥{}}'
$XONTRIB_CD_LONG_DURATION = 5  # default
xontrib load cmd_done

If the command is taking more than $XONTRIB_CD_LONG_DURATION seconds then long_cmd_duration returns the duration in human readable way:

The desktop notification is sent if the terminal is not focused:

Currently the focusing part requires xdotool to be installed.

Known issues

Notifications in Windows

On windows the notification will get triggered all the time. Finding whether the terminal is focused is not implemented for Windows yet and PRs are very welcome on that. Set $XONTRIB_CD_TRIGGER_NOTIFICATION = False to completely off the notification part.

Notifications in MacOS

If you want to change the app name in notification in MacOS you can use $XONTRIB_CD_NOTIFICATION_APP_NAME environment variable with automatically replaced keywords:

$XONTRIB_CD_NOTIFICATION_APP_NAME = '{user}@{hostname}:{cwd}'
$RIGHT_PROMPT = '{long_cmd_duration}'
xontrib load cmd_done

sleep 6
# Switch to another window

Result:

Credits

This package was created with xontrib cookiecutter template.

About

Show long running commands durations in prompt with option to send notification when terminal is not focused.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages