-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Comments
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 |
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) |
I wonder if that'll work with It is the hooks that need the custom environment. We chose not to include
What about 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. |
Wanting this too, |
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 |
- **PR Description** When executing an interactive custom command, use the user's shell rather than "bash", and pass the -i flag. This makes it possible to use shell aliases or shell functions which are not available in non-interactive shells. In previous attempts to solve this, concerns were brought up: [this one](#2096 (comment)) is addressed by using the interactive shell only for custom commands but not anything else. [This one](#2096 (comment)) is a little dubious and unconfirmed, so I'm not very worried about it. Supersedes #2096 and #3299. Fixes #770, #899, and #1642.
Fixed by #3793. |
Hello. I have stumbled upon this thread when I was trying to make lazygit open the file in neovim (which is aliased in my .zshrc file). I built the project from source because I saw that the last release was pretty old. My default shell is zsh, and I also added logs in the code here: lazygit/pkg/commands/oscommands/os_default_platform.go Lines 23 to 28 in 05ae080
and the correct shell is logged, but the command still uses bash. As a workaround I've changed the edit command with the full path to nvim in the config file, but I'd like to make this work. I'd appreciate it if someone could help me 🙏 |
The fix in #3793 only affects commands typed at the
I wouldn't call that a workaround, this seems like the appropriate solution to me. What's wrong with it?
What's missing for that? |
Oh.
Nothing wrong necessarily but I was hoping I could force lazygit to use zsh and load my .zshrc when using commands such as edit. I share my configs with my linux machine as well and wanted to use the alias for nvim instead of hardcoding the full path to the binary. |
@NeaGogu if you export the |
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 bynvm 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 shellnvm
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 forfish
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 usinglazygit
.The text was updated successfully, but these errors were encountered: