Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to automate installation #148

Closed
kbd opened this issue Jan 13, 2020 · 4 comments
Closed

Make it easier to automate installation #148

kbd opened this issue Jan 13, 2020 · 4 comments

Comments

@kbd
Copy link

kbd commented Jan 13, 2020

I noticed you recently created the --print-shell-function flag in #145. That enabled me to automate the installation of the shell script, but to fully automate the installation and avoid the install prompt the first time I run broot on a computer, I had to do the following:

mkdir -p ~/Library/Preferences/org.dystroy.broot/launcher/
touch ~/Library/Preferences/org.dystroy.broot/launcher/refused
broot --print-shell-function zsh > ~/bin/shell/3rdparty/br.zsh

One suggestion would be to have broot --install-shell-function {shell} {path} as a parallel option to broot --install that will create the shell function for shell at path and disable the install prompt.

So the above could just be:

broot --install-shell-function zsh ~/bin/shell/3rdparty/br.zsh

That would keep me from having to encode, in my setup program, details about how broot marks itself as having been installed.

@Canop
Copy link
Owner

Canop commented Jan 13, 2020

The missing part seems to be to ease preventing the install prompt. Maybe this:

broot --refuse-auto-install
broot --print-shell-function zsh > ~/bin/shell/3rdparty/br.zsh

(edited as per following comment)

@kbd
Copy link
Author

kbd commented Jan 13, 2020

I think you mean:

broot --refuse-auto-install
broot --print-shell-function zsh > ~/bin/shell/3rdparty/br.zsh

But yes that would be perfect.

@Canop
Copy link
Owner

Canop commented Jan 14, 2020

--set-install-state sets the installation state

This can be used in tests or manual installs to set the installation state.

For example, if you make an installation script which automatically
installs just the fish function in ~/sea, you may do

broot --set-install-state refused --print-shell-function fish > ~/sea/br.fish

@infinisil
Copy link

infinisil commented Jan 17, 2020

This whole install state thing is a bit unfit if the package isn't installed through $HOME, which is also the case with Nix.

How about having an environment variable instead, e.g. BROOT_INSTALLED, where if set, $HOME isn't touched and it is assumed to be installed through other means. With this available, the shell functions can be changed to

function br {
  BROOT_INSTALLED=1 broot --outcmd "$f" "$@"
}

This means that whenever the user called the br function, broot will know that they already have it installed and it doesn't need to install anything itself.

@kbd's above use-case can then also be replaced with

BROOT_INSTALLED=1 broot --print-shell-function fish

Maybe this could even be BROOT_INSTALL_STATE=refused instead, as a preferred source for the install state instead of a file in $HOME. That seems like a much cleaner solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants