fish: support flexible abbreviations
https://github.com/fish-shell/fish-shell/releases/tag/3.6.0
This commit is contained in:
parent
e1f3b36ab0
commit
8cedd63eed
3 changed files with 144 additions and 8 deletions
62
tests/modules/programs/fish/abbrs.nix
Normal file
62
tests/modules/programs/fish/abbrs.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{ config, ... }: {
|
||||
config = {
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
|
||||
shellAbbrs = {
|
||||
l = "less";
|
||||
gco = "git checkout";
|
||||
"-C" = {
|
||||
position = "anywhere";
|
||||
expansion = "--color";
|
||||
};
|
||||
L = {
|
||||
position = "anywhere";
|
||||
setCursor = true;
|
||||
expansion = "% | less";
|
||||
};
|
||||
"!!" = {
|
||||
position = "anywhere";
|
||||
function = "last_history_item";
|
||||
};
|
||||
vim_edit_texts = {
|
||||
position = "command";
|
||||
regex = ".+\\.txt";
|
||||
function = "vim_edit";
|
||||
};
|
||||
"4DIRS" = {
|
||||
setCursor = "!";
|
||||
expansion =
|
||||
"$(string join \\n -- 'for dir in */' 'cd $dir' '!' 'cd ..' 'end')";
|
||||
};
|
||||
dotdot = {
|
||||
regex = "^\\.\\.+$";
|
||||
function = "multicd";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt = {
|
||||
description =
|
||||
"if fish.shellAbbrs is set, check fish.config contains valid abbreviations";
|
||||
script = ''
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add -- l less'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add -- gco "git checkout"'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add --position anywhere -- -C --color'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add --position anywhere --set-cursor -- L "% | less"'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add --function last_history_item --position anywhere -- !!'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
"abbr --add --function vim_edit --position command --regex '.+\.txt' -- vim_edit_texts"
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
'abbr --add '"'"'--set-cursor=!'"'"' -- 4DIRS "$(string join \n -- '"'"'for dir in */'"'"' '"'"'cd $dir'"'"' '"'"'!'"'"' '"'"'cd ..'"'"' '"'"'end'"'"')'
|
||||
assertFileContains home-files/.config/fish/config.fish \
|
||||
"abbr --add --function multicd --regex '^\.\.+$' -- dotdot"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
fish-abbrs = ./abbrs.nix;
|
||||
fish-format-scripts = ./format-scripts.nix;
|
||||
fish-functions = ./functions.nix;
|
||||
fish-no-functions = ./no-functions.nix;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue