Compare commits

...

6 commits

2 changed files with 25 additions and 13 deletions

View file

@ -14,7 +14,7 @@ path = "src/main.rs"
[dependencies] [dependencies]
pico-args = { version = "0.5.0", features = [ "combined-flags", "eq-separator" ] } pico-args = { version = "0.5.0", features = [ "combined-flags", "eq-separator" ] }
termion = "2.0.1" termion = "3.0.0"
tmux_interface = "0.3.2" tmux_interface = "0.3.2"
[profile.release] [profile.release]

View file

@ -131,7 +131,7 @@ pub fn list() {
// pretty print session list // pretty print session list
println!("sessions:"); println!("sessions:");
for session in sessions.into_iter() { for session in sessions.into_iter() {
let group = session.group.unwrap_or("[untitled]".to_string()); let group = session.name.unwrap_or("[untitled]".to_string());
let id = session.id.unwrap(); let id = session.id.unwrap();
let attached = session.attached.unwrap_or(0) > 0; let attached = session.attached.unwrap_or(0) > 0;
@ -173,13 +173,16 @@ pub fn new(pargs: &mut Arguments) {
command = args.get(1); command = args.get(1);
} }
let mut tmux = Tmux::new();
// if no session exists with the given title, create one
if !util::session_exists(&title) {
let mut new = commands::NewSession::new(); let mut new = commands::NewSession::new();
new = new.group_name(title); new = new.session_name(title);
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); }
tmux = tmux.add_command(new).disable_echo();
let mut tmux = Tmux::new().add_command(new);
// rename window if var not empty // rename window if var not empty
if !window_name.is_empty() { if !window_name.is_empty() {
@ -187,6 +190,15 @@ pub fn new(pargs: &mut Arguments) {
.new_name(window_name); .new_name(window_name);
tmux = tmux.add_command(auto_name); tmux = tmux.add_command(auto_name);
} }
}
// otherwise, use the existing session
else {
let mut attach = commands::AttachSession::new();
attach = attach.target_session(title);
tmux = tmux.add_command(attach);
}
tmux.output().ok(); tmux.output().ok();
} }