Compare commits
3 commits
fd076f7fee
...
087a2fe66e
Author | SHA1 | Date | |
---|---|---|---|
087a2fe66e | |||
478638d249 | |||
50f129c793 |
3 changed files with 13 additions and 3 deletions
|
@ -149,10 +149,13 @@ pub fn new(pargs: &mut Arguments) {
|
||||||
// don't allow unflagged nesting
|
// don't allow unflagged nesting
|
||||||
util::prevent_nest();
|
util::prevent_nest();
|
||||||
|
|
||||||
// get optional flag
|
// get optional flags
|
||||||
let detached = pargs.contains(flag::DETACH);
|
let detached = pargs.contains(flag::DETACH);
|
||||||
let target_dir: Result<String, Error> = pargs.value_from_str(flag::TARGET);
|
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
|
// get target or fallback
|
||||||
let args = pargs.clone().finish();
|
let args = pargs.clone().finish();
|
||||||
let title: String;
|
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 let Some(command) = command { new.shell_command = Some(command.to_string_lossy()); }
|
||||||
if detached { new.detached = true; }
|
if detached { new.detached = true; }
|
||||||
if let Ok(target_dir) = target_dir { new = new.start_directory(target_dir); }
|
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()
|
Tmux::new()
|
||||||
.add_command(new)
|
.add_command(new)
|
||||||
|
|
|
@ -2,7 +2,8 @@ use std::env::var;
|
||||||
|
|
||||||
pub type EnvVar = (&'static str, &'static str);
|
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 {
|
pub fn env_var(envvar: EnvVar) -> String {
|
||||||
var(envvar.0).unwrap_or(envvar.1.to_string())
|
var(envvar.0).unwrap_or(envvar.1.to_string())
|
||||||
|
|
|
@ -107,7 +107,12 @@ println!("remux environment variables
|
||||||
REMUX_ATTACH_SYMBOL
|
REMUX_ATTACH_SYMBOL
|
||||||
Changes the symbol displayed for attached sessions displayed
|
Changes the symbol displayed for attached sessions displayed
|
||||||
by the 'list' command.
|
by the 'list' command.
|
||||||
Default: '*'"),
|
Default: '*'
|
||||||
|
|
||||||
|
REMUX_NEW_WINDOW
|
||||||
|
Provides a default window name when creating a session with
|
||||||
|
the 'new' command, if not empty.
|
||||||
|
Default: ''"),
|
||||||
|
|
||||||
// not found
|
// not found
|
||||||
_ => error::no_help(topic.unwrap())
|
_ => error::no_help(topic.unwrap())
|
||||||
|
|
Loading…
Reference in a new issue