Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(completion): display aliases in fish completion #1782

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion completion/fish/task.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function __task_get_tasks --description "Prints all available tasks with their d
end

# Grab names and descriptions (if any) of the tasks
set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(aliases.*/\1\t\2/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(\(aliases.*\))/\1\t\2\t\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this as a fix, but I think it would be good to move this complexity to Task itself sometime rather than relying on invoking sed. Looking at this expression gives me a headache 😆

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitive +1!

It would be simpler and more powerful. To match my previous comment, I had to do something like this:

set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(aliases: \(.*\))/\1,\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/' -e 's@,@\n@g' -e 's@ @@g'| string split0)
image

The result is better than the original version, but doing that with a real language is the best solution/idea!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with you, I would even argue that fish / bash / zsh does not support the same "feature" in the auto complete
As you said, we could move all complexity in our go code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it in zsh, the behavior is the same, aliases are displayed but not "searchable"

if test $output
echo $output
end
Expand Down
Loading