added warning for nested sessions if "TMUX" variable is set

This commit is contained in:
Valerie Wolfe 2023-06-15 11:33:08 -04:00
parent 40836412bc
commit a15bee37c6
2 changed files with 16 additions and 0 deletions

View file

@ -103,6 +103,8 @@ pub fn help(pargs: &mut Arguments) {
}
pub fn attach(pargs: &mut Arguments) {
util::prevent_nest();
let read_only = pargs.contains(["-r", "--readonly"]);
let detach_other = pargs.contains(["-d", "--detach"]);
@ -204,6 +206,8 @@ pub fn list() {
pub fn new(pargs: &mut Arguments) {
use pico_args::Error;
util::prevent_nest();
let target_dir: Result<String, Error> = pargs.value_from_str(["-t", "--target"]);
let args = pargs.clone().finish();

View file

@ -1,3 +1,7 @@
use std::{
env::var,
process::exit
};
use tmux_interface::{
Session, Sessions,
@ -13,3 +17,11 @@ pub fn get_sessions() -> Option<Vec<Session>> {
Some(sessions.unwrap().0)
}
pub fn prevent_nest() {
let tmux = var("TMUX").ok();
if tmux.is_some() && tmux.unwrap() != "" {
println!("Sessions should be nested with care; unset TMUX to allow.");
exit(1);
}
}