{"action":"created","issue":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/563","repository_url":"https://api.github.com/repos/bhilburn/powerlevel9k","labels_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/563/labels{/name}","comments_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/563/comments","events_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/563/events","html_url":"https://github.com/bhilburn/powerlevel9k/issues/563","id":241428461,"number":563,"title":"RFC: Split out segments into fpath functions","user":{"login":"docwhat","id":40799,"avatar_url":"https://avatars2.githubusercontent.com/u/40799?v=3","gravatar_id":"","url":"https://api.github.com/users/docwhat","html_url":"https://github.com/docwhat","followers_url":"https://api.github.com/users/docwhat/followers","following_url":"https://api.github.com/users/docwhat/following{/other_user}","gists_url":"https://api.github.com/users/docwhat/gists{/gist_id}","starred_url":"https://api.github.com/users/docwhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwhat/subscriptions","organizations_url":"https://api.github.com/users/docwhat/orgs","repos_url":"https://api.github.com/users/docwhat/repos","events_url":"https://api.github.com/users/docwhat/events{/privacy}","received_events_url":"https://api.github.com/users/docwhat/received_events","type":"User","site_admin":false},"labels":[{"id":171514129,"url":"https://api.github.com/repos/bhilburn/powerlevel9k/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":253147701,"url":"https://api.github.com/repos/bhilburn/powerlevel9k/labels/next","name":"next","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-07-08T05:54:26Z","updated_at":"2017-07-12T15:59:04Z","closed_at":null,"body":"### Proposal:\r\n\r\n- Put each segment method (currently `prompt_foo`) into the functions directory.\r\n- Any helper methods would be added to the same file and would be invisible to the shell.\r\n- The current contents of the `functions` directory would likewise be split up.\r\n- The functions directory would be added to the `$fpath` and `autoload`ed.\r\n    - Alternative approach:  We could create the `autoload -X` stubs ourselves and not pollute the user's `fpath`.\r\n    ``` zsh\r\n    # Tested and it works!\r\n    p9k-foobar() {\r\n        local oldfpath=( \"${(@)fpath}\" )\r\n        local fpath=( \"/path/to/installation/functions\" \"${(@)oldfpath}\" )\r\n        autoload -X\r\n    }\r\n    ```\r\n- All (public) functions in the `functions` directory would be prefixed with something like `p9k-` (utility functions) and `p9k-segment-` (segments).\r\n\r\nReasons:\r\n\r\n- The current `powerlevel9k.zsh-theme` is very large.  Splitting it up would make it easier to read.\r\n- This would make reuse easier, since you could find all the functions.\r\n- Functions could do things like change the `emulation`, reset all `setopt`s (temporarily) to ensure portability, use local `setopt`s and even use local `trap`s!\r\n- We could add tests to verify each function is documented; We could even generate a web page from the documentation for developers. e.g. the first block of comments could be processed as markdown.\r\n- Testing would be easier, since each function could be tested separately.\r\n- Profiling would be easier, since each function could be profiled separately.\r\n- Functions wouldn't clutter up the user's shell if they aren't used (currently 63 total).\r\n- Functions could be compiled individually to boost performance; power users who have a whole-zshrc `.zwc` file would not be affected by this (see `AUTOLOADING FUNCTIONS` in the man pages)."},"comment":{"url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/comments/314815346","html_url":"https://github.com/bhilburn/powerlevel9k/issues/563#issuecomment-314815346","issue_url":"https://api.github.com/repos/bhilburn/powerlevel9k/issues/563","id":314815346,"user":{"login":"docwhat","id":40799,"avatar_url":"https://avatars2.githubusercontent.com/u/40799?v=3","gravatar_id":"","url":"https://api.github.com/users/docwhat","html_url":"https://github.com/docwhat","followers_url":"https://api.github.com/users/docwhat/followers","following_url":"https://api.github.com/users/docwhat/following{/other_user}","gists_url":"https://api.github.com/users/docwhat/gists{/gist_id}","starred_url":"https://api.github.com/users/docwhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwhat/subscriptions","organizations_url":"https://api.github.com/users/docwhat/orgs","repos_url":"https://api.github.com/users/docwhat/repos","events_url":"https://api.github.com/users/docwhat/events{/privacy}","received_events_url":"https://api.github.com/users/docwhat/received_events","type":"User","site_admin":false},"created_at":"2017-07-12T15:59:04Z","updated_at":"2017-07-12T15:59:04Z","body":"We should collect some standards to normalize on...\r\n\r\n- All methods start with `-p9k-` or `-powerlevel9k-`.  example:\r\n    ``` zsh\r\n    -p9k-segment-dir {\r\n    ...\r\n    }\r\n    ```\r\n    Except for ones that must conform to an external API requirement (e.g. `prompt_powerlevel9k_setup` required by the `prompt` command).\r\n- `setopt local_options` is your friend.\r\n- Avoid external programs whenever possible; `zshexpn(1)` is your friend!\r\n- When in doubt, ask!"}}
{"actor":{"display_login":"docwhat"}}