Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-17T16:03:03.000Z (7 months ago)
- Last Synced: 2024-10-11T23:48:52.166Z (2 months ago)
- Topics: bgnotify, done, xonsh, xontrib
- Language: Python
- Homepage:
- Size: 794 KB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xontribs - cmd_done - send notification once long-running command is finished. Adds `long_cmd_duration` field to $PROMPT_FIELDS. (Plugins / Prompt tweaks)
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:
![](./images/2020-10-26-10-59-38.png)
The desktop notification is sent if the terminal is not focused:
![](./images/2020-11-02-13-38-47.png)
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:![](./images/notification-mac.png)
## Credits
This package was created with [xontrib cookiecutter template](https://github.com/jnoortheen/xontrib-cookiecutter).