Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): generate default template when config file is not found #3460

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

pluiedev
Copy link
Contributor

Closes #3203

@qwerasd205
Copy link
Collaborator

Notably, this PR automatically initializes the file on the first attempted load, rather than as a part of open_config (which is handled by open in ./src/config/edit.zig). I'm not sure how I feel about this.

@qwerasd205
Copy link
Collaborator

qwerasd205 commented Dec 27, 2024

As for the contents of the template- there are some changes to my suggested template that are definitely improvements, but some of the new wording is a little sloppy, the text jumps around between moods in a strange way, extraneous commentary is included which will reduce the chance of a user properly reading it (users could not care less about the philosophical basis of the configuration file, they just want to change their font and color scheme), and not leading with the docs link front and center is definitely worse.

@mitchellh
Copy link
Contributor

Notably, this PR automatically initializes the file on the first attempted load, rather than as a part of open_config (which is handled by open in ./src/config/edit.zig). I'm not sure how I feel about this.

I agree, I don't think we should be doing this in the load portion.

@pluiedev
Copy link
Contributor Author

pluiedev commented Dec 28, 2024

Notably, this PR automatically initializes the file on the first attempted load, rather than as a part of open_config (which is handled by open in ./src/config/edit.zig). I'm not sure how I feel about this.

I feel like I prefer this over only generating when open_config is run, since another common point of feedback is that some people didn't even know that you can open the config by pressing Ctrl/Cmd-,.

Plus, when they follow the docs and try to find the config file at ~/.config/ghostty/config (or its macOS equivalent) only to find that it doesn't exist, they get quite confused for one reason or another (some people mistake it for a directory, some people ask "wait, where's the ghostty directory in ~/.config?", etc.) Therefore I'd argue that only generating the file upon open_config only addresses half the problem. Always creating the template file when one couldn't be found would largely alleviate the volume of PEBKAC I've personally seen.

@pluiedev
Copy link
Contributor Author

pluiedev commented Dec 28, 2024

As for the contents of the template- there are some changes to my suggested template that are definitely improvements, but some of the new wording is a little sloppy, the text jumps around between moods in a strange way,

Proofreads & wording suggestions welcome, but an issue I had with the original version is that it feels too cold/robotic for an introductory document — I tried to rephrase it with a more welcoming tone but maybe now it seems a bit disjointed

extraneous commentary is included which will reduce the chance of a user properly reading it (users could not care less about the philosophical basis of the configuration file, they just want to change their font and color scheme),

Zero-config is a great selling point of Ghostty — heck, it's literally the first thing you see on the website's docs page. If people truly don't care about philosophical fluff then maybe we should deemphasize it there too.

I think it's a needed point of justification as to why we're not like, say, Kitty, where the default config is a full list of options. (Believe me, there are people who got confused by that as well, coming from Kitty)

and not leading with the docs link front and center is definitely worse.

That can definitely be moved

@mitchellh mitchellh added this to the 1.0.1 milestone Dec 29, 2024
@edrozenberg
Copy link

edrozenberg commented Dec 30, 2024

Love this:

This template file has been automatically created at path
#   {[path]s} 

As a new user, Ghostty created the config file for me and I had a bit of a hl of a time figuring out where it put it, ~/Library/Application Support/com.mitchellh.ghostty/config (Mac) was not my first, second or fifth guess, I looked in ~ and then in ~/.config and then no clue. Eventually I found it. This template text will be a big help.

@mitchellh mitchellh force-pushed the push-yozovzpysmzw branch 2 times, most recently from 1c2b6e2 to 76b3a8b Compare December 30, 2024 22:28
/// called from one place that is not performance critical so it is fine
/// to be inline.
inline fn configPath(alloc_arena: Allocator) ![]const u8 {
fn configPath(alloc_arena: Allocator) ![]const u8 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an unrelated change I snuck in here because I noticed it.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I made some edits. I'm still not super happy with how this works but it does the job and I think it'll help users quite a lot. Thanks @pluiedev

@mitchellh mitchellh merged commit 478fe39 into ghostty-org:main Dec 30, 2024
21 checks passed
@HeySora
Copy link

HeySora commented Jan 1, 2025

There might be an issue in this PR, considering that this happened on every launch after updating to 1.0.1 on my computer.

image

This will actually fail if the ~/Library/Application Support/com.mitchellh.ghostty directory does not exist! That can be fixed by doing cmd+, inside ghostty, but this creates an empty config file, without the template. Because of this, ghostty will not attempt to create a template file, considering the file exists (despite being empty). Closing ghostty, deleting that file while keeping the folder, then restarting ghostty properly creates the template file this time!

A workaround for this would be to also generate the template by doing cmd+, for the first time, in the code path that creates the folder and file.

@mitchellh
Copy link
Contributor

Does the directory exist? I just deleted my config files (moved them) and it gets created fine. But @HeySora is correct that it requires the dir to exist which is unfortunate. I'm making an issue to track that now.

@edrozenberg
Copy link

edrozenberg commented Jan 1, 2025

It worked after these steps:

  1. Close Ghostty windows, Quit Ghostty

  2. rm -rf ~/Library/Application\ Support/com.mitchellh.ghostty

  3. Open Ghostty, Cmd ,

  4. Blank config file opens in TextMate

  5. cat ~/Library/Application\ Support/com.mitchellh.ghostty/config is blank

  6. Quit Ghostty

  7. rm -f ~/Library/Application\ Support/com.mitchellh.ghostty/config

  8. Open Ghostty, Cmd ,

  9. Template config file shows up in TextMate ✅

@liby
Copy link
Contributor

liby commented Jan 1, 2025

Hi @HeySora,

image

Interesting observation! While trying to reproduce this issue, I noticed something different. I can only see the error message in the logs:

2025-01-01 17:30:11.159045+0000 Info ghostty: [com.mitchellh.ghostty:config] creating template config file: path=/Users/bryan/Library/Application Support/com.mitchellh.ghostty/config
2025-01-01 17:30:11.159075+0000 Error ghostty: [com.mitchellh.ghostty:config] error creating template config file err=error.FileNotFound

But I don't see any UI modal/notification like the one in your screenshot. I'm curious:

  • Did you have any special configuration to enable these error notifications?

  • Or perhaps you're running on a different platform? I'm on macOS with:

    Ghostty 1.0.1
    - channel: stable
    - app runtime: apprt.Runtime.none
    - font engine: font.main.Backend.coretext
    - renderer: renderer.Metal
    

Would be helpful to know your setup as it seems to provide a better user experience with visible error notifications!

@HeySora
Copy link

HeySora commented Jan 2, 2025

Hi @liby, this is just Console.app!

It's the built-in macOS app that aggregates logs from every running app (+ has remote debugging for any of your Apple devices, including iOS);
I simply didn't want to guess where Ghostty stored its logs, as Console is effectively an universal way to read logs from anywhere, so I just started the logging capture, started Ghostty, then stopped the capture and typed "ghostty" in the search bar, filtering by errors.

Here is an uncropped screenshot to hopefully help with the context of the above image.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default config file contents
6 participants