{"action":"created","issue":{"url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/288","labels_url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/288/labels{/name}","comments_url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/288/comments","events_url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/288/events","html_url":"https://github.com/bpinto/oh-my-fish/pull/288","id":53323511,"number":288,"title":"〈New\b〉import command.","user":{"login":"bucaran","id":8317250,"avatar_url":"https://avatars.githubusercontent.com/u/8317250?v=3","gravatar_id":"","url":"https://api.github.com/users/bucaran","html_url":"https://github.com/bucaran","followers_url":"https://api.github.com/users/bucaran/followers","following_url":"https://api.github.com/users/bucaran/following{/other_user}","gists_url":"https://api.github.com/users/bucaran/gists{/gist_id}","starred_url":"https://api.github.com/users/bucaran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bucaran/subscriptions","organizations_url":"https://api.github.com/users/bucaran/orgs","repos_url":"https://api.github.com/users/bucaran/repos","events_url":"https://api.github.com/users/bucaran/events{/privacy}","received_events_url":"https://api.github.com/users/bucaran/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-01-04T03:15:31Z","updated_at":"2015-01-07T01:30:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bpinto/oh-my-fish/pulls/288","html_url":"https://github.com/bpinto/oh-my-fish/pull/288","diff_url":"https://github.com/bpinto/oh-my-fish/pull/288.diff","patch_url":"https://github.com/bpinto/oh-my-fish/pull/288.patch"},"body":"### Breakdown\r\n\r\n+ Rewrites `oh-my-fish.fish` initial configuration and adds in-depth comments. The amount of code is reduced to ~__10__ lines of code.\r\n\r\n+ Adds a __new__ [`import`](https://github.com/bucaran/oh-my-fish/blob/import/functions/import.fish) command and introduces the idea of _libraries_. A library is category to  conceptually organize cluster of `.fish` files such as plugins, themes and completions. A plugin intended to be used by other plugins and not by the user of the shell can be thought of as a _library_. \r\n\r\n+ Simplifies `_prepend_tree` reducing amount of code to half.\r\n\r\n+  `import` calls [`_prepend_tree`](https://github.com/bucaran/oh-my-fish/blob/import/functions/_prepend_tree.fish) for each plugin in the global `$fish_plugins` prepending subdirectories containing `.fish` files to the `$fish_function_path`. \r\n\r\nNow it's possible to create complex directory trees with `fish` files organized according to the plugin's own API / structure. Paths containing `.fish` files will be added to the path automatically. This should encourage plugin authors to create a consistent project hierarchy without having to worry with load / configuration files modifying the `$fish_function_path` directly. `.load` files can still be used for more pertinent tasks such as downloading assets, declaring global variables, etc. \r\n\r\n> __Note__: `_prepend_tree` runs before `.load` files are sourced, so it is still possible to override any undesired behavior in the `<plugin>.load` file if necessary.\r\n\r\n### Notes\r\n\r\n`import` replaces `oh_my_fish.fish`, `_fish_add_plugin`, `_fish_add_completion`, `_fish_source_plugin_load_file` functions inside `functions/oh-my-fish.fish/`, adds documentation and calls `_prepend_tree`, but it is still less code than the current configuration. This is possible using Fish `{}` brace expansion:\r\n\r\n```fish\r\n    set -l root $fish_path $fish_custom\r\n    # ...\r\n    set -l paths $root/$library $root/$library/completions\r\n    set -l plugins     $paths[1..2]\" fish_function_path\"\r\n    set -l completions $paths[3..4]\" fish_complete_path\"\r\n    \r\n    for path in $plugins $completions\r\n      eval \"_prepend_path \"$path\r\n    end\r\n```\r\n\r\n#### Performance\r\nI tested adding _al_ l the existing modules with a macbook pro and while I did notice a small lag when starting the shell the first time, the bottleneck seems to be simply adding so many plugins (and the fact Fish [can not](https://github.com/fish-shell/fish-shell/issues/563) run Fish code in the background) and not `_prepend_tree` running for each plugin, conclusion I reached after commenting it and retesting without being able to notice any significant performance gains. See #96 for more info.\r\n\r\n### Usage\r\n#### `import <path/library>[<path/library>..]`\r\nImports libraries, plugins, themes, completions. Prepends existing user `custom/<library>` directories to the path to  allow users to override specific functions. Use `import` to load plugins, themes, handle plugin inter-dependency, etc. \r\n\r\n> __Note__: Adds __only__ existing directories to the path.\r\n\r\n### Examples\r\n+ `import plugins/dpaste themes/bobthefish`\r\n+ `import plugins/{cask,brew,django}`\r\n\r\n### Extras\r\n\r\n+ Also included in this commit is the [`msg`](https://github.com/bucaran/oh-my-fish/blob/import/plugins/msg/msg.fish) plugin. See #285.\r\n![msg](https://cloud.githubusercontent.com/assets/8317250/5605086/41c69d96-942b-11e4-853e-c5be2d8be68d.png)\r\n\r\n### Related & Other Issues\r\n\r\n[\\#286](https://github.com/bpinto/oh-my-fish/pull/286) [\\#284](https://github.com/bpinto/oh-my-fish/pull/284) #285 #96 "},"comment":{"url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/comments/68965642","html_url":"https://github.com/bpinto/oh-my-fish/pull/288#issuecomment-68965642","issue_url":"https://api.github.com/repos/bpinto/oh-my-fish/issues/288","id":68965642,"user":{"login":"bpinto","id":526122,"avatar_url":"https://avatars.githubusercontent.com/u/526122?v=3","gravatar_id":"","url":"https://api.github.com/users/bpinto","html_url":"https://github.com/bpinto","followers_url":"https://api.github.com/users/bpinto/followers","following_url":"https://api.github.com/users/bpinto/following{/other_user}","gists_url":"https://api.github.com/users/bpinto/gists{/gist_id}","starred_url":"https://api.github.com/users/bpinto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpinto/subscriptions","organizations_url":"https://api.github.com/users/bpinto/orgs","repos_url":"https://api.github.com/users/bpinto/repos","events_url":"https://api.github.com/users/bpinto/events{/privacy}","received_events_url":"https://api.github.com/users/bpinto/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T01:30:01Z","updated_at":"2015-01-07T01:30:01Z","body":"I'll to another full review, but if you could squash and rebase, that would be the next step."}}