diff options
| author | Aram Drevekenin <aram@poor.dev> | 2023-02-28 15:47:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-28 15:47:08 +0100 |
| commit | 9dc3cb19616ece5e363a357fc06e0e75ac8b49e0 (patch) | |
| tree | 9e4a287ecc35758cf5568bdc42e55292cb830fea /src | |
| parent | fix(layouts): do not relayout twice on auto_layout (#2202) (diff) | |
| download | sl0ppij-9dc3cb19616ece5e363a357fc06e0e75ac8b49e0.tar.gz sl0ppij-9dc3cb19616ece5e363a357fc06e0e75ac8b49e0.tar.xz sl0ppij-9dc3cb19616ece5e363a357fc06e0e75ac8b49e0.zip | |
fix(new-tab): get config parameters from config file (#2203)
* fix(cli): take default shell from config if it exists when opening new tab
* fix(cli): take layout dir from config when opening new tab if it exists
* style(fmt): rustfmt
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.rs | 21 | ||||
| -rw-r--r-- | src/main.rs | 8 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/commands.rs b/src/commands.rs index 6d429cdb..d8f37a7a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -18,7 +18,11 @@ use zellij_server::{os_input_output::get_server_os_input, start_server as start_ use zellij_utils::{ cli::{CliArgs, Command, SessionCommand, Sessions}, envs, - input::{actions::Action, config::ConfigError, options::Options}, + input::{ + actions::Action, + config::{Config, ConfigError}, + options::Options, + }, nix, setup::Setup, }; @@ -115,6 +119,7 @@ fn find_indexed_session( pub(crate) fn send_action_to_session( cli_action: zellij_utils::cli::CliAction, requested_session_name: Option<String>, + config: Option<Config>, ) { match get_active_session() { ActiveSession::None => { @@ -132,13 +137,13 @@ pub(crate) fn send_action_to_session( std::process::exit(1); } } - attach_with_cli_client(cli_action, &session_name); + attach_with_cli_client(cli_action, &session_name, config); }, ActiveSession::Many => { let existing_sessions = get_sessions().unwrap(); if let Some(session_name) = requested_session_name { if existing_sessions.contains(&session_name) { - attach_with_cli_client(cli_action, &session_name); + attach_with_cli_client(cli_action, &session_name, config); } else { eprintln!( "Session '{}' not found. The following sessions are active:", @@ -148,7 +153,7 @@ pub(crate) fn send_action_to_session( std::process::exit(1); } } else if let Ok(session_name) = envs::get_session_name() { - attach_with_cli_client(cli_action, &session_name); + attach_with_cli_client(cli_action, &session_name, config); } else { eprintln!("Please specify the session name to send actions to. The following sessions are active:"); print_sessions(existing_sessions); @@ -226,10 +231,14 @@ pub(crate) fn convert_old_theme_file(old_theme_file: PathBuf) { } } -fn attach_with_cli_client(cli_action: zellij_utils::cli::CliAction, session_name: &str) { +fn attach_with_cli_client( + cli_action: zellij_utils::cli::CliAction, + session_name: &str, + config: Option<Config>, +) { let os_input = get_os_input(zellij_client::os_input_output::get_cli_client_os_input); let get_current_dir = || std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); - match Action::actions_from_cli(cli_action, Box::new(get_current_dir)) { + match Action::actions_from_cli(cli_action, Box::new(get_current_dir), config) { Ok(actions) => { zellij_client::cli_client::start_cli_client(Box::new(os_input), session_name, actions); std::process::exit(0); diff --git a/src/main.rs b/src/main.rs index 77c3256d..54ca71cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ mod tests; use zellij_utils::{ clap::Parser, cli::{CliAction, CliArgs, Command, Sessions}, + input::config::Config, logging::*, }; @@ -14,8 +15,9 @@ fn main() { let opts = CliArgs::parse(); { + let config = Config::try_from(&opts).ok(); if let Some(Command::Sessions(Sessions::Action(cli_action))) = opts.command { - commands::send_action_to_session(cli_action, opts.session); + commands::send_action_to_session(cli_action, opts.session, config); std::process::exit(0); } if let Some(Command::Sessions(Sessions::Run { @@ -37,7 +39,7 @@ fn main() { close_on_exit, start_suspended, }; - commands::send_action_to_session(command_cli_action, opts.session); + commands::send_action_to_session(command_cli_action, opts.session, config); std::process::exit(0); } if let Some(Command::Sessions(Sessions::Edit { @@ -62,7 +64,7 @@ fn main() { floating, cwd, }; - commands::send_action_to_session(command_cli_action, opts.session); + commands::send_action_to_session(command_cli_action, opts.session, config); std::process::exit(0); } if let Some(Command::Sessions(Sessions::ConvertConfig { old_config_file })) = opts.command { |
