added REMUX_WINDOW_NAME var for add command

This commit is contained in:
Valerie Wolfe 2024-03-14 16:26:40 -04:00
parent 54f3fbb331
commit 50f129c793
2 changed files with 7 additions and 2 deletions

View file

@ -149,10 +149,13 @@ pub fn new(pargs: &mut Arguments) {
// don't allow unflagged nesting
util::prevent_nest();
// get optional flag
// get optional flags
let detached = pargs.contains(flag::DETACH);
let target_dir: Result<String, Error> = pargs.value_from_str(flag::TARGET);
// get environment variables
let window_name = env_var(env::NEW_WINDOW_NAME);
// get target or fallback
let args = pargs.clone().finish();
let title: String;
@ -171,6 +174,7 @@ pub fn new(pargs: &mut Arguments) {
if let Some(command) = command { new.shell_command = Some(command.to_string_lossy()); }
if detached { new.detached = true; }
if let Ok(target_dir) = target_dir { new = new.start_directory(target_dir); }
if !window_name.is_empty() { new.window_name = Some(window_name.into()); }
Tmux::new()
.add_command(new)

View file

@ -3,6 +3,7 @@ use std::env::var;
pub type EnvVar = (&'static str, &'static str);
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
pub fn env_var(envvar: EnvVar) -> String {
var(envvar.0).unwrap_or(envvar.1.to_string())