Skip to main content

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.

Metadata

Release files for xontrib-cmd-durations 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xontrib-cmd-durations 0.3.2
File Size Uploaded
xontrib-cmd-durations-0.3.2.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-cmd-durations 0.3.2
File Interpreter ABI Platform
xontrib_cmd_durations-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / xontrib-cmd-durations-0.3.2.tar.gz

Download URL xontrib-cmd-durations-0.3.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7e5ed13d80c964b1a84694c72234ac9dd3553cb5f45ab4960fba5323374a7abf
BLAKE2b-256 checksum
How to use checksums
6f038dd10c0331755a6160583b2dd3539b1321a16f57c09b0011f764432a6e05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / xontrib_cmd_durations-0.3.2-py3-none-any.whl

Download URL xontrib_cmd_durations-0.3.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9e1b16c3e3b00ff9fd4fefa1699941fb33a4e90241c8b7632f4eda54068d66f
BLAKE2b-256 checksum
How to use checksums
a144ef6c92aff7fee0ce7a70145fd7d2ea315c7d0feeb12c0e37bac3fdd6cb22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page