-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 a editor FileSystem dock action to open a terminal in selected folder #85923
Add a editor FileSystem dock action to open a terminal in selected folder #85923
Conversation
// Silence command name being printed when found. (stderr is already silenced by `OS::execute()` by default.) | ||
// FIXME: This doesn't appear to silence stdout. | ||
test_args.push_back(">"); | ||
test_args.push_back("/dev/null"); |
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 haven't been able to resolve this yet. Note that this output only appears in the terminal's stdout when running Godot from a terminal, not in the editor Output panel.
// Prepend default arguments based on the terminal emulator name. | ||
// Use `String.get_basename().to_lower()` to handle Windows' case-insensitive paths | ||
// with optional file extensions for executables in `PATH`. | ||
if (chosen_terminal_emulator.get_basename().to_lower() == "powershell") { |
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.
This could also be equal to pwsh
, if the user has a newer version of Powershell (i.e. "Powershell Core" in addition to "Windows Powershell") installed. Same command line arguments would apply.
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 Windows itself still calls powershell
by default (in the Windows + X menu for instance), but you should be able to specify pwsh
in the custom terminal name editor setting. I can modify the class reference accordingly.
15e8505
to
b292a96
Compare
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 implementation looks ok on the editor side, can't say much about the FILE_OPEN_IN_TERMINAL code, as there is lots of platform-specific stuff happening in there.
Personally I'm indifferent to the feature. If I need git I just open the project in VS Code, which comes with its own terminal. Also from what I understand, this option is mostly useful in project's root folder, so it could be "Open Project in Terminal" in the Project menu instead of making the file menu longer. But well, either way is fine.
b292a96
to
e17a29c
Compare
I force-pushed to fix a typo in the commit message; no other changes were made. |
Can confirm that this works on Windows 11 with PowerShell, both for folders and files (open containing folder) |
…lder This is useful to enter some commands without having to open a separate terminal and `cd` to the project folder.
e17a29c
to
0e97acf
Compare
Thanks! |
I'm a bit late to the party, but I would have suggested adding another really useful option for Windows: It would be pretty useful, as we would have access to all Windows shell extensions just right there. This idea comes from TortoiseGit: The function to call would be SHCreateDefaultContextMenu ( https://learn.microsoft.com/es-es/windows/win32/api/shlobj_core/nf-shlobj_core-shcreatedefaultcontextmenu ) but, after having a look into it, seems that it is not an easy task. |
This is useful to enter some commands without having to open a separate terminal and
cd
to the project folder.Tested on:
Paths with spaces have been tested in all scenarios listed above and are confirmed to be working.
Testing on more Linux terminal emulators is welcome.
Preview