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

Ability to use existing shell for commands and git actions #899

Open
lordlycastle opened this issue Jul 16, 2020 · 5 comments
Open

Ability to use existing shell for commands and git actions #899

lordlycastle opened this issue Jul 16, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@lordlycastle
Copy link

Is your feature request related to a problem? Please describe.
If you have a git hook before push/commit and it depends on a certain tool e.g. node then it is best to use the current shell.

For example I have nvm and various node versions. In the git hook it runs tests using node and it expects a certain version. I load the correct version by nvm use v8 but lazygit still complains about wrong version and stops all the commits and pushes. That is because I image it is running in a separate shell like when you run custom commands, and in that shell nvm never switched to required version.

This is the same issue when you run custom commands, it runs bash -c .... Firstly now you need to format your commands for bash instead of default shell/current shell which is very annoying (especially for fish users where syntax is different). And you cannot use local variables, and some time even all commands as you might not have updated .bashrc to include all paths that are there in your current/default shell; since you never use it.

Describe the solution you'd like
Run all custom commands and git commands in current shell process.

Describe alternatives you've considered
Alternative is using git directly from current shell and not using lazygit.

@lordlycastle lordlycastle added the enhancement New feature or request label Jul 16, 2020
@jesseduffield
Copy link
Owner

I briefly looked into this a while back but couldn't find a way to carry over the state of the shell environment into the program. I think it's a security thing, though my memory is hazy on it. Perhaps there's a way to initialize a new shell from within lazygit, however that wouldn't be able to carry over variables defined on the outside

@jesseduffield
Copy link
Owner

jesseduffield commented Apr 6, 2021

I think we can get halfway there by letting the user specify which shell to use. It means you won't have access to local variables but you'll get access to your rc file for example (I think)

@lordlycastle
Copy link
Author

lordlycastle commented Apr 26, 2021

I wonder if that'll work with nvm because you need to do nvm use but it would certainly be a good step forward to be able to specify a shell. The shells can be hooks like you say to do these actions before running the custom command. This would be a good feature regardless! 💯

It is the hooks that need the custom environment. We chose not to include nvm use etc. in hooks because people use different tools to manager versions. This is sadly true for most other languages. So it is on the user to "be" in the right env for the git hooks.

Can we maybe use the same shell for all custom command and hooks? Because then user can do it normally in two commands e.g. nvm use and then Commit action that will run the hooks' tests in same shell which is using the correct version of tool 🤔 ... totally a random idea.

What about lazygit runs the hooks in the same env as the shell it was launched in so the user has the responsibility to do nvm use before launching lazygit. And then hooks should run fine.

Is there an argument to run the custom commands in the same env as well? It would create consistent experience and would remove the need for the feature mentioned above.

@PeterPCardenas
Copy link

Wanting this too, fish will automatically source the config on restart, so as long as the variables are set there should be ok?

@GeorgiChochev
Copy link

GeorgiChochev commented Mar 15, 2024

I recently ran into that issue so don't mind me just bumping for visibility.

Looks like there is a promising PR on the horizon #3299

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

No branches or pull requests

4 participants