Skip to content

Commit 8a9286a

Browse files
committed
feat(core): add Open in Terminal to project menu
1 parent acbee40 commit 8a9286a

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
@@ -158,7 +158,8 @@ pub fn build<R: Runtime>(
158158
.build(handle)?,
159159
)
160160
.separator()
161-
.text("project/open-in-vscode", "Open in Editor");
161+
.text("project/open-in-vscode", "Open in Editor")
162+
.text("project/open-in-terminal", "Open in Terminal");
162163

163164
#[cfg(target_os = "macos")]
164165
{
@@ -322,6 +323,11 @@ pub fn handle_event<R: Runtime>(
322323
return;
323324
}
324325

326+
if event.id() == "project/open-in-terminal" {
327+
emit(webview, SHORTCUT_EVENT, "open-in-terminal");
328+
return;
329+
}
330+
325331
if event.id() == "project/show-in-finder" {
326332
emit(webview, SHORTCUT_EVENT, "show-in-finder");
327333
return;

0 commit comments

Comments
 (0)