Search code examples
shellterminalfish

How to time fish prompt


I'm considering switching from zsh to fish, however before I do I want to compare the speeds at which the prompts load. I have a ZSH function which would time 10 times how long it would take for the prompt to load.

timeshell() {
  shell=${1-$SHELL}
  for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}

I'm struggling to implement the same code into something fish compliant. for instance the following:

time for i in 1 2 3 4 5 6 7 8 9 10; fish; end

Wil actually load the fish shell prompt, cancelling the command.

Any thoughts? Thank you.


Solution

  • Not sure I fully understand. Is this what you mean?

    function timeshell 
      set shell $SHELL
      for i in (seq 1 10); /usr/bin/time $shell -i -c exit; end
    end