11 Commits

Author SHA1 Message Date
Leah Amelia Chen
98d77788f4 feat(config): generate default template when config file is not found
Closes #3203
2024-12-30 14:28:38 -08:00
Mitchell Hashimoto
adcaff7137 config: edit opens AppSupport over XDG on macOS, prefers non-empty paths
Fixes #3953
Fixes #3284

This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.

The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.

Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.

This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
2024-12-30 08:43:59 -08:00
Nico Weber
44e1df5df3 add a comment 2024-12-22 13:16:30 -05:00
Nico Weber
79d84af56e comment 2024-12-22 08:52:38 -05:00
Nico Weber
6a2597a6d6 macos: Make "Settings…" menu item open config file in Application Support
...unless ~/.config/ghostty/config already exists, then that is opened.
(Or whatever $XDG_CONFIG_HOME points to.)

If both files exists, ghostty reads first the one in ~/.config/ghostty/config
and then the one in Application Support, and merges the settings. In that case,
the menu item opens the file at ~/.config.

Fixes #2890.
2024-12-22 08:45:45 -05:00
Mitchell Hashimoto
cf18e23256 config: create the config dir recursively for edit 2024-01-05 09:01:30 -08:00
Mitchell Hashimoto
a62061aec6 config: use dirname so we don't have to alloc a new dir for edit 2024-01-05 07:54:20 -08:00
Evan Boehs
3a93831e39 Fix #1213 (create dir if needed for settings) 2024-01-05 10:36:26 -05:00
Borja Clemente
a1fd9f733c Remove log from imports as it is unused
Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-19 09:23:30 +01:00
Borja Clemente
9f8465c507 Remove unused imports from config/edit
Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-19 09:21:10 +01:00
Mitchell Hashimoto
7600c761ef fix callback struct ordering, use internal_os.open 2023-12-18 08:00:40 -08:00