Skip to content

Commit 7538d96

Browse files
SandWoodJonesteto
authored andcommitted
fish: added abbr.name option
1 parent 3670a78 commit 7538d96

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

modules/programs/fish.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ let
166166

167167
abbrModule = types.submodule {
168168
options = {
169+
name = mkOption {
170+
type = with types; nullOr str;
171+
default = null;
172+
description = ''
173+
The abbreviation name that is replaced by the expansion.
174+
'';
175+
};
176+
169177
expansion = mkOption {
170178
type = with types; nullOr str;
171179
default = null;
@@ -289,8 +297,9 @@ let
289297

290298
abbrsStr = lib.concatStringsSep "\n" (
291299
lib.mapAttrsToList (
292-
name: def:
300+
attrName: def:
293301
let
302+
name = if isAttrs def && def.name != null then def.name else attrName;
294303
mods =
295304
lib.cli.toGNUCommandLineShell
296305
{

tests/modules/programs/fish/abbrs.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@
3939
command = "git";
4040
expansion = "checkout";
4141
};
42-
s = {
42+
status = {
43+
name = "s";
4344
command = [
4445
"git"
4546
"hg"
4647
];
4748
expansion = "status";
4849
};
50+
show = {
51+
name = "s";
52+
command = "systemctl";
53+
expansion = "show";
54+
};
4955
dotdot = {
5056
regex = "^\\.\\.+$";
5157
function = "multicd";
@@ -79,6 +85,8 @@
7985
"abbr --add --command git -- co checkout"
8086
assertFileContains home-files/.config/fish/config.fish \
8187
"abbr --add --command git --command hg -- s status"
88+
assertFileContains home-files/.config/fish/config.fish \
89+
"abbr --add --command systemctl -- s show"
8290
assertFileContains home-files/.config/fish/config.fish \
8391
"abbr --add --function multicd --regex '^\.\.+$' -- dotdot"
8492
'';

0 commit comments

Comments
 (0)