https://github.com/jnoortheen/xontrib-cmd-durations
Show long running commands durations in prompt with option to send notification when terminal is not focused.
https://github.com/jnoortheen/xontrib-cmd-durations
bgnotify done xonsh xontrib
Last synced: 3 months ago
JSON representation
Show long running commands durations in prompt with option to send notification when terminal is not focused.
- Host: GitHub
- URL: https://github.com/jnoortheen/xontrib-cmd-durations
- Owner: jnoortheen
- License: mit
- Created: 2020-10-25T06:54:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-17T16:03:03.000Z (about 1 year ago)
- Last Synced: 2025-03-12T05:46:14.887Z (3 months ago)
- Topics: bgnotify, done, xonsh, xontrib
- Language: Python
- Homepage:
- Size: 794 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Overview
Send notification once long-running command is finished and also show the execution time.## Installation
To install use pip:
``` bash
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](https://xon.sh/tutorial.html#customizing-the-prompt) and load the xontrib i.e.:
``` bash
$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](https://xon.sh/tutorial.html#customizing-the-prompt):
```xsh
$XONTRIB_CD_NOTIFICATION_APP_NAME = '{user}@{hostname}:{cwd}'
$RIGHT_PROMPT = '{long_cmd_duration}'
xontrib load cmd_donesleep 6
# Switch to another window
```
Result:
## Credits
This package was created with [xontrib cookiecutter template](https://github.com/jnoortheen/xontrib-cookiecutter).