Skip to content

Commit

Permalink
feat: add fish completion for yarn workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Oct 29, 2024
1 parent 1bfc49f commit 4f6b7e6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions modules/home-manager/fish/yarn.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{}:

{
xdg.configFile.fishCompletionYarn = {
executable = true;
target = "fish/completions/yarn.fish";
text = ''
function __fish_yarn_get_workspaces
if type -q jq && test -f package.json
command \
# List all workspaces glob patterns in the current workspaces
jq -r '.workspaces | .[]' package.json 2>/dev/null |\
# list nested package.json files in every glob pattern
xargs -I {} -- fish -c "ls {}/package.json 2>/dev/null" |\
# get name of the workspace from the package.json
xargs -I {} -- fish -c "jq -r '.name' {} 2>/dev/null" |\
# remove empty lines
grep -v '^$' 2>/dev/null |\
# remove duplicates
sort -u 2>/dev/null
end
end
complete -f -c yarn -n '__fish_seen_subcommand_from workspace' -a "(__fish_yarn_get_workspaces)"
'';
};
}

0 comments on commit 4f6b7e6

Please sign in to comment.