Skip to content

Commit

Permalink
feat: add *Nushell* autostart script
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenxxiu committed Apr 28, 2024
1 parent 65a7fcf commit 7c5772b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions zellij-utils/assets/shell/auto-start.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if 'ZELLIJ' not-in $env {
if $env.ZELLIJ_AUTO_ATTACH? == 'true' {
zellij attach --create
} else {
zellij
}
if $env.ZELLIJ_AUTO_EXIT? == 'true' {
exit
}
}
14 changes: 13 additions & 1 deletion zellij-utils/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ pub const ZSH_AUTO_START_SCRIPT: &[u8] = include_bytes!(concat!(
"assets/shell/auto-start.zsh"
));

pub const NU_AUTO_START_SCRIPT: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
"assets/shell/auto-start.nu"
));

pub fn add_layout_ext(s: &str) -> String {
match s {
c if s.ends_with(".kdl") => c.to_owned(),
Expand Down Expand Up @@ -619,6 +625,13 @@ impl Setup {
}

fn generate_auto_start(shell: &str) {
let mut out = std::io::stdout();

if shell.to_lowercase() == "nu" {
let _ = out.write_all(NU_AUTO_START_SCRIPT);
return;
}

let shell: Shell = match shell.to_lowercase().parse() {
Ok(shell) => shell,
_ => {
Expand All @@ -627,7 +640,6 @@ impl Setup {
},
};

let mut out = std::io::stdout();
match shell {
Shell::Bash => {
let _ = out.write_all(BASH_AUTO_START_SCRIPT);
Expand Down

0 comments on commit 7c5772b

Please sign in to comment.