Skip to content

Commit 783ae33

Browse files
committed
feat(core): add Open in Terminal to project menu
1 parent c24b0d0 commit 783ae33

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

apps/desktop/src/components/ProjectSettingsMenuAction.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { historyPath } from '$lib/routes/routes.svelte';
77
import { SETTINGS } from '$lib/settings/userSettings';
88
import { SHORTCUT_SERVICE } from '$lib/shortcuts/shortcutService';
9-
import { getEditorUri, openExternalUrl, showFileInFolder } from '$lib/utils/url';
9+
import { getEditorUri, openExternalUrl, showFileInFolder, openInTerminal } from '$lib/utils/url';
1010
import { inject } from '@gitbutler/shared/context';
1111
import { mergeUnlisten } from '@gitbutler/ui/utils/mergeUnlisten';
1212
@@ -38,6 +38,13 @@
3838
})
3939
);
4040
}),
41+
shortcutService.on('open-in-terminal', async () => {
42+
const project = await projectsService.fetchProject(projectId);
43+
if (!project) {
44+
throw new Error(`Project not found: ${projectId}`);
45+
}
46+
await openInTerminal($userSettings.defaultTerminal.appName, vscodePath(project.path));
47+
}),
4148
shortcutService.on('show-in-finder', async () => {
4249
const project = await projectsService.fetchProject(projectId);
4350
if (!project) {

apps/desktop/src/lib/utils/url.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ export function getEditorUri(params: EditorUriParams): string {
5151

5252
return `${params.schemeId}://file${pathString}${positionSuffix}${searchSuffix}`;
5353
}
54+
55+
export async function openInTerminal(appName: string, path: string) {
56+
await invoke<void>('open_in_terminal', { appName, path });
57+
}

crates/gitbutler-tauri/src/menu.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ pub fn build<R: Runtime>(handle: &AppHandle<R>) -> tauri::Result<tauri::menu::Me
144144
.build(handle)?,
145145
)
146146
.separator()
147-
.text("project/open-in-vscode", "Open in Editor");
147+
.text("project/open-in-vscode", "Open in Editor")
148+
.text("project/open-in-terminal", "Open in Terminal");
148149

149150
#[cfg(target_os = "macos")]
150151
{
@@ -295,6 +296,11 @@ pub fn handle_event(webview: &WebviewWindow, event: &MenuEvent) {
295296
return;
296297
}
297298

299+
if event.id() == "project/open-in-terminal" {
300+
emit(webview, SHORTCUT_EVENT, "open-in-terminal");
301+
return;
302+
}
303+
298304
if event.id() == "project/show-in-finder" {
299305
emit(webview, SHORTCUT_EVENT, "show-in-finder");
300306
return;

0 commit comments

Comments
 (0)