aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 16:13:46 +0200
committeruser <user@clank>2026-08-15 16:13:46 +0200
commitee6288a7eadeb43c83a5ab78f6c65cffa4748a53 (patch)
tree8fc137687f47a7f20f0a2766bca17cd53e0400dc /src/config.c
parentmake coverage: a number, cheaply (diff)
downloadslosh-ee6288a7eadeb43c83a5ab78f6c65cffa4748a53.tar.gz
slosh-ee6288a7eadeb43c83a5ab78f6c65cffa4748a53.tar.xz
slosh-ee6288a7eadeb43c83a5ab78f6c65cffa4748a53.zip
sl0ppty: C-a e opens the config, in a pane, in your editor
The config watcher's whole point is the loop -- edit, save, watch the session change under you, edit again -- and the loop had a hole in the middle of it: you had to leave the session, or remember where the file lives, to start. So: one keystroke opens `$EDITOR <config>` in a new pane, down rather than across because a config file is lines and half the height beats half the width for reading them. `editor` in the config beats $EDITOR, and vi is the fallback, being the one editor a POSIX system must have -- a wrong guess you can see and change beats a pane that opens empty. The interesting part is what kind of pane it is. Panes given a command keep their corpse (D14), which is right for a dev server and wrong for this: quit the editor and you would be left dismissing a dead pane you opened thirty seconds ago. Rather than gaming that policy by giving the pane no command -- which would be a lie in the one field dump-layout and re-run read -- panes can now be *ephemeral*: a task rather than part of the session's shape. An ephemeral pane keeps no corpse and is not written into a dumped layout, so a restart does not reopen somebody's editor on a file they had finished with. That concept is the reusable half of this commit; the keybinding is the part you notice.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index f4076b7..877b225 100644
--- a/src/config.c
+++ b/src/config.c
@@ -30,6 +30,7 @@ static const struct {
{"detach", ACT_DETACH}, {"quit", ACT_QUIT},
{"literal-prefix", ACT_LITERAL_PREFIX},
{"help", ACT_HELP},
+ {"edit-config", ACT_EDIT_CONFIG},
};
static const struct {
@@ -393,6 +394,7 @@ void config_defaults(config_t *c) {
bind_add(c, GHOSTTY_KEY_SLASH, 0, ACT_HELP, false);
bind_add(c, GHOSTTY_KEY_R, 0, ACT_RERUN, false);
bind_add(c, GHOSTTY_KEY_Z, 0, ACT_ZOOM, false);
+ bind_add(c, GHOSTTY_KEY_E, 0, ACT_EDIT_CONFIG, false);
bind_add(c, GHOSTTY_KEY_M, 0, ACT_MINIMIZE, false);
bind_add(c, GHOSTTY_KEY_H, 0, ACT_FOCUS_LEFT, false);
bind_add(c, GHOSTTY_KEY_L, 0, ACT_FOCUS_RIGHT, false);
@@ -431,6 +433,7 @@ void config_free(config_t *c) {
free(c->exprs);
free(c->binds);
free(c->shell);
+ free(c->editor);
free(c->shader_dir);
memset(c, 0, sizeof *c);
}
@@ -478,6 +481,7 @@ static const struct {
{ACT_SCROLL_BOTTOM, "scroll", "back to the present"},
{ACT_HELP, "session", "this list"},
+ {ACT_EDIT_CONFIG, "session", "edit the config"},
{ACT_DETACH, "session", "detach, leave it running"},
{ACT_QUIT, "session", "quit the session"},
{ACT_LITERAL_PREFIX, "session", "send the prefix itself"},
@@ -709,6 +713,11 @@ bool config_load(config_t *c, const char *path, char *err, size_t errcap) {
free(c->shell);
c->shell = strdup(sh);
}
+ const char *ed = kdl_arg(kdl_child(root, "editor"), 0, NULL);
+ if (ed) {
+ free(c->editor);
+ c->editor = strdup(ed);
+ }
/* Shader plugins, before any shader is named below: a `shaders` block may
* use what one of these adds, and a name is looked up as it is parsed. The