-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add option to specify other shell(Arg) #3299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I tested it out, and it seems to work as advertised. Left a couple of comments that I think could help.
pkg/gui/gui.go
Outdated
shell := gui.UserConfig.OS.Shell | ||
if shell != "" { | ||
osCommand.Platform.Shell = shell | ||
osCommand.Platform.ShellArg = gui.UserConfig.OS.ShellArg | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to move this logic into NewOsCommand
? We want all os commands to inherit that setting, right? Or do we only want the command runner for custom commands to use the shell
and shellArgs
from the userconfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I don't know how to access config.OS from there, though 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I think it would make more sense to pass the OSConfig
struct into oscommands.GetPlatform
and get that function to extract the shell
and shellArg
values from there and use them there directly.
Sounds good. I don't know how to access config.OS from there, though 😕
You would be able to access the config through the Common
struct that's passed into NewOsCommand
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, but perhaps an integration test is not the right thing for this feature? Maybe this should just be a unit test in pkg/commands/oscommands/os_test.go
schema/config.json
Outdated
}, | ||
"shell": { | ||
"type": "string", | ||
"description": "Shell and ShellArg are the shell and corresponding argument to be used for executing custom commands.\nSee https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-command-for-copying-to-clipboard" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL here needs to point to the "Custom Shell for executing arbitrary commands" section of the Config.md
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Just one last comment.
if osConfig.Shell != "" { | ||
platform.Shell = osConfig.Shell | ||
platform.ShellArg = osConfig.ShellArg | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at this point, we should probably just consider setting bash
and -c
as default parameters for Shell
and ShellArg
in the user_config
file. That way, we can just directly take the values from osConfig
and use them in the Platform
literal.
@J-Kappes Hi there, I hope you're doing well. I wanted to check on the status of your PR for the feature we've been eagerly awaiting. Are you still able to work on it? If you're too busy, I'd be happy to help move it forward. No pressure either way - just let me know what works best for you. Thanks for your efforts on this! |
Oh, yes, I'm fine. I'm happy with the feature itself but I don't intend on finishing the test tbh. |
I just looked at this for the first time in more detail. I like the feature and would like to have it myself. As I said in #3749 though, I'd prefer it if we could have this automatically with no user config, like in #2096. If people want to spend more effort on this topic, I think it would be a good idea to first spend some more time to research what was the problem with #2096 (I don't remember, and don't have time to invest in that right now myself). Another thought: currently, the NewShell function that is being modified here is used for a ton of things, including opening files in an editor, opening links, cop&paste, updating the window title on Windows, and others. I think it could be a good idea to use the And finally: if we do take the approach of this PR, then I would like to wait with finishing the PR until #3787 is done, and find ways to make the new config hot-reloadable, which it currently isn't. See d3c91ac. |
I agree: custom commands typically commands you would otherwise run in your shell, so using |
@stefanhaller I tested it. It's just what I want.👍🏼 |
I haven't tried it but the description sounds exaclty like what I want: being able to use my fish abbreviations. |
- **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.
Closing, superseded by #3793. |
PR Description
if
os.shell
is not empty it replaces the default"bash"
shell andos.shellArg
replaces the default"-c"
argument.started writing test but don't know how to check stdout or command log.
Please check if the PR fulfills these requirements
go generate ./...
)docs/Config.md
) have been updated if necessary