From 2f6a9bb297acfd30937178bec6f5d054c96c3a51 Mon Sep 17 00:00:00 2001 From: figsoda Date: Wed, 14 Apr 2021 17:46:27 -0400 Subject: [PATCH] nixos/programs/fish: add shellAbbrs config --- nixos/modules/programs/fish.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nixos/modules/programs/fish.nix b/nixos/modules/programs/fish.nix index 392f06eb933..8dd7101947f 100644 --- a/nixos/modules/programs/fish.nix +++ b/nixos/modules/programs/fish.nix @@ -8,6 +8,11 @@ let cfg = config.programs.fish; + fishAbbrs = concatStringsSep "\n" ( + mapAttrsFlatten (k: v: "abbr -ag ${k} ${escapeShellArg v}") + cfg.shellAbbrs + ); + fishAliases = concatStringsSep "\n" ( mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") (filterAttrs (k: v: v != null) cfg.shellAliases) @@ -83,6 +88,18 @@ in ''; }; + shellAbbrs = mkOption { + default = {}; + example = { + gco = "git checkout"; + npu = "nix-prefetch-url"; + }; + description = '' + Set of fish abbreviations. + ''; + type = with types; attrsOf str; + }; + shellAliases = mkOption { default = {}; description = '' @@ -205,6 +222,7 @@ in # if we haven't sourced the interactive config, do it status --is-interactive; and not set -q __fish_nixos_interactive_config_sourced and begin + ${fishAbbrs} ${fishAliases} ${sourceEnv "interactiveShellInit"}