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

add(option): default_layout #1467

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/MANPAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions zellij-utils/src/input/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub struct Options {
/// Set the default shell
#[clap(long, parse(from_os_str))]
pub default_shell: Option<PathBuf>,
/// Set the default layout
#[clap(long, parse(from_os_str))]
pub default_layout: Option<PathBuf>,
/// Set the layout_dir, defaults to
/// subdirectory of config dir
#[clap(long, parse(from_os_str))]
Expand Down Expand Up @@ -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);
Expand All @@ -144,6 +148,7 @@ impl Options {
theme,
default_mode,
default_shell,
default_layout,
layout_dir,
mouse_mode,
pane_frames,
Expand Down Expand Up @@ -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);
Expand All @@ -195,6 +201,7 @@ impl Options {
theme,
default_mode,
default_shell,
default_layout,
layout_dir,
mouse_mode,
pane_frames,
Expand Down Expand Up @@ -247,6 +254,7 @@ impl From<CliOptions> 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,
Expand Down
6 changes: 5 additions & 1 deletion zellij-utils/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down