Skip to content

Commit 4146189

Browse files
committed
ghostty: fix more flags
1 parent 9b6319e commit 4146189

File tree

2 files changed

+105
-28
lines changed
  • completers/common/ghostty_completer/cmd
  • pkg/actions/tools/ghostty

2 files changed

+105
-28
lines changed

completers/common/ghostty_completer/cmd/root.go

Lines changed: 82 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"github.com/carapace-sh/carapace"
55
"github.com/carapace-sh/carapace-bin/pkg/actions/color"
6+
"github.com/carapace-sh/carapace-bin/pkg/actions/env"
67
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/ghostty"
78
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
89
"github.com/carapace-sh/carapace/pkg/style"
@@ -80,6 +81,7 @@ func addConfigs(cmd *cobra.Command) {
8081
cmd.Flags().Bool("clipboard-trim-trailing-spaces", false, "Trims trailing whitespace on data that is copied to the clipboard")
8182
cmd.Flags().String("clipboard-write", "", "Whether to allow programs running in the terminal to write to the system clipboard")
8283
cmd.Flags().String("command", "", "The command to run, usually a shell")
84+
cmd.Flags().StringArray("command-palette-entry", nil, "Custom entries into the command palette")
8385
cmd.Flags().Bool("config-default-files", false, "When this is true, the default configuration file paths will be loaded")
8486
cmd.Flags().StringArray("config-file", nil, "Additional configuration files to read")
8587
cmd.Flags().Bool("confirm-close-surface", false, "Confirms that a surface should be closed before closing it")
@@ -94,27 +96,32 @@ func addConfigs(cmd *cobra.Command) {
9496
cmd.Flags().String("custom-shader-animation", "", "Controls when custom shaders are animated")
9597
cmd.Flags().Bool("desktop-notifications", false, "bool")
9698
cmd.Flags().String("enquiry-response", "", "String to send when we receive `ENQ` (`0x05`) from the command that we are running")
99+
cmd.Flags().StringArray("env", nil, "Extra environment variables to pass to commands launched in a terminal surface")
100+
cmd.Flags().String("faint-opacity", "", "The opacity level (opposite of transparency) of the faint text")
97101
cmd.Flags().Bool("focus-follows-mouse", false, "If true, when there are multiple split panes, the mouse selects the pane that is focused")
98102
cmd.Flags().StringArray("font-codepoint-map", nil, "Force one or a range of Unicode codepoints to map to a specific named font")
99103
cmd.Flags().StringArray("font-family", nil, "The font families to use")
100104
cmd.Flags().StringArray("font-family-bold", nil, "The font families to use for bold")
101105
cmd.Flags().StringArray("font-family-bold-italic", nil, "The font families to use for bold italic")
102106
cmd.Flags().StringArray("font-family-italic", nil, "The font families to use for italic")
103107
cmd.Flags().StringArray("font-feature", nil, "Apply a font feature")
108+
cmd.Flags().String("font-shaping-break", "", "Locations to break font shaping into multiple runs")
104109
cmd.Flags().String("font-size", "", "Font size in points")
105110
cmd.Flags().String("font-style", "", "The named font style to use")
106111
cmd.Flags().String("font-style-bold", "", "The named font style to use for bold")
107112
cmd.Flags().String("font-style-bold-italic", "", "The named font style to use for bold italic")
108113
cmd.Flags().String("font-style-italic", "", "The named font style to use for italic")
109114
cmd.Flags().String("font-synthetic-style", "", "Control whether Ghostty should synthesize a style if the requested style is not available")
110115
cmd.Flags().Bool("font-thicken", false, "Draw fonts with a thicker stroke")
116+
cmd.Flags().String("font-thicken-strength", "", "Strength of thickening when `font-thicken` is enabled")
111117
cmd.Flags().StringArray("font-variation", nil, "Set font variation")
112118
cmd.Flags().StringArray("font-variation-bold", nil, "Set font variation for bold")
113119
cmd.Flags().StringArray("font-variation-bold-italic", nil, "Set font variation for bold-italic")
114120
cmd.Flags().StringArray("font-variation-italic", nil, "Set font variation for italic")
121+
cmd.Flags().String("foreground", "", "Foreground color for the window")
115122
cmd.Flags().String("freetype-load-flags", "", "FreeType load flags to enable")
123+
cmd.Flags().Bool("fullscreen", false, "Start new windows in fullscreen")
116124
cmd.Flags().String("grapheme-width-method", "", "The method to use for calculating the cell width of a grapheme cluster")
117-
cmd.Flags().Bool("gtk-adwaita", false, "Adwaita theme support")
118125
cmd.Flags().String("gtk-single-instance", "", "Run in single-instance mode")
119126
cmd.Flags().String("gtk-tabs-location", "", "Determines the side of the screen that the GTK tab bar will stick to")
120127
cmd.Flags().Bool("gtk-titlebar", false, "Display the full GTK titlebar")
@@ -123,6 +130,8 @@ func addConfigs(cmd *cobra.Command) {
123130
cmd.Flags().String("image-storage-limit", "", "The total amount of bytes that can be used for image data")
124131
cmd.Flags().String("initial-command", "", "This is the same as \"command\", but only applies to the first terminal surface created")
125132
cmd.Flags().Bool("initial-window", false, "Create an initial window when Ghostty is run")
133+
cmd.Flags().String("input", "", "Data to send as input to the command on startup")
134+
cmd.Flags().Bool("link-previews", false, "Show link previews for a matched URL")
126135
cmd.Flags().Bool("link-url", false, "Enable URL matching")
127136
cmd.Flags().String("linux-cgroup", "", "Put every surface (tab, split, window) into a dedicated Linux cgroup")
128137
cmd.Flags().Bool("linux-cgroup-hard-fail", false, "Let cgroup initialization failure cause exit")
@@ -146,18 +155,23 @@ func addConfigs(cmd *cobra.Command) {
146155
cmd.Flags().String("osc-color-report-format", "", "Sets the reporting format for OSC sequences that request color information")
147156
cmd.Flags().String("quick-terminal-animation-duration", "", "Duration (in seconds) of the quick terminal enter and exit animation")
148157
cmd.Flags().Bool("quick-terminal-autohide", false, "Automatically hide the quick terminal when focus shifts to another window")
158+
cmd.Flags().String("quick-terminal-keyboard-interactivity", "", "Determines under which circumstances that the quick terminal should receive keyboard input")
149159
cmd.Flags().String("quick-terminal-position", "", "The position of the \"quick\" terminal window")
150160
cmd.Flags().String("quick-terminal-screen", "", "The screen where the quick terminal should show up")
151161
cmd.Flags().Bool("quit-after-last-window-closed", false, "Whether or not to quit after the last surface is closed")
152162
cmd.Flags().String("quit-after-last-window-closed-delay", "", "Controls how long Ghostty will stay running after the last open surface has been closed")
153163
cmd.Flags().String("resize-overlay", "", "Controls when resize overlays are shown")
154164
cmd.Flags().String("resize-overlay-duration", "", "Controls how long the overlay is visible on the screen before it is hidde")
155165
cmd.Flags().String("resize-overlay-position", "", "Controls the position of the overlay")
166+
cmd.Flags().String("scroll-to-bottom", "", "When to scroll the surface to the bottom")
156167
cmd.Flags().String("scrollback-limit", "", "The size of the scrollback buffer in bytes")
157168
cmd.Flags().String("selection-background", "", "The background color for selection")
158169
cmd.Flags().String("selection-foreground", "", "The foreground color for selection")
159170
cmd.Flags().String("shell-integration", "", "Whether to enable shell integration auto-injection or not")
160171
cmd.Flags().String("shell-integration-features", "", "Shell integration features to enable")
172+
cmd.Flags().String("split-divider-color", "", "The color of the split divider")
173+
cmd.Flags().String("theme", "", "A theme to use")
174+
cmd.Flags().String("title", "", "The title Ghostty will use for the window")
161175
cmd.Flags().String("unfocused-split-fill", "", "The color to dim the unfocused split")
162176
cmd.Flags().String("unfocused-split-opacity", "", "The opacity level (opposite of transparency) of an unfocused split")
163177
cmd.Flags().Bool("vt-kam-allowed", false, "Allows the \"KAM\" mode")
@@ -172,6 +186,8 @@ func addConfigs(cmd *cobra.Command) {
172186
cmd.Flags().String("window-padding-color", "", "The color of the padding area of the window")
173187
cmd.Flags().String("window-padding-x", "", "Horizontal window padding")
174188
cmd.Flags().String("window-padding-y", "", "Vertical window padding")
189+
cmd.Flags().String("window-position-x", "", "The starting window position")
190+
cmd.Flags().String("window-position-y", "", "The starting window position")
175191
cmd.Flags().String("window-save-state", "", "Whether to enable saving and restoring window state")
176192
cmd.Flags().Bool("window-step-resize", false, "Resize the window in discrete increments of the focused surface's cell size")
177193
cmd.Flags().String("window-theme", "", "The theme to use for the windows")
@@ -222,6 +238,7 @@ func addConfigs(cmd *cobra.Command) {
222238
"cursor-text": color.ActionHexColors(),
223239
"custom-shader": carapace.ActionFiles(),
224240
"custom-shader-animation": ghostty.ActionShaderAnimationModes(),
241+
"env": env.ActionNameValues(false),
225242
"font-codepoint-map": carapace.ActionMultiPartsN("=", 2, func(c carapace.Context) carapace.Action {
226243
switch len(c.Parts) {
227244
case 0:
@@ -230,11 +247,14 @@ func addConfigs(cmd *cobra.Command) {
230247
return ghostty.ActionFontFamilies()
231248
}
232249
}),
233-
"font-family": ghostty.ActionFontFamilies(),
234-
"font-family-bold": ghostty.ActionFontFamilies(),
235-
"font-family-bold-italic": ghostty.ActionFontFamilies(),
236-
"font-family-italic": ghostty.ActionFontFamilies(),
237-
"font-feature": carapace.ActionValues(), // TODO font-features
250+
"font-family": ghostty.ActionFontFamilies(),
251+
"font-family-bold": ghostty.ActionFontFamilies(),
252+
"font-family-bold-italic": ghostty.ActionFontFamilies(),
253+
"font-family-italic": ghostty.ActionFontFamilies(),
254+
"font-feature": carapace.ActionValues(), // TODO font-features
255+
"font-shaping-break": carapace.ActionValuesDescribed(
256+
"cursor", "Break runs under the cursor",
257+
),
238258
"font-style": carapace.ActionValues(), // TODO font style
239259
"font-style-bold": carapace.ActionValues(), // TODO font style
240260
"font-style-bold-italic": carapace.ActionValues(), // TODO font style
@@ -244,12 +264,32 @@ func addConfigs(cmd *cobra.Command) {
244264
"font-variation-bold": carapace.ActionValues(), // TODO font variation
245265
"font-variation-bold-italic": carapace.ActionValues(), // TODO font variation
246266
"font-variation-italic": carapace.ActionValues(), // TODO font variation
247-
"freetype-load-flags": ghostty.ActionFreetypeLoadFlags().UniqueList(","),
248-
"grapheme-width-method": ghostty.ActionGraphemeWidthMethods(),
249-
"gtk-single-instance": carapace.ActionValues("true", "false", "detect").StyleF(style.ForKeyword),
250-
"gtk-tabs-location": carapace.ActionValues("top", "bottom", "left", "right", "hidden"),
251-
"gtk-toolbar-style": ghostty.ActionGtkToolbarStyles(),
252-
"initial-command": bridge.ActionCarapaceBin().Split(),
267+
"foreground": carapace.Batch(
268+
color.ActionHexColors(),
269+
color.ActionXtermColorNames(),
270+
).ToA(),
271+
"freetype-load-flags": ghostty.ActionFreetypeLoadFlags().UniqueList(","),
272+
"grapheme-width-method": ghostty.ActionGraphemeWidthMethods(),
273+
"gtk-single-instance": carapace.ActionValues("true", "false", "detect").StyleF(style.ForKeyword),
274+
"gtk-tabs-location": carapace.ActionValues("top", "bottom", "left", "right", "hidden"),
275+
"gtk-toolbar-style": ghostty.ActionGtkToolbarStyles(),
276+
"initial-command": bridge.ActionCarapaceBin().Split(),
277+
"input": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action {
278+
switch len(c.Parts) {
279+
case 0:
280+
return carapace.ActionValuesDescribed(
281+
"raw", "Send raw text as-is",
282+
"path", "Read a filepath and send the contents",
283+
).Suffix(":")
284+
default:
285+
switch c.Parts[0] {
286+
case "path":
287+
return carapace.ActionFiles()
288+
default:
289+
return carapace.ActionValues()
290+
}
291+
}
292+
}),
253293
"linux-cgroup": carapace.ActionValuesDescribed(
254294
"never", "Never use cgroups",
255295
"always", "Always use cgroups",
@@ -265,21 +305,35 @@ func addConfigs(cmd *cobra.Command) {
265305
"macos-titlebar-style": ghostty.ActionMacTitlebarStyles(),
266306
"mouse-shift-capture": ghostty.ActionMouseShiftCaptureModes(),
267307
"osc-color-report-format": ghostty.ActionOscColorReportFormats(),
268-
"quick-terminal-position": ghostty.ActionQuickTerminalPositions(),
269-
"quick-terminal-screen": ghostty.ActionQuickTerminalScreens(),
270-
"resize-overlay": ghostty.ActionResizeOverlayModes(),
271-
"resize-overlay-position": ghostty.ActionResizeOverlayPositions(),
272-
"selection-background": color.ActionHexColors(),
273-
"selection-foreground": color.ActionHexColors(),
274-
"shell-integration": ghostty.ActionShellIntegrationModes(),
275-
"shell-integration-features": ghostty.ActionShellIntegrationFeatures().UniqueList(","),
276-
"unfocused-split-fill": color.ActionXtermColorNames(),
277-
"window-colorspace": carapace.ActionValues("srgb", "display-p3"),
278-
"window-new-tab-position": ghostty.ActionWindowNewTabPositions(),
279-
"window-padding-color": ghostty.ActionWindowPaddingColors(),
280-
"window-save-state": ghostty.ActionWindowSaveStates(),
281-
"window-theme": ghostty.ActionWindowThemes(),
282-
"window-title-font-family": ghostty.ActionFontFamilies(),
283-
"working-directory": carapace.ActionDirectories(),
308+
"quick-terminal-keyboard-interactivity": carapace.ActionValuesDescribed(
309+
"none", "The quick terminal will not receive any keyboard input",
310+
"on-demand", "The quick terminal would only receive keyboard input when it is focused",
311+
"exclusive", "The quick terminal will always receive keyboard input",
312+
).StyleF(style.ForKeyword),
313+
"quick-terminal-position": ghostty.ActionQuickTerminalPositions(),
314+
"quick-terminal-screen": ghostty.ActionQuickTerminalScreens(),
315+
"resize-overlay": ghostty.ActionResizeOverlayModes(),
316+
"resize-overlay-position": ghostty.ActionResizeOverlayPositions(),
317+
"scroll-to-bottom": carapace.ActionValuesDescribed(
318+
"keystroke", "scroll the surface to the bottom when the user presses a key",
319+
"output", "scroll the surface to the bottom if there is new data to display",
320+
).UniqueList(","),
321+
"selection-background": color.ActionHexColors(),
322+
"selection-foreground": color.ActionHexColors(),
323+
"shell-integration": ghostty.ActionShellIntegrationModes(),
324+
"shell-integration-features": ghostty.ActionShellIntegrationFeatures().UniqueList(","),
325+
"split-divider-color": carapace.Batch(
326+
color.ActionHexColors(),
327+
color.ActionXtermColorNames(),
328+
).ToA(),
329+
"theme": ghostty.ActionThemes(),
330+
"unfocused-split-fill": color.ActionXtermColorNames(),
331+
"window-colorspace": carapace.ActionValues("srgb", "display-p3"),
332+
"window-new-tab-position": ghostty.ActionWindowNewTabPositions(),
333+
"window-padding-color": ghostty.ActionWindowPaddingColors(),
334+
"window-save-state": ghostty.ActionWindowSaveStates(),
335+
"window-theme": ghostty.ActionWindowThemes(),
336+
"window-title-font-family": ghostty.ActionFontFamilies(),
337+
"working-directory": carapace.ActionDirectories(),
284338
})
285339
}

pkg/actions/tools/ghostty/theme.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ghostty
2+
3+
import (
4+
"strings"
5+
6+
"github.com/carapace-sh/carapace"
7+
)
8+
9+
// ActionThemes completes themes
10+
//
11+
// Atom
12+
// Ayu
13+
func ActionThemes() carapace.Action {
14+
return carapace.ActionExecCommand("ghostty", "+list-themes")(func(output []byte) carapace.Action {
15+
lines := strings.Split(string(output), "\n")
16+
17+
vals := make([]string, 0)
18+
for _, line := range lines {
19+
vals = append(vals, strings.Split(line, " (")[0])
20+
}
21+
return carapace.ActionValues(vals...)
22+
}).Tag("themes")
23+
}

0 commit comments

Comments
 (0)