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;
|
||||
} else {
|
||||
// fallback behavior is list
|
||||
list();
|
||||
list(&state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ pub fn has(state: &mut State) {
|
|||
exit( if success { 0 } else { 1 });
|
||||
}
|
||||
|
||||
pub fn list() {
|
||||
pub fn list(state: &State) {
|
||||
// get session list
|
||||
let sessions = util::get_sessions().unwrap_or(Vec::new());
|
||||
|
||||
|
@ -150,23 +150,27 @@ pub fn list() {
|
|||
|
||||
// get attached session symbol
|
||||
let attach_symbol = env_var(env::ATTACH_SYMBOL);
|
||||
let current_symbol = env_var(env::CURRENT_SYMBOL);
|
||||
|
||||
// pretty print session list
|
||||
println!("sessions:");
|
||||
for session in sessions.into_iter() {
|
||||
let name = session.name.unwrap_or("[untitled]".to_string());
|
||||
let id = session.id.unwrap();
|
||||
|
||||
let attached = session.attached.unwrap_or(0) > 0;
|
||||
let current = Some(name.clone()) == state.title;
|
||||
|
||||
println!(
|
||||
" {name} ({bold}{blue}{id}{reset}) {bold}{green}{attach}{reset}",
|
||||
" {current} {name}{reset} ({bold}{blue}{id}{reset}) {bold}{green}{attach}{reset}",
|
||||
// values
|
||||
attach = if attached { attach_symbol.clone() } else { "".to_string() },
|
||||
current = if current { current_symbol.clone() } else { " ".to_string() },
|
||||
// formatting
|
||||
bold = style::Bold,
|
||||
blue = color::Fg(color::Blue),
|
||||
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 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 TMUX: &str = "TMUX";
|
||||
|
|
|
@ -148,10 +148,15 @@ REMUX_ATTACH_SYMBOL
|
|||
by the 'list' command.
|
||||
Default: '*'
|
||||
|
||||
REMUX_CURRENT_SYMBOL
|
||||
Changes the symbol displayed to denote the current session
|
||||
in the 'list' command.
|
||||
Default: '>'
|
||||
|
||||
REMUX_NEW_WINDOW
|
||||
Provides a default window name when creating a session with
|
||||
the 'new' command, if not empty.
|
||||
Default: ''"),
|
||||
Default: (unset)"),
|
||||
|
||||
// not found
|
||||
_ => error::no_help(topic.unwrap())
|
||||
|
|
|
@ -50,7 +50,7 @@ fn main() {
|
|||
=> command::share::has(&mut state),
|
||||
|
||||
Some("l" | "ls" | "list")
|
||||
=> command::share::list(),
|
||||
=> command::share::list(&state),
|
||||
|
||||
Some("n" | "new")
|
||||
=> command::share::new(&mut state),
|
||||
|
|
Loading…
Reference in a new issue