mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-16 05:51:08 +01:00
fish: add command option for abbreviations (#6666)
The fish shell has added a flag to the abbr command which allows one to expand it only if it is typed after a real command e.g.: git s -> git status s -> s Also see the last example here: https://fishshell.com/docs/current/cmds/abbr.html#examples
This commit is contained in:
parent
cfaa4426a3
commit
8675edf7d3
2 changed files with 17 additions and 1 deletions
|
|
@ -167,6 +167,16 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Specifies the command(s) for which the abbreviation should expand. If
|
||||||
|
set, the abbreviation will only expand when used as an argument to
|
||||||
|
the given command(s).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
setCursor = mkOption {
|
setCursor = mkOption {
|
||||||
type = with types; (either bool str);
|
type = with types; (either bool str);
|
||||||
default = false;
|
default = false;
|
||||||
|
|
@ -201,7 +211,7 @@ let
|
||||||
(lib.generators.mkValueStringDefault { } v)
|
(lib.generators.mkValueStringDefault { } v)
|
||||||
];
|
];
|
||||||
} {
|
} {
|
||||||
inherit position regex function;
|
inherit position regex command function;
|
||||||
set-cursor = setCursor;
|
set-cursor = setCursor;
|
||||||
};
|
};
|
||||||
modifiers = if isAttrs def then mods else "";
|
modifiers = if isAttrs def then mods else "";
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
co = {
|
||||||
|
command = "git";
|
||||||
|
expansion = "checkout";
|
||||||
|
};
|
||||||
dotdot = {
|
dotdot = {
|
||||||
regex = "^\\.\\.+$";
|
regex = "^\\.\\.+$";
|
||||||
function = "multicd";
|
function = "multicd";
|
||||||
|
|
@ -64,6 +68,8 @@
|
||||||
cd ..
|
cd ..
|
||||||
end
|
end
|
||||||
'"
|
'"
|
||||||
|
assertFileContains home-files/.config/fish/config.fish \
|
||||||
|
"abbr --add --command git -- co checkout"
|
||||||
assertFileContains home-files/.config/fish/config.fish \
|
assertFileContains home-files/.config/fish/config.fish \
|
||||||
"abbr --add --function multicd --regex '^\.\.+$' -- dotdot"
|
"abbr --add --function multicd --regex '^\.\.+$' -- dotdot"
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue