Compare commits
No commits in common. "beb880ed43466bc38dba78bd05704fcb82fe01f7" and "b7b893d55cc748e6f6dc7f48b2abac912a0e72e7" have entirely different histories.
beb880ed43
...
b7b893d55c
8 changed files with 25 additions and 57 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "remux"
|
name = "remux"
|
||||||
version = "0.3.6"
|
version = "0.3.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
|
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
|
||||||
description = "A friendly command shortener for tmux"
|
description = "A friendly command shortener for tmux"
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
_remux() {
|
|
||||||
local word
|
|
||||||
COMPREPLY=()
|
|
||||||
word="${COMP_WORDS[COMP_CWORD]}"
|
|
||||||
|
|
||||||
case $COMP_CWORD in
|
|
||||||
1)
|
|
||||||
COMPREPLY=( `compgen -W 'attach detach has help list new path switch title' -- "$word"` )
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
COMPREPLY=( `compgen -W "$(remux l -q $word)"` )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _remux remux
|
|
||||||
|
|
|
@ -135,9 +135,6 @@ Default: '>'
|
||||||
.It Ev REMUX_NEW_WINDOW
|
.It Ev REMUX_NEW_WINDOW
|
||||||
Provides a default windows name when creating a new session. Unused if empty.
|
Provides a default windows name when creating a new session. Unused if empty.
|
||||||
Default: (unset)
|
Default: (unset)
|
||||||
.It Ev REMUX_REPO_FILE
|
|
||||||
The filename to match on when trying to find the root of a repository.
|
|
||||||
Default: '.git'
|
|
||||||
.El
|
.El
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Bl -tag -Width Ds
|
.Bl -tag -Width Ds
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub fn attach(state: &mut State) {
|
||||||
state.nest_deinit();
|
state.nest_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn context_action(state: &mut State) {
|
pub fn context_action(state: &State) {
|
||||||
if !state.session {
|
if !state.session {
|
||||||
if let Some(repository) = &state.repository {
|
if let Some(repository) = &state.repository {
|
||||||
let target = repository.name.clone();
|
let target = repository.name.clone();
|
||||||
|
@ -72,7 +72,7 @@ pub fn context_action(state: &mut State) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fallback behavior is list
|
// fallback behavior is list
|
||||||
list(state);
|
list(&state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn detach(state: &mut State) {
|
pub fn detach(state: &mut State) {
|
||||||
|
@ -114,12 +114,10 @@ pub fn has(state: &mut State) {
|
||||||
exit( if success { 0 } else { 1 });
|
exit( if success { 0 } else { 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list(state: &mut State) {
|
pub fn list(state: &State) {
|
||||||
// get session list
|
// get session list
|
||||||
let sessions = util::get_sessions().unwrap_or(Vec::new());
|
let sessions = util::get_sessions().unwrap_or(Vec::new());
|
||||||
|
|
||||||
let search = state.target();
|
|
||||||
|
|
||||||
// handle empty case
|
// handle empty case
|
||||||
if sessions.len() == 0 {
|
if sessions.len() == 0 {
|
||||||
println!("no sessions");
|
println!("no sessions");
|
||||||
|
@ -131,13 +129,9 @@ pub fn list(state: &mut State) {
|
||||||
let current_symbol = env_var(env::CURRENT_SYMBOL);
|
let current_symbol = env_var(env::CURRENT_SYMBOL);
|
||||||
|
|
||||||
// pretty print session list
|
// pretty print session list
|
||||||
if !state.flags.quiet { println!("sessions:"); }
|
println!("sessions:");
|
||||||
for session in sessions {
|
for session in sessions.into_iter() {
|
||||||
let name = session.name.unwrap_or("[untitled]".to_string());
|
let name = session.name.unwrap_or("[untitled]".to_string());
|
||||||
|
|
||||||
if search.is_some() && !name.starts_with(search.as_ref().unwrap()) { continue; }
|
|
||||||
|
|
||||||
if !state.flags.quiet {
|
|
||||||
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;
|
||||||
|
@ -154,9 +148,6 @@ pub fn list(state: &mut State) {
|
||||||
green = color::Fg(color::LightGreen),
|
green = color::Fg(color::LightGreen),
|
||||||
reset = style::Reset,
|
reset = style::Reset,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
print!("{name} ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ pub type EnvVar = (&'static str, &'static str);
|
||||||
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
|
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
|
||||||
pub static CURRENT_SYMBOL: EnvVar = ("REMUX_CURRENT_SYMBOL", ">");
|
pub static CURRENT_SYMBOL: EnvVar = ("REMUX_CURRENT_SYMBOL", ">");
|
||||||
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
||||||
pub static REPO_FILE: EnvVar = ("REMUX_REPO_FILE", ".git");
|
|
||||||
|
|
||||||
pub static TMUX: &str = "TMUX";
|
pub static TMUX: &str = "TMUX";
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn main() {
|
||||||
Some("help")
|
Some("help")
|
||||||
=> help(&mut args),
|
=> help(&mut args),
|
||||||
None
|
None
|
||||||
=> command::share::context_action(&mut state),
|
=> command::share::context_action(&state),
|
||||||
|
|
||||||
Some("a" | "attach")
|
Some("a" | "attach")
|
||||||
=> command::share::attach(&mut state),
|
=> command::share::attach(&mut state),
|
||||||
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
=> command::share::has(&mut state),
|
=> command::share::has(&mut state),
|
||||||
|
|
||||||
Some("l" | "ls" | "list")
|
Some("l" | "ls" | "list")
|
||||||
=> command::share::list(&mut state),
|
=> command::share::list(&state),
|
||||||
|
|
||||||
Some("n" | "new")
|
Some("n" | "new")
|
||||||
=> command::share::new(&mut state),
|
=> command::share::new(&mut state),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
use pico_args::Arguments;
|
use pico_args::Arguments;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
env::{ env_var, REPO_FILE, TMUX },
|
env::TMUX,
|
||||||
error,
|
error,
|
||||||
flag::Flags,
|
flag::Flags,
|
||||||
util::{ find, session_name }
|
util::{ find, session_name }
|
||||||
|
@ -82,7 +82,7 @@ pub struct Repository {
|
||||||
|
|
||||||
impl Repository {
|
impl Repository {
|
||||||
pub fn find() -> Option<Repository> {
|
pub fn find() -> Option<Repository> {
|
||||||
let path = find(&env_var(REPO_FILE), env::current_dir().unwrap());
|
let path = find(".git", env::current_dir().unwrap());
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
||||||
let inner = Repository {
|
let inner = Repository {
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn terminal_enforce() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// recursively propagate up directories to find a child
|
/// recursively propagate up directories to find a child
|
||||||
pub fn find(target: &str, path: PathBuf) -> Option<PathBuf> {
|
pub fn find(target: &'static str, path: PathBuf) -> Option<PathBuf> {
|
||||||
if path.join(target).exists() { return Some(path); }
|
if path.join(target).exists() { return Some(path); }
|
||||||
|
|
||||||
let parent = path.parent();
|
let parent = path.parent();
|
||||||
|
|
Loading…
Reference in a new issue