xontrib-cmd-durations


Namexontrib-cmd-durations JSON
Version 0.3.1 PyPI version JSON
download
home_pageNone
SummarySend notification once long running command is finished. Add duration PROMP_FIELD.
upload_time2024-04-06 14:23:28
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/05/68/39a0b3f269a414cba6eb7f44847c815e4917afb9a9c9305a703317d91b96/xontrib-cmd-durations-0.3.1.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.1",
    "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": "af6a90445b15cab7ff9d337246a964cfd91b0047b4388daab1bc293897d81d27",
                "md5": "b3d5bc79a05d05cba108a6b06b7a4e51",
                "sha256": "4db8aec26a76229bb6bf077ca463cdc8b2ca4ae7cc64700a0a2fdbf3a640d428"
            },
            "downloads": -1,
            "filename": "xontrib_cmd_durations-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b3d5bc79a05d05cba108a6b06b7a4e51",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4850,
            "upload_time": "2024-04-06T14:23:25",
            "upload_time_iso_8601": "2024-04-06T14:23:25.974533Z",
            "url": "https://files.pythonhosted.org/packages/af/6a/90445b15cab7ff9d337246a964cfd91b0047b4388daab1bc293897d81d27/xontrib_cmd_durations-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "056839a0b3f269a414cba6eb7f44847c815e4917afb9a9c9305a703317d91b96",
                "md5": "2d82fd21710ef500c95eb945c2439281",
                "sha256": "7a1cc0413aa7fb4108bb32556a66fd1df0a15cce4e69f0a9613ed4add4ba34be"
            },
            "downloads": -1,
            "filename": "xontrib-cmd-durations-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2d82fd21710ef500c95eb945c2439281",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4204,
            "upload_time": "2024-04-06T14:23:28",
            "upload_time_iso_8601": "2024-04-06T14:23:28.363383Z",
            "url": "https://files.pythonhosted.org/packages/05/68/39a0b3f269a414cba6eb7f44847c815e4917afb9a9c9305a703317d91b96/xontrib-cmd-durations-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-06 14:23:28",
    "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: 0.28141s