diff --git a/Cargo.toml b/Cargo.toml index f69ddd2..b89a690 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remux" -version = "0.3.1" +version = "0.3.2" edition = "2021" authors = [ "Valerie Wolfe " ] description = "A friendly command shortener for tmux" diff --git a/src/command/share.rs b/src/command/share.rs index 9d1d927..6927240 100644 --- a/src/command/share.rs +++ b/src/command/share.rs @@ -64,6 +64,23 @@ pub fn attach(pargs: &mut Arguments) { tmux.output().ok(); } +pub fn context_action() { + let repo = util::repo_root(std::env::current_dir().unwrap()); + if !env::tmux() && repo.is_some() { + let target = util::repo_fallback(); + let mut args = Arguments::from_vec( vec![(&target).into()] ); + if util::session_exists(&target) { + attach(&mut args); + } else { + new(&mut args); + } + return; + } else { + // fallback behavior is list + list(); + } +} + pub fn detach(pargs: &mut Arguments) { util::terminal_enforce(); // get target or fallback diff --git a/src/main.rs b/src/main.rs index e94a42e..ca3b08c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,8 @@ fn main() { match subcommand.as_deref() { Some("help") => help(&mut args), + None + => command::share::context_action(), Some("a" | "attach") => command::share::attach(&mut args), @@ -53,7 +55,6 @@ fn main() { Some("h" | "has") => command::share::has(&mut args), - None | Some("l" | "ls" | "list") => command::share::list(),