Features: - Vertical tabs sidebar with SwiftUI - Terminal emulation via GhosttyKit.xcframework (libghostty) - Keyboard shortcuts: Cmd+T/N, Ctrl+Shift+` (new tab), Cmd+W (close), Cmd+Shift+[/], Ctrl+Tab (navigation), Cmd+1-9 (jump to tab) - Reads Ghostty config from ~/Library/Application Support/com.mitchellh.ghostty/config - Metal-based rendering
74 lines
2.3 KiB
Swift
74 lines
2.3 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct GhosttyTabsApp: App {
|
|
@StateObject private var tabManager = TabManager()
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.environmentObject(tabManager)
|
|
}
|
|
.windowStyle(.hiddenTitleBar)
|
|
.commands {
|
|
// New tab commands
|
|
CommandGroup(replacing: .newItem) {
|
|
Button("New Tab") {
|
|
tabManager.addTab()
|
|
}
|
|
.keyboardShortcut("t", modifiers: .command)
|
|
|
|
Button("New Tab") {
|
|
tabManager.addTab()
|
|
}
|
|
.keyboardShortcut("n", modifiers: .command)
|
|
|
|
Button("New Tab") {
|
|
tabManager.addTab()
|
|
}
|
|
.keyboardShortcut("`", modifiers: [.control, .shift])
|
|
}
|
|
|
|
// Close tab
|
|
CommandGroup(after: .newItem) {
|
|
Button("Close Tab") {
|
|
tabManager.closeCurrentTab()
|
|
}
|
|
.keyboardShortcut("w", modifiers: .command)
|
|
}
|
|
|
|
// Tab navigation
|
|
CommandGroup(after: .toolbar) {
|
|
Button("Next Tab") {
|
|
tabManager.selectNextTab()
|
|
}
|
|
.keyboardShortcut("]", modifiers: [.command, .shift])
|
|
|
|
Button("Previous Tab") {
|
|
tabManager.selectPreviousTab()
|
|
}
|
|
.keyboardShortcut("[", modifiers: [.command, .shift])
|
|
|
|
Button("Next Tab") {
|
|
tabManager.selectNextTab()
|
|
}
|
|
.keyboardShortcut(.tab, modifiers: .control)
|
|
|
|
Button("Previous Tab") {
|
|
tabManager.selectPreviousTab()
|
|
}
|
|
.keyboardShortcut(.tab, modifiers: [.control, .shift])
|
|
|
|
Divider()
|
|
|
|
// Cmd+1 through Cmd+9 for tab selection
|
|
ForEach(1...9, id: \.self) { number in
|
|
Button("Tab \(number)") {
|
|
tabManager.selectTab(at: number - 1)
|
|
}
|
|
.keyboardShortcut(KeyEquivalent(Character("\(number)")), modifiers: .command)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|