mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Make fish_indent less spooky
Don't wrap fish_indent at all if the version in $PATH matches $FISH_VERSION. When we do wrap it, resolve the path once, and use that via alias machinery instead of doing an eval each time. In both cases, `type fish_indent` can tell us what it's actually going to do now. clarity aside, it's faster if we only eval the one time. eval is not only evil, but slow. > for h in $history[1..100]; echo $h | fish_indent --no-indent; end before: CMD_DURATION = 1005 if fish_indent is kosher in PATH: 549 if not, using alias: 687
This commit is contained in:
parent
204e79105a
commit
4c34ba9959
1 changed files with 7 additions and 4 deletions
|
@ -1,4 +1,7 @@
|
|||
function fish_indent --description 'Indenter and prettifier for fish code'
|
||||
# This is wrapped in a function so that fish_indent does not need to be found in PATH
|
||||
eval (string escape $__fish_bin_dir/fish_indent) $argv
|
||||
end
|
||||
# check if command fish_indent works and is the same version that
|
||||
# came with this fish. This will happen one time.
|
||||
command -s fish_indent > /dev/null
|
||||
and command fish_indent --version 2>&1 | string match -rq $FISH_VERSION
|
||||
# if alias doesn't define the function here, this is an autoloaded "nothing".
|
||||
# the command (if there is one) will be used by default.
|
||||
or alias fish_indent=(string escape $__fish_bin_dir/fish_indent)
|
||||
|
|
Loading…
Reference in a new issue