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

Fish function are not completions #2186

Open
Zykino opened this issue Feb 24, 2023 · 10 comments
Open

Fish function are not completions #2186

Zykino opened this issue Feb 24, 2023 · 10 comments

Comments

@Zykino
Copy link
Contributor

Zykino commented Feb 24, 2023

Doing zellij setup --generate-completion fish > ~/.config/fish/completions/zellij.fish create a lot of nice completions around zellij.

I have 2 issues with it:
The completions files are evaluated lazily but some functions are in there ze zrf… They should be in ~/.config/fish/functions/zellij.fish where they will be evaluated more eagerly (so I can use ze without having to do zellij [Tab] first.
=> We need 2 generation commands or 2 outputs. This can be worked around and fixed manually… if the users know all that 😅.
I’m not sure how other shell’s completions are working.

zellij run [Tab] (and zellij action new-pane [Tab], maybe others too) try to complete with local folder instead of commands. I’m not sure it can be addressed, I do not know the fish completion ^^'.

@Zykino
Copy link
Contributor Author

Zykino commented Feb 24, 2023

Note: As a user, to save the functions just do:

zellij setup --generate-completion fish > ~/.config/fish/completions/zellij.fish
zellij [Tab] [Ctrl+c]
funcsave zr
funcsave zrf
funcsave ze
funcsave zef

This will save each function into its own autoloaded function file in ~/.config/fish/functions/z*.

@imsnif
Copy link
Member

imsnif commented Feb 27, 2023

Yeah, I'll readily admit I kind of hacked these together in the last minute before the release. So you're suggesting adding a --generate-shell-aliases flag instead? Or some other name?

@Zykino
Copy link
Contributor Author

Zykino commented Feb 27, 2023

I don’t really know. Another possibility is to generate all files and directory structure (possibly in /tmp/zellijConfig). And in stdout tell the user to inspect it and then mv /tmp/zellijConfig ~/.config/fish if they are ok to keep it. I mean, if you do not want to overwrite default config automatically.

I’m not sure generating multiples aliases is possible in a single file, the way fish works. Or maybe ze and zef in ze.fish and the same for the zr family? I must admit, I use fish but am not well versed into its configs.

@Zykino
Copy link
Contributor Author

Zykino commented Mar 11, 2023

skim does not propose auto-installing their function (or I’m not aware how). They propose this file: https://github.com/lotabout/skim/blob/master/shell/key-bindings.fish. I installed it with:

curl https://raw.githubusercontent.com/lotabout/skim/master/shell/key-bindings.fish > ~/.config/fish/functions/skim.fish
< edit the file to insert the command as a reminder ;) >

zellij can offer the same and all the aliases in the same file: zellij.fish.

Thinking again, maybe this can be a good citizen default: not "steal" all the short name and expose the quick functions as zellije, zellijef, zellijr, zellijrf. Easier to remember/learn for occasional user.

Maybe on the "shell integration" doc can propose to do the abbr -a -U -- ze zellije.

@jirijakes
Copy link

I don't know what would be the fishiest way but one more option how to make the completions and aliases work now is adding:

zellij setup --generate-completion fish | source

into config.fish. It's probably not the most idiomatic way but AFAIK it's also what zoxide and starship recommend.

@Zykino
Copy link
Contributor Author

Zykino commented Mar 14, 2023

Effectively starship and skim ask to do something like this in the config.fish, inside the if status is-interactive block.

if status is-interactive
	# Commands to run in interactive sessions can go here

	# Skim key bindings
	source ~/.config/fish/functions/skim.fish
	skim_key_bindings

	starship init fish | source
end

So this is a possibility, but I prefer skim's setup: do not generate the config each time. Especially for the completion: as a user you prefer them not to change without your knowledge.

@valankar
Copy link

valankar commented Aug 3, 2023

Yeah, I'll readily admit I kind of hacked these together in the last minute before the release. So you're suggesting adding a --generate-shell-aliases flag instead? Or some other name?

I thinking having a --generate-shell-aliases makes sense. https://fishshell.com/docs/current/completions.html#where-to-put-completions indicates there being a completions directory separate from the functions directory. I ended up putting the functions in ~/.config/fish/functions/zellij.fish and completions in ~/.config/fish/completions/zellij.fish.

@Zykino
Copy link
Contributor Author

Zykino commented Aug 3, 2023

I saw #2650 is trying to fix this :)

@aldanor
Copy link

aldanor commented Nov 28, 2023

Another thing I noticed (unless it has been already discussed somewhere), in the fish shell,

  • ze function auto-completes file paths
  • zef function does not autocomplete file paths which renders it next to useless (it tries to auto-complete options but never file paths)

I.e.,

  • ze <tab> shows files in the current folder
  • zef <tab> shows zellij command options and arguments

Edit: it looks like those functions are missing --wraps="zellij edit" and --wraps="zellij edit --floating" in order for auto-complete to behave correctly.
Edit 2: actually no, sometimes it fixes it, sometimes it doesn't. I'm not quite what makes it behave right or wrong.

@upryst
Copy link

upryst commented Jul 2, 2024

Struggling with zef completion behaviour as well. It looks like there's a collision with zef from Raku universe, which Fish is trying to support out of the box.

Erasing the conflicting completion makes zef act like the other aliases:

$ complete -e zef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants