Skip to main content

Send notification once long running command is finished. Add duration PROMP_FIELD.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib-cmd-durations-0.3.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

xontrib_cmd_durations-0.3.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-cmd-durations-0.3.2.tar.gz.

File metadata

  • Download URL: xontrib-cmd-durations-0.3.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for xontrib-cmd-durations-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7e5ed13d80c964b1a84694c72234ac9dd3553cb5f45ab4960fba5323374a7abf
MD5 5e905f0f736131670fd3002b2bad5ffd
BLAKE2b-256 6f038dd10c0331755a6160583b2dd3539b1321a16f57c09b0011f764432a6e05

See more details on using hashes here.

File details

Details for the file xontrib_cmd_durations-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_cmd_durations-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e1b16c3e3b00ff9fd4fefa1699941fb33a4e90241c8b7632f4eda54068d66f
MD5 520525630e6a61bf628af6e1f5c55cdf
BLAKE2b-256 a144ef6c92aff7fee0ce7a70145fd7d2ea315c7d0feeb12c0e37bac3fdd6cb22

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page