Mark current session in the output of list-sessions
This commit is contained in:
parent
d231d28d7c
commit
2487256664
2 changed files with 10 additions and 2 deletions
|
|
@ -58,10 +58,17 @@ fn list_sessions() {
|
||||||
match fs::read_dir(&*ZELLIJ_SOCK_DIR) {
|
match fs::read_dir(&*ZELLIJ_SOCK_DIR) {
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
let mut is_empty = true;
|
let mut is_empty = true;
|
||||||
|
let session_name = std::env::var("ZELLIJ_SESSION_NAME").unwrap_or("".into());
|
||||||
files.for_each(|file| {
|
files.for_each(|file| {
|
||||||
let file = file.unwrap();
|
let file = file.unwrap();
|
||||||
if file.file_type().unwrap().is_socket() {
|
if file.file_type().unwrap().is_socket() {
|
||||||
println!("{}", file.file_name().into_string().unwrap());
|
let fname = file.file_name().into_string().unwrap();
|
||||||
|
let suffix = if session_name == fname {
|
||||||
|
" (current)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
println!("{}{}", fname, suffix);
|
||||||
is_empty = false;
|
is_empty = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
use zellij_utils::cli::CliArgs;
|
use zellij_utils::cli::CliArgs;
|
||||||
use zellij_utils::{
|
use zellij_utils::{
|
||||||
channels::{SenderType, SenderWithContext, SyncChannelWithContext},
|
channels::{SenderType, SenderWithContext, SyncChannelWithContext},
|
||||||
consts::ZELLIJ_IPC_PIPE,
|
consts::{SESSION_NAME, ZELLIJ_IPC_PIPE},
|
||||||
errors::{ClientContext, ContextType, ErrorInstruction},
|
errors::{ClientContext, ContextType, ErrorInstruction},
|
||||||
input::config::Config,
|
input::config::Config,
|
||||||
input::options::Options,
|
input::options::Options,
|
||||||
|
|
@ -95,6 +95,7 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
|
||||||
.write(clear_client_terminal_attributes.as_bytes())
|
.write(clear_client_terminal_attributes.as_bytes())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
std::env::set_var(&"ZELLIJ", "0");
|
std::env::set_var(&"ZELLIJ", "0");
|
||||||
|
std::env::set_var(&"ZELLIJ_SESSION_NAME", &*SESSION_NAME);
|
||||||
|
|
||||||
#[cfg(not(any(feature = "test", test)))]
|
#[cfg(not(any(feature = "test", test)))]
|
||||||
spawn_server(&*ZELLIJ_IPC_PIPE).unwrap();
|
spawn_server(&*ZELLIJ_IPC_PIPE).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue