Skip to content

Commit 71d49b5

Browse files
committed
choose-fonts kitten: allow specifying the name of the conf file to edit
Fixes #7926
1 parent af83d85 commit 71d49b5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

kittens/choose_fonts/final.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (self *final_pane) draw_screen() (err error) {
3535
"",
3636
"What would you like to do?",
3737
"",
38-
fmt.Sprintf("%s to modify %s and use the new fonts", h("Enter"), s("italic", `kitty.conf`)),
38+
fmt.Sprintf("%s to modify %s and use the new fonts", h("Enter"), s("italic", self.handler.opts.Config_file_name)),
3939
"",
4040
fmt.Sprintf("%s to abort and return to font selection", h("Esc")),
4141
"",
@@ -78,7 +78,12 @@ func (self *final_pane) on_key_event(event *loop.KeyEvent) (err error) {
7878
if event.MatchesPressOrRepeat("enter") {
7979
event.Handled = true
8080
patcher := config.Patcher{Write_backup: true}
81-
path := filepath.Join(utils.ConfigDir(), "kitty.conf")
81+
path := ""
82+
if filepath.IsAbs(self.handler.opts.Config_file_name) {
83+
path = self.handler.opts.Config_file_name
84+
} else {
85+
path = filepath.Join(utils.ConfigDir(), self.handler.opts.Config_file_name)
86+
}
8287
updated, err := patcher.Patch(path, "KITTY_FONTS", self.settings.serialized(), "font_family", "bold_font", "italic_font", "bold_italic_font")
8388
if err != nil {
8489
return err

kittens/choose_fonts/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ func main(opts *Options) (rc int, err error) {
6868
}
6969

7070
type Options struct {
71-
Reload_in string
71+
Reload_in string
72+
Config_file_name string
7273
}
7374

7475
func EntryPoint(root *cli.Command) {
@@ -93,6 +94,18 @@ func EntryPoint(root *cli.Command) {
9394
running in to reload its config, after making changes. Use this option to
9495
instead either not reload the config at all or in all running kitty instances.`,
9596
})
97+
ans.Add(cli.OptionSpec{
98+
Name: "--config-file-name",
99+
Dest: "Config_file_name",
100+
Type: "str",
101+
Default: "kitty.conf",
102+
Help: `The name or path to the config file to edit. Relative paths are interpreted
103+
with respect to the kitty config directory. By default the kitty config
104+
file, kitty.conf is edited. This is most useful if you add include
105+
fonts.conf to your kitty.conf and then have the kitten operate only on
106+
fonts.conf, allowing kitty.conf to remain unchanged.`,
107+
})
108+
96109
clone := root.AddClone(ans.Group, ans)
97110
clone.Hidden = false
98111
clone.Name = "choose_fonts"

0 commit comments

Comments
 (0)