From 98124ab583089a166fb8a25191f8266c883a4fa5 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 7 Jun 2022 19:58:37 +0200 Subject: [PATCH 1/2] add(option): `default_layout` Add `option` `default_layout` / `default-layout`, that allows specifying a different layout, that should be loaded on start. Eg: ``` default_layout: compact ``` --- zellij-utils/src/input/options.rs | 8 ++++++++ zellij-utils/src/setup.rs | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index bc23cf3c0d..22dc0a556e 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -52,6 +52,9 @@ pub struct Options { /// Set the default shell #[clap(long, parse(from_os_str))] pub default_shell: Option, + /// Set the default layout + #[clap(long, parse(from_os_str))] + pub default_layout: Option, /// Set the layout_dir, defaults to /// subdirectory of config dir #[clap(long, parse(from_os_str))] @@ -128,6 +131,7 @@ impl Options { let simplified_ui = other.simplified_ui.or(self.simplified_ui); let default_mode = other.default_mode.or(self.default_mode); let default_shell = other.default_shell.or_else(|| self.default_shell.clone()); + let default_layout = other.default_layout.or_else(|| self.default_layout.clone()); let layout_dir = other.layout_dir.or_else(|| self.layout_dir.clone()); let theme = other.theme.or_else(|| self.theme.clone()); let on_force_close = other.on_force_close.or(self.on_force_close); @@ -144,6 +148,7 @@ impl Options { theme, default_mode, default_shell, + default_layout, layout_dir, mouse_mode, pane_frames, @@ -179,6 +184,7 @@ impl Options { let default_mode = other.default_mode.or(self.default_mode); let default_shell = other.default_shell.or_else(|| self.default_shell.clone()); + let default_layout = other.default_layout.or_else(|| self.default_layout.clone()); let layout_dir = other.layout_dir.or_else(|| self.layout_dir.clone()); let theme = other.theme.or_else(|| self.theme.clone()); let on_force_close = other.on_force_close.or(self.on_force_close); @@ -195,6 +201,7 @@ impl Options { theme, default_mode, default_shell, + default_layout, layout_dir, mouse_mode, pane_frames, @@ -247,6 +254,7 @@ impl From for Options { theme: opts.theme, default_mode: opts.default_mode, default_shell: opts.default_shell, + default_layout: opts.default_layout, layout_dir: opts.layout_dir, mouse_mode: opts.mouse_mode, pane_frames: opts.pane_frames, diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index b117766d4f..4e0c39578c 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -230,8 +230,12 @@ impl Setup { .layout_dir .clone() .or_else(|| get_layout_dir(opts.config_dir.clone().or_else(find_default_config_dir))); + let chosen_layout = opts + .layout + .clone() + .or_else(|| config_options.default_layout.clone()); let layout_result = - LayoutFromYamlIntermediate::from_path_or_default(opts.layout.as_ref(), layout_dir); + LayoutFromYamlIntermediate::from_path_or_default(chosen_layout.as_ref(), layout_dir); let layout = match layout_result { None => None, Some(Ok(layout)) => Some(layout), From 838a9bd16060279d2635ee769eb234c767e67ea4 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 7 Jun 2022 21:15:44 +0200 Subject: [PATCH 2/2] add(manpage): `default_layout` --- docs/MANPAGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/MANPAGE.md b/docs/MANPAGE.md index 877141b9a2..6d749301d9 100644 --- a/docs/MANPAGE.md +++ b/docs/MANPAGE.md @@ -39,6 +39,8 @@ LAYOUTS Layouts are yaml files which Zellij can load on startup when _--layout_ flag is provided. +By default Zellij will load a layout called `default.yaml`, +but this can be changed by using the `default_layout: [LAYOUT_NAME]` configuration option. For example a file like this: