list attach symbol is now configurable

This commit is contained in:
Valerie Wolfe 2024-03-06 16:12:54 -05:00
parent 9c814c43f4
commit be593c82e7
2 changed files with 11 additions and 3 deletions

View file

@ -85,6 +85,10 @@ using an AUR package manager such as <a href="https://github.com/Morganamilo/par
Install the package using Cargo with the command <code>cargo install tmux-remux</code>. Install the package using Cargo with the command <code>cargo install tmux-remux</code>.
</details> </details>
## Configuration
The pretty-print attached symbol (default: `*`) can be set manually by setting `REMUX_ATTACH_SYMBOL`.
## Libraries ## Libraries
- [pico-args](https://crates.io/crates/pico_args) — argument parsing - [pico-args](https://crates.io/crates/pico_args) — argument parsing

View file

@ -1,5 +1,6 @@
//! globally available tmux commands. //! globally available tmux commands.
use std::{ use std::{
env::var,
ffi::OsString, ffi::OsString,
process::exit process::exit
}; };
@ -117,6 +118,9 @@ pub fn list() {
return; return;
} }
// get attached session symbol
let attach_symbol = var("REMUX_ATTACH_SYMBOL").unwrap_or("*".to_string());
// pretty print session list // pretty print session list
println!("sessions:"); println!("sessions:");
for session in sessions.into_iter() { for session in sessions.into_iter() {
@ -125,9 +129,9 @@ pub fn list() {
let attached = session.attached.unwrap_or(0) > 0; let attached = session.attached.unwrap_or(0) > 0;
println!( println!(
" {group} ({bold}{blue}{id}{reset}) {bold}{green}{attach_sym}{reset}", " {group} ({bold}{blue}{id}{reset}) {bold}{green}{attach}{reset}",
// value // values
attach_sym = if attached { "\u{F0339}" } else { "" }, attach = if attached { attach_symbol.clone() } else { "".to_string() },
// formatting // formatting
bold = style::Bold, bold = style::Bold,
blue = color::Fg(color::Blue), blue = color::Fg(color::Blue),