xontrib-cmd-durations


Namexontrib-cmd-durations JSON
Version 0.3.2 PyPI version JSON
download
home_pageNone
SummarySend notification once long running command is finished. Add duration PROMP_FIELD.
upload_time2024-05-17 16:03:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords xontrib xonsh
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Overview

<p align="center">
Send notification once long-running command is finished and also show the execution time.
</p>

## 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_done

sleep 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).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "xontrib-cmd-durations",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "xontrib, xonsh",
    "author": null,
    "author_email": "Noortheen Raja J <jnoortheen@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6f/03/8dd10c0331755a6160583b2dd3539b1321a16f57c09b0011f764432a6e05/xontrib-cmd-durations-0.3.2.tar.gz",
    "platform": null,
    "description": "## Overview\n\n<p align=\"center\">\nSend notification once long-running command is finished and also show the execution time.\n</p>\n\n## Installation\n\nTo install use pip:\n\n``` bash\nxpip install xontrib-cmd-durations\n# or: xpip install -U git+https://github.com/jnoortheen/xontrib-cmd-durations\n```\n\n## Usage\n\nAdd the `long_cmd_duration` section to the [prompt fields](https://xon.sh/tutorial.html#customizing-the-prompt) and load the xontrib i.e.:\n\n``` bash\n$RIGHT_PROMPT = '{long_cmd_duration:\u231b{}}{user:{{BOLD_RED}}\ud83e\udd16{}}{hostname:{{BOLD_#FA8072}}\ud83d\udda5{}}'\n$XONTRIB_CD_LONG_DURATION = 5  # default\nxontrib load cmd_done\n```\n\nIf the command is taking more than `$XONTRIB_CD_LONG_DURATION` seconds then `long_cmd_duration` returns the duration in human readable way:\n\n![](./images/2020-10-26-10-59-38.png)\n\nThe desktop notification is sent if the terminal is not focused:\n\n![](./images/2020-11-02-13-38-47.png)\n\nCurrently the focusing part requires `xdotool` to be installed.\n\n## Known issues\n\n### Notifications in Windows\nOn windows the notification will get triggered all the time. \n`Finding whether the terminal is focused` is not implemented for Windows yet and PRs are very welcome on that.\nSet `$XONTRIB_CD_TRIGGER_NOTIFICATION = False` to completely off the notification part.\n\n### Notifications in MacOS\n\nIf 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):\n```xsh\n$XONTRIB_CD_NOTIFICATION_APP_NAME = '{user}@{hostname}:{cwd}'\n$RIGHT_PROMPT = '{long_cmd_duration}'\nxontrib load cmd_done\n\nsleep 6\n# Switch to another window\n```\nResult:\n\n![](./images/notification-mac.png)\n\n\n## Credits\n\nThis package was created with [xontrib cookiecutter template](https://github.com/jnoortheen/xontrib-cookiecutter).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Send notification once long running command is finished. Add duration PROMP_FIELD.",
    "version": "0.3.2",
    "project_urls": {
        "Code": "https://github.com/jnoortheen/xontrib-cmd-durations",
        "Documentation": "https://github.com/jnoortheen/xontrib-cmd-durations/blob/master/README.md",
        "Issue tracker": "https://github.com/jnoortheen/xontrib-cmd-durations/issues",
        "repository": "https://github.com/jnoortheen/xontrib-cmd-durations"
    },
    "split_keywords": [
        "xontrib",
        " xonsh"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a144ef6c92aff7fee0ce7a70145fd7d2ea315c7d0feeb12c0e37bac3fdd6cb22",
                "md5": "520525630e6a61bf628af6e1f5c55cdf",
                "sha256": "a9e1b16c3e3b00ff9fd4fefa1699941fb33a4e90241c8b7632f4eda54068d66f"
            },
            "downloads": -1,
            "filename": "xontrib_cmd_durations-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "520525630e6a61bf628af6e1f5c55cdf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4874,
            "upload_time": "2024-05-17T16:03:55",
            "upload_time_iso_8601": "2024-05-17T16:03:55.602431Z",
            "url": "https://files.pythonhosted.org/packages/a1/44/ef6c92aff7fee0ce7a70145fd7d2ea315c7d0feeb12c0e37bac3fdd6cb22/xontrib_cmd_durations-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f038dd10c0331755a6160583b2dd3539b1321a16f57c09b0011f764432a6e05",
                "md5": "5e905f0f736131670fd3002b2bad5ffd",
                "sha256": "7e5ed13d80c964b1a84694c72234ac9dd3553cb5f45ab4960fba5323374a7abf"
            },
            "downloads": -1,
            "filename": "xontrib-cmd-durations-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5e905f0f736131670fd3002b2bad5ffd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4230,
            "upload_time": "2024-05-17T16:03:57",
            "upload_time_iso_8601": "2024-05-17T16:03:57.300765Z",
            "url": "https://files.pythonhosted.org/packages/6f/03/8dd10c0331755a6160583b2dd3539b1321a16f57c09b0011f764432a6e05/xontrib-cmd-durations-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-17 16:03:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jnoortheen",
    "github_project": "xontrib-cmd-durations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "xontrib-cmd-durations"
}
        
Elapsed time: 9.53779s