{"id":13587827,"url":"https://github.com/popstas/zsh-command-time","last_synced_at":"2025-08-16T16:32:04.751Z","repository":{"id":39649353,"uuid":"83981724","full_name":"popstas/zsh-command-time","owner":"popstas","description":"Show execution time for long commands in zsh","archived":false,"fork":false,"pushed_at":"2020-11-15T13:58:05.000Z","size":25,"stargazers_count":191,"open_issues_count":1,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-06T07:39:58.018Z","etag":null,"topics":["oh-my-zsh","powerlevel9k","zsh","zsh-command-time"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/popstas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-05T15:44:29.000Z","updated_at":"2024-10-14T18:43:10.000Z","dependencies_parsed_at":"2022-09-20T06:51:24.238Z","dependency_job_id":null,"html_url":"https://github.com/popstas/zsh-command-time","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popstas%2Fzsh-command-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popstas%2Fzsh-command-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popstas%2Fzsh-command-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popstas%2Fzsh-command-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/popstas","download_url":"https://codeload.github.com/popstas/zsh-command-time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230044603,"owners_count":18164182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oh-my-zsh","powerlevel9k","zsh","zsh-command-time"],"created_at":"2024-08-01T15:06:22.774Z","updated_at":"2025-08-16T16:32:04.703Z","avatar_url":"https://github.com/popstas.png","language":"Shell","funding_links":[],"categories":["Plugins","Shell"],"sub_categories":["ZSH on Windows","Zinit (née zplugin)"],"readme":"# zsh-command-time\n\nPlugin that output `time: xx` after long commands and export `ZSH_COMMAND_TIME` variable for usage in your scripts.\n\nExample output with `typeset -F SECONDS`:\n\n![screenshot](screen1.png)\n\nIt similar builin feature [REPORTTIME](http://zsh.sourceforge.net/Doc/Release/Parameters.html), but it outputs only\nif user + system time \u003e= `REPORTTIME` in config. For example:\n```bash\n$ time sleep 3\nsleep 3  0,00s user 0,00s system 0% cpu 3,008 total\n```\nSleep don't consume any cpu time and `REPORTTIME` \"don't see\" such idle commands.\n\nIf you need to monitor only cpu-angry commands, use `REPORTTIME` instead this plugin.\n\n\n## Install with antigen\n```bash\nantigen bundle popstas/zsh-command-time\n```\n\n## Install with zplug\n```bash\nzplug \"popstas/zsh-command-time\"\n```\n\n\n## Install for oh-my-zsh\n\nDownload:\n```bash\ngit clone https://github.com/popstas/zsh-command-time.git ~/.oh-my-zsh/custom/plugins/command-time\n```\nAnd add `command-time` to `plugins` in `.zshrc`.\n\n\n## Configuration\n\nYou can override defaults in `.zshrc`:\n```bash\n# Use floating point numbers for time.\ntypeset -F SECONDS\n\n# If command execution time above min. time, plugins will output time.\nZSH_COMMAND_TIME_MIN_SECONDS=3\n\n# Message to display (set to \"%s\" for disable).\nZSH_COMMAND_TIME_MSG=\"Execution time: %s sec\"\n\n# Message color.\nZSH_COMMAND_TIME_COLOR=\"cyan\"\n\n# Don’t colorize the output based on the duration. Default colors: green \u003c 1 min, yellow \u003c 3 min, red \u003e= 3 min.\nZSH_COMMAND_TIME_NO_COLOR=\"1\"\n\n# Exclude some commands\nZSH_COMMAND_TIME_EXCLUDE=(vim mcedit)\n```\n\n### Customization\nYou can customize view of the plugin by redefinition of function\n`zsh_command_time`. There is an example of custom definition `zsh_command_time`:\n```bash\nzsh_command_time() {\n    local hours min sec timer_show\n    if [ -n \"$ZSH_COMMAND_TIME\" ]; then\n        # hours and minutes are calculated from the total seconds as integers\n        typeset -i hours=$(( ZSH_COMMAND_TIME / 3600))\n        typeset -i min=$(( ZSH_COMMAND_TIME / 60 % 60))\n        if [[ \"$ZSH_COMMAND_TIME\" == *.* ]]; then\n            # If SECONDS is a float, we limit the precision to 3 decimal places\n            typeset -F 3 sec\n        fi\n        # secunds are calculated as float or integer automatically\n        sec=$(( ZSH_COMMAND_TIME % 60 ))\n        if [[ \"$min\" == 0 ]]; then\n            timer_show=\"$fg[green]$sec s.\"\n        elif [[ 1 -le \"$min\" \u0026\u0026 \"$min\" -le 3 ]]; then\n            timer_show=\"$fg[yellow]$min min. $sec s.\"\n        else\n            if [[ \"$hours\" != 0 ]]; then\n                timer_show=\"$fg[red]$hours h. $min min. $sec s.\"\n            else\n                timer_show=\"$fg[red]$min min. $sec s.\"\n            fi\n        fi\n        printf \"${ZSH_COMMAND_TIME_MSG}\\n\" \"$timer_show\"\n    fi\n}\n```\n\nYou can see result of this function on the following screenshot:\n\n![screenshot](screen2.jpg)\n\nVariable `$ZSH_COMMAND_TIME` contains execution time in seconds. We calculate\nhow many minutes and hours it was and print this information to terminal.\n* Commands that were executed less than one minutes highlights by green color.\n* Commands that were executed less than three minutes highlights by yellow color.\n* Commands that were executed more than three minutes highlights by red color.\n\n## Usage with [powerlevel9k](https://github.com/bhilburn/powerlevel9k) theme\nYou should not want to use this plugin with powerlevel9k.\nSinse powerlevel9k v0.6.0 theme have native segment \n[command_execution_time](https://github.com/bhilburn/powerlevel9k#command_execution_time)\n(see [PR](https://github.com/bhilburn/powerlevel9k/pull/402)), so you can just add it to your prompt:\n```bash\nPOWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs vcs command_execution_time time)\n```\n\nIf you still want to use it with powerlevel9k, add custom element in `.zshrc`:\n```bash\nPOWERLEVEL9K_CUSTOM_COMMAND_TIME=\"zsh_command_time\"\nPOWERLEVEL9K_CUSTOM_COMMAND_TIME_BACKGROUND=\"253\" # white\nPOWERLEVEL9K_CUSTOM_COMMAND_TIME_FOREGROUND=\"000\" # black\n```\n\nAnd add element `custom_command_time` to your prompt:\n```bash\nPOWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs vcs custom_command_time time)\n```\n\n\n## Provision with ansible\n~~Plugin `command-time` included in ansible role [viasite-ansible/ansible-role-zsh](https://github.com/viasite-ansible/ansible-role-zsh)\nwith other useful plugins.~~ Plugin excluded from viasite-ansible.zsh, but you can still check role.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopstas%2Fzsh-command-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpopstas%2Fzsh-command-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopstas%2Fzsh-command-time/lists"}