list command now shows a symbol in front of the current session
This commit is contained in:
parent
97f546a69c
commit
e930af1027
4 changed files with 17 additions and 7 deletions
|
@ -83,7 +83,7 @@ pub fn context_action(state: &State) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// fallback behavior is list
|
// fallback behavior is list
|
||||||
list();
|
list(&state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ pub fn has(state: &mut State) {
|
||||||
exit( if success { 0 } else { 1 });
|
exit( if success { 0 } else { 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list() {
|
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());
|
||||||
|
|
||||||
|
@ -149,24 +149,28 @@ pub fn list() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get attached session symbol
|
// get attached session symbol
|
||||||
let attach_symbol = env_var(env::ATTACH_SYMBOL);
|
let attach_symbol = env_var(env::ATTACH_SYMBOL);
|
||||||
|
let current_symbol = env_var(env::CURRENT_SYMBOL);
|
||||||
|
|
||||||
// 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 name = session.name.unwrap_or("[untitled]".to_string());
|
let name = 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;
|
||||||
|
let current = Some(name.clone()) == state.title;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
" {name} ({bold}{blue}{id}{reset}) {bold}{green}{attach}{reset}",
|
" {current} {name}{reset} ({bold}{blue}{id}{reset}) {bold}{green}{attach}{reset}",
|
||||||
// values
|
// values
|
||||||
attach = if attached { attach_symbol.clone() } else { "".to_string() },
|
attach = if attached { attach_symbol.clone() } else { "".to_string() },
|
||||||
|
current = if current { current_symbol.clone() } else { " ".to_string() },
|
||||||
// formatting
|
// formatting
|
||||||
bold = style::Bold,
|
bold = style::Bold,
|
||||||
blue = color::Fg(color::Blue),
|
blue = color::Fg(color::Blue),
|
||||||
green = color::Fg(color::LightGreen),
|
green = color::Fg(color::LightGreen),
|
||||||
reset = style::Reset
|
reset = style::Reset,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::env::var;
|
||||||
pub type EnvVar = (&'static str, &'static str);
|
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 NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
||||||
|
|
||||||
pub static TMUX: &str = "TMUX";
|
pub static TMUX: &str = "TMUX";
|
||||||
|
|
|
@ -148,10 +148,15 @@ REMUX_ATTACH_SYMBOL
|
||||||
by the 'list' command.
|
by the 'list' command.
|
||||||
Default: '*'
|
Default: '*'
|
||||||
|
|
||||||
|
REMUX_CURRENT_SYMBOL
|
||||||
|
Changes the symbol displayed to denote the current session
|
||||||
|
in the 'list' command.
|
||||||
|
Default: '>'
|
||||||
|
|
||||||
REMUX_NEW_WINDOW
|
REMUX_NEW_WINDOW
|
||||||
Provides a default window name when creating a session with
|
Provides a default window name when creating a session with
|
||||||
the 'new' command, if not empty.
|
the 'new' command, if not empty.
|
||||||
Default: ''"),
|
Default: (unset)"),
|
||||||
|
|
||||||
// not found
|
// not found
|
||||||
_ => error::no_help(topic.unwrap())
|
_ => error::no_help(topic.unwrap())
|
||||||
|
|
|
@ -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(),
|
=> command::share::list(&state),
|
||||||
|
|
||||||
Some("n" | "new")
|
Some("n" | "new")
|
||||||
=> command::share::new(&mut state),
|
=> command::share::new(&mut state),
|
||||||
|
|
Loading…
Reference in a new issue