added warning for nested sessions if "TMUX" variable is set
This commit is contained in:
parent
40836412bc
commit
a15bee37c6
2 changed files with 16 additions and 0 deletions
|
@ -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();
|
||||
|
|
12
src/util.rs
12
src/util.rs
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue