{"action":"created","issue":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/153","labels_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/153/labels{/name}","comments_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/153/comments","events_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/153/events","html_url":"https://github.com/bhilburn/powerlevel9k/pull/153","id":117701710,"number":153,"title":"Custom command segment.","user":{"login":"Tritlo","id":1667287,"avatar_url":"https://avatars.githubusercontent.com/u/1667287?v=3","gravatar_id":"","url":"https://api.github.com/users/Tritlo","html_url":"https://github.com/Tritlo","followers_url":"https://api.github.com/users/Tritlo/followers","following_url":"https://api.github.com/users/Tritlo/following{/other_user}","gists_url":"https://api.github.com/users/Tritlo/gists{/gist_id}","starred_url":"https://api.github.com/users/Tritlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tritlo/subscriptions","organizations_url":"https://api.github.com/users/Tritlo/orgs","repos_url":"https://api.github.com/users/Tritlo/repos","events_url":"https://api.github.com/users/Tritlo/events{/privacy}","received_events_url":"https://api.github.com/users/Tritlo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-18T22:58:13Z","updated_at":"2015-11-20T23:53:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/pulls/153","html_url":"https://github.com/bhilburn/powerlevel9k/pull/153","diff_url":"https://github.com/bhilburn/powerlevel9k/pull/153.diff","patch_url":"https://github.com/bhilburn/powerlevel9k/pull/153.patch"},"body":"This segment allows the user to run an arbitrary command and display the result as a segment. Useful to enable users to monitor whatever they want, without having to muck around in powerlevel9k itself.\r\n\r\n    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_command)\r\n\r\n    POWERLEVEL9K_CUSTOM_COMMANDS=(\"echo signal: \\$(nmcli device wifi | grep yes | awk '{print \\$8}')\" )\r\n    POWERLEVEL9K_CUSTOM_COMMAND_BACKGROUNDS=(\"blue\")\r\n    POWERLEVEL9K_CUSTOM_COMMAND_FOREGROUNDS=(\"yellow\")\r\n    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(aws status load ram)\r\n\r\n\r\ngives\r\n\r\n\r\n![custom_command](https://cloud.githubusercontent.com/assets/1667287/11259502/5d340d20-8e62-11e5-9a95-047970616cec.png)\r\n\r\nInstead of defining the command inline (if it is kinda long or unreadable), one can also add a function to the .zshrc like:\r\n \r\n    zsh_signal(){\r\n         local signal=$(nmcli device wifi | grep yes | awk '{print $8}')\r\n         local color='%F{yellow}'\r\n         [[ $signal -gt 75 ]] && color='%F{green}'\r\n         [[ $signal -lt 50 ]] && color='%F{red}'\r\n         echo -n \"%{$color%}  $signal%{%f%}\"\r\n  \r\n  }\r\n\r\nAnd then just change custom commands array to read\r\n\r\n    POWERLEVEL9K_CUSTOM_COMMANDS=(\"zsh_signal\")\r\n\r\nWith this updated command, this looks like:\r\n\r\n![signal](https://cloud.githubusercontent.com/assets/1667287/11299082/f8e46a5e-8f83-11e5-8801-33b2a4618bc7.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/comments/158561779","html_url":"https://github.com/bhilburn/powerlevel9k/pull/153#issuecomment-158561779","issue_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/153","id":158561779,"user":{"login":"dritter","id":1544760,"avatar_url":"https://avatars.githubusercontent.com/u/1544760?v=3","gravatar_id":"","url":"https://api.github.com/users/dritter","html_url":"https://github.com/dritter","followers_url":"https://api.github.com/users/dritter/followers","following_url":"https://api.github.com/users/dritter/following{/other_user}","gists_url":"https://api.github.com/users/dritter/gists{/gist_id}","starred_url":"https://api.github.com/users/dritter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dritter/subscriptions","organizations_url":"https://api.github.com/users/dritter/orgs","repos_url":"https://api.github.com/users/dritter/repos","events_url":"https://api.github.com/users/dritter/events{/privacy}","received_events_url":"https://api.github.com/users/dritter/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T23:53:01Z","updated_at":"2015-11-20T23:53:01Z","body":"> They can define multiple entry points.\r\n\r\nYes, but the order of that segments is not defined in the `POWERLEVEL9K_LEFT_PROMPT_ELEMENTS` array any more, right? That now happens in `POWERLEVEL9K_CUSTOM_COMMANDS`."}}