Compare commits
No commits in common. "407d77812a80db68d6d3eb86f610bba45d06d8fa" and "2ede502884d4295a121d0c3394363cf823d508b0" have entirely different histories.
407d77812a
...
2ede502884
3 changed files with 14 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "remux"
|
||||
version = "0.2.0"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
|
||||
description = "A friendly command shortener for tmux"
|
||||
|
|
|
@ -24,7 +24,10 @@ pub fn attach(pargs: &mut Arguments) {
|
|||
let window: Option<&OsString>;
|
||||
if args.len() < 1 {
|
||||
// missing name will attempt to fall back to repository
|
||||
target = util::repo_fallback();
|
||||
let repo = util::repo_root(current_dir().unwrap());
|
||||
if repo.is_none() { error::missing_target(); }
|
||||
|
||||
target = repo.unwrap().file_name().unwrap().to_string_lossy().to_string();
|
||||
if !util::session_exists(target.clone()) { error::missing_target(); }
|
||||
window = None;
|
||||
} else {
|
||||
|
@ -84,7 +87,10 @@ pub fn has(pargs: &mut Arguments) {
|
|||
let target: String;
|
||||
if args.len() < 1 {
|
||||
// missing name will attempt to fall back to repository
|
||||
target = util::repo_fallback();
|
||||
let repo = util::repo_root(current_dir().unwrap());
|
||||
if repo.is_none() { error::missing_target(); }
|
||||
|
||||
target = repo.unwrap().file_name().unwrap().to_string_lossy().to_string();
|
||||
} else {
|
||||
target = args.get(0).unwrap().to_string_lossy().to_string();
|
||||
}
|
||||
|
@ -147,7 +153,10 @@ pub fn new(pargs: &mut Arguments) {
|
|||
let command: Option<&OsString>;
|
||||
if args.len() < 1 {
|
||||
// missing name will attempt to fall back to repository
|
||||
title = util::repo_fallback();
|
||||
let repo = util::repo_root(current_dir().unwrap());
|
||||
if repo.is_none() { error::missing_target(); }
|
||||
|
||||
title = repo.unwrap().file_name().unwrap().to_string_lossy().to_string();
|
||||
command = None;
|
||||
} else {
|
||||
title = args.get(0).unwrap().to_string_lossy().to_string();
|
||||
|
|
13
src/util.rs
13
src/util.rs
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
env::{ current_dir, var },
|
||||
env::var,
|
||||
path::PathBuf,
|
||||
process::exit
|
||||
};
|
||||
|
@ -9,8 +9,6 @@ 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);
|
||||
|
@ -39,15 +37,6 @@ pub fn session_exists<S: Into<String>>(target: S) -> bool {
|
|||
.success()
|
||||
}
|
||||
|
||||
/// attempt to return the repo name or exit
|
||||
pub fn repo_fallback() -> String {
|
||||
let repo = repo_root(current_dir().unwrap());
|
||||
if repo.is_none() { error::missing_target(); }
|
||||
|
||||
let target = repo.unwrap().file_name().unwrap().to_string_lossy().to_string();
|
||||
target
|
||||
}
|
||||
|
||||
/// recursively attempt to find a git root directory
|
||||
pub fn repo_root(path: PathBuf) -> Option<PathBuf> {
|
||||
// if .git dir is found, return
|
||||
|
|
Loading…
Reference in a new issue