77 "github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
88 "github.com/carapace-sh/carapace/pkg/style"
99 "github.com/spf13/cobra"
10+ "github.com/spf13/pflag"
1011)
1112
1213var rootCmd = & cobra.Command {
@@ -21,51 +22,70 @@ func Execute() error {
2122}
2223func init () {
2324 carapace .Gen (rootCmd ).Standalone ()
25+ rootCmd .Flags ().SetInterspersed (false )
2426
25- rootCmd .Flags ().StringS ("e" , "e" , "" , "run command" )
27+ rootCmd .Flags ().BoolS ("e" , "e" , false , "run command" ) // if set positional arguments accept a command
2628 rootCmd .Flags ().Bool ("help" , false , "show help" )
2729 rootCmd .Flags ().Bool ("version" , false , "show version" )
2830 addConfigs (rootCmd )
2931
30- carapace .Gen (rootCmd ).FlagCompletion (carapace.ActionMap {
31- "e" : bridge .ActionCarapaceBin ().Split (),
32- })
32+ carapace .Gen (rootCmd ).PositionalAnyCompletion (
33+ carapace .ActionCallback (func (c carapace.Context ) carapace.Action {
34+ if rootCmd .Flag ("e" ).Changed {
35+ return bridge .ActionCarapaceBin ()
36+ }
37+ return carapace .ActionValues ()
38+ }),
39+ )
3340}
3441
3542func addConfigs (cmd * cobra.Command ) {
36- cmd .Flags ().Bool ("_xdg-terminal-exec" , false , "Set to true if Ghostty was executed as xdg-terminal-exec on Linux" )
3743 cmd .Flags ().String ("abnormal-command-exit-runtime" , "" , "The number of milliseconds of runtime below which we consider a process exit to be abnormal" )
3844 cmd .Flags ().String ("adjust-box-thickness" , "" , "Thickness in pixels of box drawing characters" )
3945 cmd .Flags ().String ("adjust-cell-height" , "" , "Height of the cell" )
4046 cmd .Flags ().String ("adjust-cell-width" , "" , "Witdth of the cell" )
4147 cmd .Flags ().String ("adjust-cursor-height" , "" , "Height in pixels of the cursor" )
4248 cmd .Flags ().String ("adjust-cursor-thickness" , "" , "Thickness in pixels of the bar cursor and outlined rect cursor" )
4349 cmd .Flags ().String ("adjust-font-baseline" , "" , "Distance in pixels from the bottom of the cell to the text baseline" )
50+ cmd .Flags ().String ("adjust-icon-height" , "" , "Height in pixels or percentage adjustment of maximum height for nerd font icons" )
4451 cmd .Flags ().String ("adjust-overline-position" , "" , "Distance in pixels from the top of the cell to the top of the overline" )
4552 cmd .Flags ().String ("adjust-overline-thickness" , "" , "Thickness in pixels of the overline" )
4653 cmd .Flags ().String ("adjust-strikethrough-position" , "" , "Distance in pixels from the top of the cell to the top of the strikethrough" )
4754 cmd .Flags ().String ("adjust-strikethrough-thickness" , "" , "Thickness in pixels of the strikethrough" )
4855 cmd .Flags ().String ("adjust-underline-position" , "" , "Distance in pixels from the top of the cell to the top of the underline" )
4956 cmd .Flags ().String ("adjust-underline-thickness" , "" , "Thickness in pixels of the underline" )
50- cmd .Flags ().String ("adw-toolbar-style" , "" , "Determines the appearance of the top and bottom bars when using the Adwaita tab bar" )
57+ cmd .Flags ().String ("alpha-blending" , "" , "What color space to use when performing alpha blending" )
58+ cmd .Flags ().String ("app-notifications" , "" , "Control the in-app notifications that Ghostty shows" )
59+ cmd .Flags ().String ("async-backend" , "" , "Configures the low-level API to use for async IO, eventing, etc." )
5160 cmd .Flags ().String ("auto-update" , "" , "Control the auto-update functionality of Ghostty" )
5261 cmd .Flags ().String ("auto-update-channel" , "" , "The release channel to use for auto-updates" )
53- cmd .Flags ().String ("background-blur-radius" , "" , "A positive value enables blurring of the background when background-opacity is less than 1" )
62+ cmd .Flags ().String ("background" , "" , "Background color for the window" )
63+ cmd .Flags ().String ("background-blur" , "" , "Whether to blur the background when `background-opacity` is less than 1" )
64+ cmd .Flags ().String ("background-image" , "" , "Background image for the terminal" )
65+ cmd .Flags ().String ("background-image-fit" , "" , "Background image fit" )
66+ cmd .Flags ().String ("background-image-opacity" , "" , "Background image opacity" )
67+ cmd .Flags ().String ("background-image-position" , "" , "Background image position" )
68+ cmd .Flags ().Bool ("background-image-repeat" , false , "Whether to repeat the background image or not" )
5469 cmd .Flags ().String ("background-opacity" , "" , "The opacity level (opposite of transparency) of the background" )
55- cmd .Flags ().Bool ("bold-is-bright" , false , "If `true`, the bold text will use the bright color palette" )
70+ cmd .Flags ().Bool ("background-opacity-cells" , false , "Applies background opacity to cells with an explicit background color set" )
71+ cmd .Flags ().String ("bell-audio-path" , "" , "If `audio` is an enabled bell feature, this is a path to an audio file" )
72+ cmd .Flags ().String ("bell-audio-volume" , "" , "If `audio` is an enabled bell feature, this is the volume to play the audio file at" )
73+ cmd .Flags ().String ("bell-features" , "" , "Bell features to enable if bell support is available in your runtime" )
74+ cmd .Flags ().String ("bold-color" , "" , "Modifies the color used for bold text in the terminal" )
75+ cmd .Flags ().String ("class" , "" , "The setting that will change the application class value" )
5676 cmd .Flags ().String ("click-repeat-interval" , "" , "The time in milliseconds between clicks to consider a click a repeat" )
5777 cmd .Flags ().Bool ("clipboard-paste-bracketed-safe" , false , "If true, bracketed pastes will be considered safe" )
5878 cmd .Flags ().Bool ("clipboard-paste-protection" , false , "Require confirmation before pasting text that appears unsafe" )
5979 cmd .Flags ().String ("clipboard-read" , "" , "Whether to allow programs running in the terminal to read from the system clipboard" )
6080 cmd .Flags ().Bool ("clipboard-trim-trailing-spaces" , false , "Trims trailing whitespace on data that is copied to the clipboard" )
6181 cmd .Flags ().String ("clipboard-write" , "" , "Whether to allow programs running in the terminal to write to the system clipboard" )
82+ cmd .Flags ().String ("command" , "" , "The command to run, usually a shell" )
6283 cmd .Flags ().Bool ("config-default-files" , false , "When this is true, the default configuration file paths will be loaded" )
6384 cmd .Flags ().StringArray ("config-file" , nil , "Additional configuration files to read" )
6485 cmd .Flags ().Bool ("confirm-close-surface" , false , "Confirms that a surface should be closed before closing it" )
6586 cmd .Flags ().String ("copy-on-select" , "" , "Whether to automatically copy selected text to the clipboard" )
6687 cmd .Flags ().Bool ("cursor-click-to-move" , false , "Enables the ability to move the cursor at prompts" )
6788 cmd .Flags ().String ("cursor-color" , "" , "The color of the cursor" )
68- cmd .Flags ().Bool ("cursor-invert-fg-bg" , false , "Swap the foreground and background colors of the cell under the cursor" )
6989 cmd .Flags ().String ("cursor-opacity" , "" , "The opacity level (opposite of transparency) of the cursor" )
7090 cmd .Flags ().String ("cursor-style" , "" , "The style of the cursor" )
7191 cmd .Flags ().Bool ("cursor-style-blink" , false , "Sets the default blinking state of the cursor" )
@@ -98,6 +118,7 @@ func addConfigs(cmd *cobra.Command) {
98118 cmd .Flags ().String ("gtk-single-instance" , "" , "Run in single-instance mode" )
99119 cmd .Flags ().String ("gtk-tabs-location" , "" , "Determines the side of the screen that the GTK tab bar will stick to" )
100120 cmd .Flags ().Bool ("gtk-titlebar" , false , "Display the full GTK titlebar" )
121+ cmd .Flags ().Bool ("gtk-toolbar-style" , false , "Determines the appearance of the top and bottom bars tab bar" )
101122 cmd .Flags ().Bool ("gtk-wide-tabs" , false , "Use \" wide\" GTK tabs" )
102123 cmd .Flags ().String ("image-storage-limit" , "" , "The total amount of bytes that can be used for image data" )
103124 cmd .Flags ().String ("initial-command" , "" , "This is the same as \" command\" , but only applies to the first terminal surface created" )
@@ -135,7 +156,6 @@ func addConfigs(cmd *cobra.Command) {
135156 cmd .Flags ().String ("scrollback-limit" , "" , "The size of the scrollback buffer in bytes" )
136157 cmd .Flags ().String ("selection-background" , "" , "The background color for selection" )
137158 cmd .Flags ().String ("selection-foreground" , "" , "The foreground color for selection" )
138- cmd .Flags ().Bool ("selection-invert-fg-bg" , false , "Swap the foreground and background colors of cells for selection" )
139159 cmd .Flags ().String ("shell-integration" , "" , "Whether to enable shell integration auto-injection or not" )
140160 cmd .Flags ().String ("shell-integration-features" , "" , "Shell integration features to enable" )
141161 cmd .Flags ().String ("unfocused-split-fill" , "" , "The color to dim the unfocused split" )
@@ -161,13 +181,40 @@ func addConfigs(cmd *cobra.Command) {
161181 cmd .Flags ().String ("working-directory" , "" , "The directory to change to after starting the command" )
162182 cmd .Flags ().String ("x11-instance-name" , "" , "This controls the instance name field of the `WM_CLASS` X11 property" )
163183
184+ cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
185+ if f .Value .Type () != "bool" {
186+ f .NoOptDefVal = " " // flag arguments need to be passed in attached mode
187+ }
188+ })
189+
164190 // TODO use font-families from `+list-fonts`?
165191 carapace .Gen (cmd ).FlagCompletion (carapace.ActionMap {
166- "adw-toolbar-style" : ghostty .ActionAdwToolbarStyles (),
167- "auto-update" : ghostty .ActionAutoUpdateModes (),
168- "auto-update-channel" : ghostty .ActionReleaseChannels (),
192+ "alpha-blending" : ghostty .ActionAlphaBlendings (),
193+ "app-notifications" : ghostty .ActionNotifications ().UniqueList ("," ),
194+ "async-backend" : ghostty .ActionAsyncBackends (),
195+ "auto-update" : ghostty .ActionAutoUpdateModes (),
196+ "auto-update-channel" : ghostty .ActionReleaseChannels (),
197+ "background" : carapace .Batch (
198+ color .ActionHexColors (),
199+ color .ActionXtermColorNames (),
200+ ).ToA (),
201+ "background-blur" : carapace .ActionValuesDescribed (
202+ "false" , "equivalent to a blur intensity of 0" ,
203+ "true" , "equivalent to the default blur intensity of 20" ,
204+ ).StyleF (style .ForKeyword ),
205+ "background-image" : carapace .ActionFiles (),
206+ "background-image-fit" : ghostty .ActionBackgroundImageFits (),
207+ "background-image-position" : ghostty .ActionBackgroundImagePositions (),
208+ "bell-audio-path" : carapace .ActionFiles (),
209+ "bell-features" : ghostty .ActionBellFeatures ().UniqueList ("," ),
210+ "bold-color" : carapace .Batch (
211+ color .ActionHexColors (),
212+ color .ActionXtermColorNames (),
213+ carapace .ActionValues ("bright" ),
214+ ).ToA (),
169215 "clipboard-read" : carapace .ActionValues ("ask" , "allow" , "deny" ).StyleF (style .ForKeyword ),
170216 "clipboard-write" : carapace .ActionValues ("ask" , "allow" , "deny" ).StyleF (style .ForKeyword ),
217+ "command" : bridge .ActionCarapaceBin ().SplitP (),
171218 "config-file" : carapace .ActionFiles (),
172219 "copy-on-select" : ghostty .ActionCopyOnSelectModes (),
173220 "cursor-color" : color .ActionHexColors (),
@@ -201,6 +248,7 @@ func addConfigs(cmd *cobra.Command) {
201248 "grapheme-width-method" : ghostty .ActionGraphemeWidthMethods (),
202249 "gtk-single-instance" : carapace .ActionValues ("true" , "false" , "detect" ).StyleF (style .ForKeyword ),
203250 "gtk-tabs-location" : carapace .ActionValues ("top" , "bottom" , "left" , "right" , "hidden" ),
251+ "gtk-toolbar-style" : ghostty .ActionGtkToolbarStyles (),
204252 "initial-command" : bridge .ActionCarapaceBin ().Split (),
205253 "linux-cgroup" : carapace .ActionValuesDescribed (
206254 "never" , "Never use cgroups" ,
0 commit comments