added REMUX_WINDOW_NAME var for add command
This commit is contained in:
parent
681e7427ba
commit
62d72735da
2 changed files with 7 additions and 2 deletions
|
@ -153,10 +153,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;
|
||||
|
@ -175,6 +178,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)
|
||||
|
|
|
@ -2,7 +2,8 @@ use std::env::var;
|
|||
|
||||
pub type EnvVar = (&'static str, &'static str);
|
||||
|
||||
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
|
||||
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())
|
||||
|
|
Loading…
Reference in a new issue