{"action":"created","issue":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/83","labels_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/83/comments","events_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/83/events","html_url":"https://github.com/bhilburn/powerlevel9k/pull/83","id":104378459,"number":83,"title":"Implement defined, set_default utility functions","user":{"login":"jkoelndorfer","id":507443,"avatar_url":"https://avatars.githubusercontent.com/u/507443?v=3","gravatar_id":"","url":"https://api.github.com/users/jkoelndorfer","html_url":"https://github.com/jkoelndorfer","followers_url":"https://api.github.com/users/jkoelndorfer/followers","following_url":"https://api.github.com/users/jkoelndorfer/following{/other_user}","gists_url":"https://api.github.com/users/jkoelndorfer/gists{/gist_id}","starred_url":"https://api.github.com/users/jkoelndorfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkoelndorfer/subscriptions","organizations_url":"https://api.github.com/users/jkoelndorfer/orgs","repos_url":"https://api.github.com/users/jkoelndorfer/repos","events_url":"https://api.github.com/users/jkoelndorfer/events{/privacy}","received_events_url":"https://api.github.com/users/jkoelndorfer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-02T00:07:27Z","updated_at":"2015-09-02T07:26:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/pulls/83","html_url":"https://github.com/bhilburn/powerlevel9k/pull/83","diff_url":"https://github.com/bhilburn/powerlevel9k/pull/83.diff","patch_url":"https://github.com/bhilburn/powerlevel9k/pull/83.patch"},"body":"Per my previous comment, whipped up a couple of utility functions to help set defaults for powerlevel9k configurables.\r\n\r\n`defined` does what you think it does - except unlike `-n`, it also works if the variable is defined but empty. Very nifty!\r\n\r\n`set_default` allows for a shorthand if your variable is a scalar, e.g: `set_default myvar hello` sets `myvar` to \"hello\" only if it has not been defined previously.\r\n\r\nUnfortunately, `typeset` can't set a value for an array. For arrays, do something like `defined array || array=(1 2 3)`.\r\n\r\nAlso put in some work to get existing variable checks switched over to use `defined` or `set_default` as appropriate. I didn't go into great depth to see if we could do any refactoring, just grabbed the low hanging fruit for this PR. :-)"},"comment":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/comments/136960859","html_url":"https://github.com/bhilburn/powerlevel9k/pull/83#issuecomment-136960859","issue_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/83","id":136960859,"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-09-02T07:26:46Z","updated_at":"2015-09-02T07:26:46Z","body":"Awesome! Thanks. :)"}}