Compare commits
2 commits
044736b535
...
65e28327f1
Author | SHA1 | Date | |
---|---|---|---|
65e28327f1 | |||
70c7c325f9 |
3 changed files with 27 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "remux"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -30,3 +30,9 @@ pub fn missing_target() {
|
|||
exit(4);
|
||||
}
|
||||
|
||||
/// user declined nesting dialog
|
||||
pub fn nest_declined() {
|
||||
println!("remux: session nesting declined by user");
|
||||
exit(5);
|
||||
}
|
||||
|
||||
|
|
23
src/util.rs
23
src/util.rs
|
@ -1,5 +1,10 @@
|
|||
use std::{
|
||||
env::var,
|
||||
env::{ set_var, var },
|
||||
io::{
|
||||
self,
|
||||
|
||||
Read, Write
|
||||
},
|
||||
process::exit
|
||||
};
|
||||
|
||||
|
@ -8,6 +13,8 @@ use tmux_interface::{
|
|||
variables::session::session::SESSION_ALL
|
||||
};
|
||||
|
||||
use crate::error;
|
||||
|
||||
/// return a Vec of all sessions or None
|
||||
pub fn get_sessions() -> Option<Vec<Session>> {
|
||||
let i_sessions = Sessions::get(SESSION_ALL);
|
||||
|
@ -22,8 +29,18 @@ pub fn get_sessions() -> Option<Vec<Session>> {
|
|||
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);
|
||||
// ask the user if they want to nest (default: no)
|
||||
print!("Are you sure you want to nest sessions? (y/N) ");
|
||||
let _ = io::stdout().flush();
|
||||
|
||||
let mut input = [0];
|
||||
let _ = io::stdin().read(&mut input);
|
||||
match input[0] as char {
|
||||
'y' | 'Y'
|
||||
=> {},
|
||||
_ => error::nest_declined()
|
||||
}
|
||||
set_var("TMUX", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue