Apologies, did not notice the reply options. Cheers, Joel Maxuel ---------- Forwarded message ---------- From: "Joel Maxuel" <j.max...@gmail.com> Date: May 14, 2017 7:21 AM Subject: Re: Bug#862527: fish: complete command not passing options or skipping execution of command, exiting silently To: "David Adam" <zanc...@ucc.gu.uwa.edu.au> Cc:
I think there is a misunderstanding as to why I used complete in the first place. I do not want to apply the first search result. Rather, if there are multiple results to present a menu of those results and allow the end user to choose the directory to cd to. I have already achieved this in bash through a select command, which is similar in end-user concept to choice in DOS. It looked to me that complete was fish's equivalent based on some issues I found on github. True, I was unsure about how the quotes around the parameter would behave when there were nested inside another set of double quotes only separated by brackets. I did have at one point used single quotes for the interior and none at all but it had no other result. So, what would be the equivalent to select/choice in fish? Cheers, Joel Maxuel On May 14, 2017 6:28 AM, "David Adam" <zanc...@ucc.gu.uwa.edu.au> wrote: On Sun, 14 May 2017, Joel Maxuel wrote: > I am writing a function to change to a directory below the current working > directory, and I am hitting a brick wall with fish from Jessie backports > (2.2.0-3~bpo8+1) and Stretch (2.4.0-1). The function is as follows (saved > as ~/.config/fish/functions/cdb.fish): > > function cdb > complete -c cd -r -a "(find -type d -name "$argv" -not -path > '*/\.*' -prune)"; > end > > So after "funcsave cdb", I try it with a same directory name and it > silently exits with no action taken. The complete builtin is for describing how a command should be completed - that is, what should happen when you type the command and press Tab. If you are trying to write a function, the function should perform the action directly. Instead, try: function cdb cd (find -type d -name "$argv" -not -path '*/\.*' -prune)[1] end The array subscript (`[1]`) ensures that only the first result is used. > I debugged to the point that the find command by itself works (returns the > directory). After consulting the fish documentation[1], I found out you > can test complete commands at the terminal. So I tried again with: > > complete -c cd -r -a "(find -type d -name "github" -not -path '*/\.*' > -prune)" > > ...still, no action taken. This example defines a completion for the cd builtin, rather than defining a function. It also has incorrect quoting - in general, the argument to the `-a` option should be surrounded by single quotes. > While I was in the documentation, I tried a stock example: > > complete -x -c su -d "Username" -a "(cat /etc/passwd | cut -d : -f 1)" > > Even with that, no choices, nothing executed. Running complete without > parameters provides a list of saved examples. Likewise, this example defines a completion for the su builtin. David Adam fish committer zanc...@ucc.gu.uwa.edu.au