I'm an indie coder, a weirdo, striving entrepreneur, lover, progressive activist, video gamer, friend. Primarily Php dev. Some bash libs. Solid js, css, html skills. My dev alias is Taeluf.
Location
United States
Work
Jobless, striving startup founder, open source developer at Taeluf (is my dev alias)
I def like the idea of having a bash functions folder (DIRECTORY!! lol). Personally, i just append an export PATH to my ~/.bashrc. Mainly because i have a fairly specific directory structure for my open source projects & i like to keep that structure going & not everything in my dev/bash/PROJECT folders is necessarily setup to be executed.
I also have a personal library with a cli "framework" i made that i just add functions too, so its tlf [command group] [command].
I don't do any autocompletion though. Thats still something i have to try out. & i think my setup would require some changes to make that work. Didnt know it was so easy to do. But yeah, I'd have to source files to enable it to a greater degree than.
I have a script to start spacevim that would be a good candidate for your approach.
You can do far more complicated Bash Completion with functions using COMP variables, compgen, and more:
Generic example:
$ complete-F func_name command_name
where the func_name is, of course, the name of the function where you do the more complicated stuff with COMP variables and return a COMPREPLY:
function func_name {# ... calculate COMP stuff and more ...COMPREPLY=($(compgen-W"<DO_STUFF>"))# DO_STUFF: calculated stuff from above or compgen inline expression }
But that's stuff you don't always need in a completion most of the time you can do with a simple word (-W) list:
$ complete-W"-h --help -a --add" command_name
or for some trickery:
tab toggling through a list of files only in a current directory:
A lot can be done with this, including doing background stuff that may not be directly involved in your completion like logging file info, file stamps of latest files etc...
I'm an indie coder, a weirdo, striving entrepreneur, lover, progressive activist, video gamer, friend. Primarily Php dev. Some bash libs. Solid js, css, html skills. My dev alias is Taeluf.
Location
United States
Work
Jobless, striving startup founder, open source developer at Taeluf (is my dev alias)
I def like the idea of having a bash functions folder (DIRECTORY!! lol). Personally, i just append an export PATH to my ~/.bashrc. Mainly because i have a fairly specific directory structure for my open source projects & i like to keep that structure going & not everything in my dev/bash/PROJECT folders is necessarily setup to be executed.
I also have a personal library with a cli "framework" i made that i just add functions too, so its tlf [command group] [command].
I don't do any autocompletion though. Thats still something i have to try out. & i think my setup would require some changes to make that work. Didnt know it was so easy to do. But yeah, I'd have to source files to enable it to a greater degree than.
I have a script to start spacevim that would be a good candidate for your approach.
You can do far more complicated Bash Completion with functions using
COMP
variables,compgen
, and more:Generic example:
where the
func_name
is, of course, the name of the function where you do the more complicated stuff withCOMP
variables and return aCOMPREPLY
:But that's stuff you don't always need in a completion most of the time you can do with a simple word (
-W
) list:or for some trickery:
tab toggling through a list of files only in a current directory:
or dirs only:
A lot can be done with this, including doing background stuff that may not be directly involved in your completion like logging file info, file stamps of latest files etc...
Thanks, if I ever get around to putting in the time/effort to set it up, this'll be v. helpful. Long as I remember to come back here lol.