nu_scripts icon indicating copy to clipboard operation
nu_scripts copied to clipboard

[WIP] post-install and nu-script-handler

Open danimesq opened this issue 3 years ago • 3 comments

post-install installs .nu files' mimetype, mimetype's icon and the nu-script-handler.

nu-script-handler triggers the action when user double-clicks/opens/executes .nu files from the file explorer.

They're both written in pure shell (sh) and have to be ported to nu.


Update [14-03-2022]: based in fdncred's comment, here are the required tasks to put post-install close to be a proper candidate for merging:

Tasks

  • [ ] Install binary in /usr/bin if Linux (already a thing), but also support MacOS (probably the same) and Windows' locations
  • [ ] Remove .gitmeta
  • [ ] script/lib that detects when no GUI is available, so post-install should display a warning
  • [ ] lib that detects the terminals installed: both on Linux and Windows; and if none available, let the OS to open the default (just as it already happens with sh/bat executables)
  • [ ] Support MacOS and Windows file icons/mimetypes
  • [ ] Port its logics to nushell

danimesq avatar Mar 12 '22 18:03 danimesq

Converted to draft so it doesn't get accidentally merged.

We'll have to discuss these things.

  1. It is not written in nushell.
  2. It's only focused on linux.
  3. It seems to be only focused on gnome-terminal.
  4. I think the .gitmeta file should be removed.
  5. Seems like it's focused on desktop gui environments only.
  6. It doesn't look like I can test this out on WSL or Mac.

It looks like you did a lot of hard work on this and I can appreciate it for that. It may help others running similar environments, but I'm not sure it's a good candidate for the nu_scripts repo. We'll discuss this and get back to you.

fdncred avatar Mar 12 '22 19:03 fdncred

It is not written in nushell.

Yes; already aware as in the PR's description and its WIP status in the title. Its a problem that can be tackled without major difficulties.

It's only focused on linux.

Good point!

It aims at Linux's mimetypes and hardcodes a /usr/bin folder. Probably it have other issues that prevents it from a seamless experience on other platforms such as Windows and MacOS.

I will make a checklist in the description.

It seems to be only focused on gnome-terminal.

Agree; and it was acknowledged in a commit message. A plan is to make a lib that detects the terminals installed: both on Linux and Windows; and if none available, let the OS to open the default (just as it already happens with sh/bat executables). My idea for getting a terminal open is that on Linux/Windows you have no context when you open a sh/bat script: the terminal opens and closes instantly so you have no idea what you did/happened.

I think the .gitmeta file should be removed.

Oh, sorry. Will do it in an next update.

This file is from my environment's hooks. I have an obsession in preserving files' dates so I made some tools to leverage git in date preserving methods.

Seems like it's focused on desktop gui environments only.

I would merge this point into It seems to be only focused on gnome-terminal. The major purpose of post-install is to turn .nu files into doubleclickable scripts with their own icons; so yes, this script is focused on GUI only. I have a script/lib that detects when no GUI is available, so post-install should display a warning.

Hope its not a big issue if nu_scripts guidelines don't force CLI-only scripts and can make an exception for GUI-only interactions.

It doesn't look like I can test this out on WSL or Mac.

Probably merge-able into It's only focused on linux.

I will update this PR's description with a tasklist you can feel free to edit.

danimesq avatar Mar 14 '22 23:03 danimesq

Another thing that can be done, is renaming this script to post-install-linux and letting the huge work for future spin-offs (such as post-install-windows, etc).

danimesq avatar Mar 14 '22 23:03 danimesq