From 0a5547e3c8b44c879fef427b901cf60eed91c3b7 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Mon, 9 Aug 2021 13:27:58 +0800 Subject: [PATCH] fish: simplify config guards --- modules/programs/fish.nix | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 8285364d..68f57eb5 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -187,43 +187,27 @@ in etc."fish/config.fish".text = '' # /etc/fish/config.fish: DO NOT EDIT -- this file has been generated automatically. - # if we haven't sourced the general config, do it - if not set -q __fish_nix_darwin_general_config_sourced - ${sourceEnv "shellInit"} + # Only execute this file once per shell. + set -q __fish_nix_darwin_config_sourced; and exit + set -g __fish_nix_darwin_config_sourced 1 - ${cfg.shellInit} + ${sourceEnv "shellInit"} - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew) - set -g __fish_nix_darwin_general_config_sourced 1 - end + ${cfg.shellInit} - # if we haven't sourced the login config, do it - status --is-login; and not set -q __fish_nix_darwin_login_config_sourced - and begin + status --is-login; and begin ${sourceEnv "loginShellInit"} ${cfg.loginShellInit} - - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew) - set -g __fish_nix_darwin_login_config_sourced 1 end - # if we haven't sourced the interactive config, do it - status --is-interactive; and not set -q __fish_nix_darwin_interactive_config_sourced - and begin + status --is-interactive; and begin ${fishAliases} ${sourceEnv "interactiveShellInit"} ${cfg.promptInit} ${cfg.interactiveShellInit} - - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew, - # allowing configuration changes in, e.g, aliases, to propagate) - set -g __fish_nix_darwin_interactive_config_sourced 1 end ''; }