[Feature Request] revert to file name completion after subcommand completion
ConorHK opened this issue · 4 comments
I'm looking for the ability to tab complete file names as argument inputs to strings after the file has been fully expressed.
e.g. sd share file <complete files in current dir here>
At the moment the tab completion does not include files after subcommands. I've given this a go myself but to no avail. I'd be happy to make a PR if someone can give guidance on how to do this if you're too busy.
Thanks for making sd
!
Oh yeah; it should definitely work that way.
This is done in 4725697
I have at times imagined making a simple declarative argument/usage syntax that you could use to specify custom completions for commands, and then parsing that into the nightmare that is a zsh autocomplete expression, but... this is a great compromise until then :)
Also: thanks for the feedback, and let me know if you find any bugs with it. I find that autocomplete is very tricky to get right...
@ConorHK Looking at your fork inspired me to make the script template customizable, as you probably saw.
I'm not sure I completely understand the motivation of the sd-foo
scripts, but you might be able to achieve part of that by using exec -a "sd-$(basename "$target")"
instead of exec
in the main __sd
function, if your bash is new enough (requires at least 4.2). I think it might allow easier process-killing? I'm not totally sure. (I would like to make that the default, but it would mean losing macOS support.)
Related to that, I pushed a change that simplifies the process tree of a running sd
command (got rid of one redundant shell in function mode; two in executable mode). I'm not sure if that was part of the motivation for the .scripts
directory.
If you're using "function mode" sd
, and the sd-foo
scripts are there so that you can have recursive sd
invocations, then you might be able to get away with $SD/helper-script
instead, depending on your directory hierarchy.
(Not that there's anything wrong with the .scripts
flattening thing, just could get annoying if you create new scripts very often.)
@ianthehenry I did, thank you for that! Will be useful for python script directories.
There was no initial issue per say that motivated the .scripts
dir, I just found that writing sd wm wallpaper
or somesuch in .xinitrc
to be a bit long opposed to how I had it before. Its nice to have all the scripts on my path if I need them. It was more of a "I'll do it because I can" opposed to a hard need.