-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
〈New〉import command. #288
〈New〉import command. #288
Conversation
…end_tree` to `require_tree`.
…Introduces the idea of libraries. Full comments.
…. Add detailed comments.
import
command.+ Fix bug where a space was added after messages leading to unexpectedly erasing the first character if the last string passed to `msg` was a \r.
Let's start the review... :) |
Take your time and let me know anything. |
# Should appear at the end if used. Specifies the name of the | ||
# global path variable to prepend the matched directories to. | ||
# If not used, the $fish_function_path is assumed by default. | ||
# [glob1 ] -a -and [glob2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[glob1] [-o -or] [glob2] ...
[glob1 ] -a -and [glob2]
could share the same pattern.
[<glob> [<operator> <glob>..]]
could possibly too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, however the reason for [-o -or]
, but only -a -and
is that the or
operator is optional (used by default if no operator is used), whereas and
must be specified if you are planning to use it. Anyway I think your format is more like it so perhaps:
[<glob> -o -or <glob>..]
[<glob> [-a -and <glob>..]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I'll do some debugging, it's noticeable slower to start my terminal with this branch. |
+ Removed unnecesary " . " for sourcing .load files. + Add comments to improve explaining the setup process. + Add more readable and user friendly if constructs as opposed to relying to any status code with `and` and `or`. + Remove `msg` plugin to split into another future PR. + Remove `rbenv` bug introduced in previous PR.
@bpinto Updated PR according to what was discussed. Did you notice any improvements after this update? I am using UPDATE: OK, I just tried the older version again, the one with |
Just tried, still not as fast. I believe the |
…and use only for root paths (fish_path and custom_path). Do not add custom paths for completions, only for plugins and themes.
I got it. Now Now I am trying to fix a bug in |
…irectory or subdirectories instead of both.
@@ -1,3 +1,8 @@ | |||
set -l rbenv_dir "$ec" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a bug on this code, don't worry about rbenv for now.
.oh-my-fish:prepend_path λ set rbenv_dir abc
.oh-my-fish:prepend_path λ echo $rbenv_dir
abc
.oh-my-fish:prepend_path λ set rbenv_dir "$I_DONT_EXIST"
.oh-my-fish:prepend_path λ echo $rbenv_dir
Just pushed the new changes. It seems to be loading just as fast as your No more eval, the code is a bit shorter again and still we have |
if contains -- $argv[1] -p --preview | ||
printf "%s\n" $dir | ||
else | ||
_prepend_path $dir fish_function_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/bpinto/oh-my-fish/pull/290 alter this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, how do you proceed here? Do you merge your commit and then the import branch? Or do you want me to copy/modify anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better as we can simplify the calls below. Otherwise I'd merge that #290 later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged #290.
This merges your changes, and updates calls to the new |
…m paths and resort to a simpler solution while sourcing .load files.
I added a small improvement during the initial setup. # Prepend all user custom paths to the fish path and source load files.
for custom_file in $fish_custom/**
_prepend_path $custom_file -d fish_function_path
switch $custom_file
case \*.load
. $custom_file
end
end In the same loop we are using to source the .load files we can also |
I'll to another full review, but if you could squash and rebase, that would be the next step. |
eval $preview # skip when on preview mode | ||
and printf "%s " $directory | ||
or _prepend_path $directory $destination | ||
# Travese $path and prepend only directories with matches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo traverse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.
…ix typos in comments.
… once and used declared variable consistently.
This is it. BTW now |
Breakdown
oh-my-fish.fish
initial configuration and adds in-depth comments. The amount of code is reduced to ~10 lines of code.import
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._prepend_tree
reducing amount of code to half.import
calls_prepend_tree
for each plugin in the global$fish_plugins
prepending subdirectories containing.fish
files to the$fish_function_path
.Now 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.Notes
import
replacesoh_my_fish.fish
,_fish_add_plugin
,_fish_add_completion
,_fish_source_plugin_load_file
functions insidefunctions/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:Performance
I 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 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.Usage
import <path/library>[<path/library>..]
Imports libraries, plugins, themes, completions. Prepends existing user
custom/<library>
directories to the path to allow users to override specific functions. Useimport
to load plugins, themes, handle plugin inter-dependency, etc.Examples
import plugins/dpaste themes/bobthefish
import plugins/{cask,brew,django}
Extras
msg
plugin. See Add msg plugin #285.Related & Other Issues
#286 #284 #285 #96