leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.29k stars 41 forks source link

Create fish extension installer #241

Closed spenserblack closed 11 months ago

spenserblack commented 11 months ago

Follow up to #240

leo-arch commented 11 months ago

Great. Now, what are the implementation details? How does this script make our lives easier? Is it supposed to be automatically triggered at installation time, or should it rather be executed by the user?

spenserblack commented 11 months ago

How does this script make our lives easier?

For readability the names are the same as the .sh counterparts, but when installed the files should be named the same as the functions. E.g. function c should be in $HOME/config/fish/functions/c.fish. So this basically handles the mapping of source filename to destination filename for you, and it involves less typing than manually copying the files.

Right now, this isn't too bad -- with only two functions, it's not too painful to call cp path/to/FUNCTION.fish ~/.config/fish/functions/F.fish twice. But it should hopefully reduce tedium as more functions are added.

Is it supposed to be automatically triggered at installation time, or should it rather be executed by the user?

My assumption would be that it would be run manually. Since this installs functions that may conflict with existing aliases, it's probably best for at least a bit of manual work to occur. Perhaps this should be mentioned in the SHELL FUNCTIONS section of the manpage?

leo-arch commented 11 months ago

So, the actual command to execute would be:

install-extensions cd_on_quit file_picker

anywhere in the fish shell (not in clifm), isn't it?

spenserblack commented 11 months ago

Well, in any shell, really. It's just an executable file.

# no args to install all
path/to/install-extensions.fish

# specify extension to install
path/to/install-extensions.fish cd_on_quit

I think I see what you're getting at, though. Were you expecting a plugin that could be called in clifm?

leo-arch commented 11 months ago

Were you expecting a plugin that could be called in clifm?

Not necessarily. Most plugins are design to be executed from within clifm, true, but that depends on the nature of the plugin/function. In this case, since ideally it will be executed once per install, it just makes sense to be executed from somewhere else.

However, since it is just a script, it can be launched from clifm as well, just as from any other shell.

What about automatically running the script from the Makefile itself? Can we make it to just exit if this directory doesn't exist (i.e. fish isn't installed)?

spenserblack commented 11 months ago

Can we make it to just exit if this directory doesn't exist (i.e. fish isn't installed)?

If fish isn't installed then the script wouldn't even execute since it uses the fish executable. And in the case that fish is installed but $__fish_config_dir doesn't exist, TBH I'd consider that an issue with an improperly configured environment.

I'm still thinking that installing these extensions shouldn't be the default. So perhaps the Makefile can take a variable like INSTALL_EXTENSIONS=fish?

leo-arch commented 11 months ago

If fish isn't installed then the script wouldn't even execute since it uses the fish executable

So simple.

For the time being, let's keep this script. We'll have time to figure out the best way to make use of it (a one-step command to install multiple functions is enough to justify its existence, even if it needs to be executed by the user).