# fishの起動が重い時 ###### tags: `fish` `fishshell` `anyenv` ## About this page [fish](http://fishshell.com)の起動が重いときの対処方法 ## 最初にやること > `fish_trace`, if set and not empty, will cause fish to print commands before they execute, similar to set -x in bash. The trace is printed to the path given by the --debug-output option to fish (stderr by default). > [Special variables - Introduction — fish-shell 3.1.0 documentation](http://fishshell.com/docs/current/index.html?highlight=fish_trace) `set -U fish_trace 1`とする `exec fish`なりしてリロードしてみると以下のようなログが表示されるようになる ###### log ``` + source /usr/local/share/fish/config.fish +++ set -g IFS \n\ \t +++ set -qg __fish_added_user_paths +++ set -g __fish_added_user_paths +++ if +++ set -q __fish_initialized +++ end if +++ function __fish_default_command_not_found_handler +++ if ~~~ + source /home/alice/.config/fish/functions/fish_right_prompt.fish +++ function __bobthefish_cmd_duration -S -d 'Show command duration' +++ function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans' +++ function __bobthefish_timestamp -S -d 'Show the current timestamp' +++ function fish_right_prompt -d 'bobthefish is all about the right prompt' ``` 時間表示されないが(される方法はあるのか?)、出力を追っていると、不思議と時間のかかる処理、大量の行数を吐く処理などがわかる ### log停止 `set -e fish_trace`する または`set -U fish_trace`でもいい(と思う) ## anyenvの対処 `anyenv init`すると、`$__fish_config_dir/config.fish`に`status --is-interactive; and source (anyenv init -|psub)`を追記するように求められる。 `anyenv init - fish`などを実行するとわかるが[anyenv/anyenv-init](https://github.com/anyenv/anyenv/blob/master/libexec/anyenv-init)で`for env in $(anyenv-envs); do`から`${env} init -`しているため、まあ遅い 対処法としては、一番遅めの処理`rehash`を消すこと `anyenv init -|psub`ではなく`anyenv init - --no-hash | psub`にしておく