Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ Add this into your `config.fish`.
als init fish | source
```

### Nushell

Add the following to the end of your Nushell env file (find it by running $nu.env-path in Nushell)::
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: why :: at the end(same below)

```shell
mkdir ~/.cache/als
als init nu | save -f ~/.cache/als/init.nu
```

And add the following to the end of your Nushell configuration (find it by running $nu.config-path)::
```shell
source ~/.cache/als/init.nu
```

## Alias config

Put a config file in `~/.config/alias.toml`.
Expand Down
4 changes: 4 additions & 0 deletions src/init/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod bash;
mod fish;
mod nu;
mod pwsh;
mod zsh;

Expand All @@ -20,6 +21,9 @@ pub(crate) fn init(config: AliasConfig, args: Vec<String>) {
"fish" => {
fish::init(config);
}
"nu" => {
nu::init(config);
}
_ => unreachable!("Unsupported shell"),
}
}
1 change: 1 addition & 0 deletions src/init/nu.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$env.ALIAS_SHELL = 'nu'
22 changes: 22 additions & 0 deletions src/init/nu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::model::{AliasConfig, AliasVisitor, VisitorAliasValue};

const NU_SCRIPT: &str = include_str!("./nu.nu");

#[inline]
pub fn print_alias<V: std::fmt::Display>(name: &str, value: V) {
println!("alias {} = {}", name, value)
}

struct NuVisitor {}

impl AliasVisitor for NuVisitor {
fn visit<'a>(&mut self, (name, value): (&'a str, VisitorAliasValue<'a>)) {
print_alias(name, value);
}
}

pub fn init(config: AliasConfig) {
println!("{NU_SCRIPT}");

config.visit_aliases("nu", &mut NuVisitor {});
}