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

Shell Integration Not Working on Fish Shell #17

Open
jubinmytheen opened this issue Nov 1, 2023 · 9 comments
Open

Shell Integration Not Working on Fish Shell #17

jubinmytheen opened this issue Nov 1, 2023 · 9 comments

Comments

@jubinmytheen
Copy link

Hi

We are trying to integrate the shell to run the dev command. But unfortunately the shell integration is not working on fish shell.
Is there any way to integrate it on fish shell??

@mxcl
Copy link
Member

mxcl commented Nov 2, 2023

This is being built pkgxdev/pkgx#838, help welcome as I am not familiar with fish.

@philipgiuliani
Copy link

Whats missing in pkgxdev/pkgx#838 for the task to be complete?

@mxcl
Copy link
Member

mxcl commented Nov 9, 2023

Been a week so i don't recall precisely (sadly I am super busy with CEO duties RN)

If you checkout the code and try to SHELL=fish eval deno task run --shellcode we then need the shellcode functions to work

$ x  # most complex, partially working
$ env +foo   # should be easy
$ dev  # again should be pretty easy

I should be able to resume work on this next week, but feel free to get it working.

IMO if x works that's enough for now, we can then make dev work after. But as said dev is probs easiest.

All the code is in shellcode.ts

@JanPokorny
Copy link

A partial workaround for fish is to use direnv. Install it, and drop a file .envrc with the following content in your project folder:

source <(pkgx --internal.activate $(realpath .))

This will act very similarly to the dev command -- it will resolve the environment and activate it using pkgx, and deactivate it once you navigate outside of the folder. This should even have greater IDE support since direnv has been around for a while and has battle-tested extensions for most IDEs.

@JanPokorny
Copy link

Here's a "poor man's" implementation for the shell integration in Fish:

function x; bass source (pkgx +(string split -f1 ' ' $history[1]) | psub) && eval $history[1]; end;
function envx; bass source (pkgx "$argv" | psub); end;
function dev; bass source (pkgx --internal.activate $(realpath .) | psub); end;

It depends on https://github.com/edc/bass for sourcing bash scripts, and the dev command does not auto-deactivate (it's probably doable with function ... --on-variable PWD -- https://fishshell.com/docs/current/cmds/function.html -- but that would be harder to serve through bass given that it does not port over bash functions -- as said above, I recommend using direnv for this use case). env is called envx not to bother with Unix env compatibility.

@svenjacobs
Copy link

svenjacobs commented May 13, 2024

@JanPokorny Thanks for the workaround with direnv. Unfortunately this requires a .envrc file in every project folder.

Looking forward to a native Fish solution as I would like to give this shell a try. Unfortunately I have no experience with Fish and its scripting so I can't help here.

@JanPokorny
Copy link

@svenjacobs You could just run echo 'source <(pkgx --internal.activate $(realpath .))' >>.envrc && echo '.envrc' >>.git/info/exclude in every project folder and be done with it. You could alias it to dev-setup or something and just use that instead of dev.

@svenjacobs
Copy link

Sure, but I don't want to add a file to every project that my colleagues don't need 😉 Of course I could add the file to the global .gitignore but as I said a native solution would be much appreciated 😃

@JanPokorny
Copy link

@svenjacobs The snippet I posted above adds the file to a local ignore file .git/info/exclude

@mxcl mxcl transferred this issue from pkgxdev/pkgx Jan 15, 2025
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

5 participants