From 565c2186fcc882afeda0e1e16078cb8392ebea5e Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 14:33:31 +0200 Subject: [PATCH 1/9] feat: Add Nushell template --- templates/nu.nu | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 templates/nu.nu diff --git a/templates/nu.nu b/templates/nu.nu new file mode 100644 index 0000000..e95f6f4 --- /dev/null +++ b/templates/nu.nu @@ -0,0 +1,43 @@ +# START generated Lacy shell config +module lacy { + def lacy-query-to-completion [context: string] { + let query = ($context | split row " " | skip 1 | str join " ") + if $query == "" { + return (ls -a | where type == dir | get name) + } + if $context ends-with " " { + return (lacy complete --basename -- $"($query) " | split row " " | uniq) + } + return (lacy complete --basename -- $query | split row " " | uniq) + } + + def lacy-dir-names [context: string] { + { + options: { + case_sensitive: false, + completion_algorithm: fuzzy, + sort: false, + }, + completions: (lacy-query-to-completion $context) + } + } + + export def --env {{ lacy_cmd }} [...args: string@lacy-dir-names] { + let query = ($args | str join " ") + let new_path = (lacy prompt {{ return_all }}-- $"($query)") + if $new_path == "~" { + {{ cd }} ~ + {% if custom_fuzzy.enabled %} } else if ($new_path | str contains " ") { + let selected = ($new_path | split row " " | str join "\n" | {{ custom_fuzzy.cmd }}) + if ($selected | path exists) and ($selected | path type) == "dir" { + {{ cd }} $selected + } + {% endif %}} else if ($new_path | path exists) and ($new_path | path type) == "dir" { + {{ cd }} $new_path + } else { + print $"Error: No matching directory found for '($query)'" + } + } +} +use lacy {{ lacy_cmd }} +# END generated Lacy shell config From 53587b854a33d728e1b0ccf8731a408d4d9e69ce Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 15:19:13 +0200 Subject: [PATCH 2/9] fix: Call custom fuzzy correct --- templates/nu.nu | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/templates/nu.nu b/templates/nu.nu index e95f6f4..1c3eb73 100644 --- a/templates/nu.nu +++ b/templates/nu.nu @@ -27,12 +27,12 @@ module lacy { let new_path = (lacy prompt {{ return_all }}-- $"($query)") if $new_path == "~" { {{ cd }} ~ - {% if custom_fuzzy.enabled %} } else if ($new_path | str contains " ") { - let selected = ($new_path | split row " " | str join "\n" | {{ custom_fuzzy.cmd }}) + {% if custom_fuzzy.enabled %} } else if ($new_path | str contains "\n") { + let selected = ($new_path | {{ custom_fuzzy.cmd }}) if ($selected | path exists) and ($selected | path type) == "dir" { {{ cd }} $selected } - {% endif %}} else if ($new_path | path exists) and ($new_path | path type) == "dir" { + {% endif %} } else if ($new_path | path exists) and ($new_path | path type) == "dir" { {{ cd }} $new_path } else { print $"Error: No matching directory found for '($query)'" @@ -40,4 +40,9 @@ module lacy { } } use lacy {{ lacy_cmd }} + +export extern "lacy help" [] +export extern "lacy prompt" [] +export extern "lacy complete" [] +export extern "lacy init" [] # END generated Lacy shell config From fd5dbe7e9708d787ac0b89592f6a7f8079c7c525 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 15:31:59 +0200 Subject: [PATCH 3/9] feat: Add Nushell template to the template engine --- src/cmd/commands.rs | 7 +++++-- src/cmd/init.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cmd/commands.rs b/src/cmd/commands.rs index 19bba89..45ca5de 100644 --- a/src/cmd/commands.rs +++ b/src/cmd/commands.rs @@ -72,10 +72,13 @@ Bash: $ echo \"eval \\\"\\$(lacy init bash)\\\"\" >> ~/.bashrc Fish: -$ echo \"lacy init fish | source\" >> ~/.config/fish/config.fish" +$ echo \"lacy init fish | source\" >> ~/.config/fish/config.fish + +Nu (check docs before updating init options for nu): +$ echo r#'mkdir ($nu.data-dir | path join \"vendor/autoload\"); lacy init nu | save -f ($nu.data-dir | path join \"vendor/autoload/lacy.nu\")'# o>> $nu.config-path" )] pub struct Init { - /// Currently supported shells: bash, fish, zsh + /// Currently supported shells: bash, fish, zsh, nu pub shell: String, /// Allows you to specify another command than cd, e.g. z diff --git a/src/cmd/init.rs b/src/cmd/init.rs index f1dc9ae..d9291a3 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -30,11 +30,17 @@ pub fn shell_config( let _ = engine.add_template("bash", include_str!("../../templates/bash.sh")); let _ = engine.add_template("zsh", include_str!("../../templates/zsh.sh")); let _ = engine.add_template("fish", include_str!("../../templates/fish.fish")); + let _ = engine.add_template("nu", include_str!("../../templates/nu.nu")); engine .template(shell) .render(value! { - cd: cd_cmd, + // Nushell does not have a builtin command + cd: if shell == "nu" && cd_cmd == "builtin cd" { + "cd" + } else { + cd_cmd + }, lacy_cmd: cmd, return_all: if custom_fuzzy.is_some() { String::from("--return-all ") @@ -63,5 +69,8 @@ mod tests { engine .add_template("fish", include_str!("../../templates/fish.fish")) .unwrap(); + engine + .add_template("nu", include_str!("../../templates/nu.nu")) + .unwrap(); } } From 177034f08b16c0b7532cb96fe227cd093ea5c800 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 15:34:05 +0200 Subject: [PATCH 4/9] docs: Add setup docs and nushell notes --- README.md | 13 +++++++++++++ docs/src/setup.md | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 27072a0..0bec6b2 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,19 @@ lacy init fish | source +
+Nushell + +You can't set the lacy alias (`--cmd`) to `cd`. More infos below the table at [Shell Options](https://lacy.tiimo.space/setup.html#shell-options). + +```bash +# $nu.config-path +mkdir ($nu.data-dir | path join "vendor/autoload") +lacy init nu | save -f ($nu.data-dir | path join "vendor/autoload/lacy.nu") +``` + +
+ If your shell is missing, feel free to create an issue! --- diff --git a/docs/src/setup.md b/docs/src/setup.md index 53cd680..66344e9 100644 --- a/docs/src/setup.md +++ b/docs/src/setup.md @@ -27,6 +27,16 @@ eval "$(lacy init bash)" lacy init fish | source ``` +### Nushell + +You can't set the lacy alias (`--cmd`) to `cd`. More infos below the table at [Shell Options](#shell-options). + +```bash +# $nu.config-path +mkdir ($nu.data-dir | path join "vendor/autoload") +lacy init nu | save -f ($nu.data-dir | path join "vendor/autoload/lacy.nu") +``` + ### Other shells Feel free to contribute the init script for your preferred shell. @@ -38,5 +48,10 @@ You can customize the shell script that gets generated by using these options: | Option | Default | Description | | ------ | ------- | ----------- | | `--cd-cmd` | `builtin cd` | Define the command to be used instead of `cd`. (e.g. `--cd-cmd=z`) | -| `--cmd`| `y` | The name of the main lacy command you use for navigating. (e.g. `--cmd=cd`) | +| `--cmd` | `y` | The name of the main lacy command you use for navigating. (e.g. `--cmd=cd`) | | `--custom-fuzzy` | *none* | Configure this to disable lacy's built in UI selector and replace it with your own command. (e.g. `--custom-fuzzy=fzf`) | + +> [!WARNING] +> For Nushell, the default `--cd-cmd` is just `cd`. Nushell doesn't have a `builtin` option, +> so setting it to `cd` will cause a loop. +> It should be possible to bypass this with some tinkering ([issue in nushell repo](https://github.com/nushell/nushell/issues/3792)). Feel free to open a PR if you have a good solution! From 6404791e602c9bc1edef6c8ba218de0cbb7c36b3 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 15:35:55 +0200 Subject: [PATCH 5/9] chore: Bump dependency versions --- Cargo.lock | 64 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 6 ++--- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cb4fb0..0e139c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "anstream" -version = "0.6.18" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", "anstyle-parse", @@ -19,15 +19,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" dependencies = [ "utf8parse", ] @@ -80,9 +80,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "clap" -version = "4.5.48" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" dependencies = [ "clap_builder", "clap_derive", @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.48" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ "anstream", "anstyle", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" dependencies = [ "heck", "proc-macro2", @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "colorchoice" @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.5.1" +version = "3.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73736a89c4aff73035ba2ed2e565061954da00d4970fc9ac25dcc85a2a20d790" +checksum = "e0b1fab2ae45819af2d0731d60f2afe17227ebb1a1538a236da84c93e9a60162" dependencies = [ "dispatch2", "nix", @@ -231,21 +231,21 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.176" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "nix" -version = "0.30.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3" dependencies = [ "bitflags", "cfg-if", @@ -276,18 +276,18 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -300,9 +300,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", @@ -345,9 +345,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -356,9 +356,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.23.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", diff --git a/Cargo.toml b/Cargo.toml index faec2c5..1f797fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,13 +17,13 @@ categories = ["command-line-utilities"] keywords = ["cli", "tool", "utility"] [dependencies] -clap = { version = "4.5.48", features = ["derive"] } -ctrlc = { version = "3.5.1", features = ["termination"] } +clap = { version = "4.6.0", features = ["derive"] } +ctrlc = { version = "3.5.2", features = ["termination"] } dialoguer = "0.12.0" upon = "0.10.0" [dev-dependencies] -tempfile = "3.23.0" +tempfile = "3.27.0" [profile.release] codegen-units = 1 From a109c74e51b04589e7255b13674e4e513bafbe34 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 16:18:59 +0200 Subject: [PATCH 6/9] docs: Improve shell options section --- docs/src/setup.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/src/setup.md b/docs/src/setup.md index 6e3f7ca..dc3f1d0 100644 --- a/docs/src/setup.md +++ b/docs/src/setup.md @@ -29,7 +29,7 @@ lacy init fish | source ### Nushell -You can't set the lacy alias (`--cmd`) to `cd`. More infos below the table at [Shell Options](#shell-options). +You can't set the lacy alias (`--cmd`) to `cd`. More infos at [`--cmd`](#--cmd). ```bash # $nu.config-path @@ -52,13 +52,29 @@ Feel free to contribute the init script for your preferred shell. You can customize the shell script that gets generated by using these options: -| Option | Default | Description | -| ------ | ------- | ----------- | -| `--cd-cmd` | `builtin cd` | Define the command to be used instead of `cd`. (e.g. `--cd-cmd=z`) | -| `--cmd` | `y` | The name of the main lacy command you use for navigating. (e.g. `--cmd=cd`) | -| `--custom-fuzzy` | *none* | Configure this to disable lacy's built in UI selector and replace it with your own command. (e.g. `--custom-fuzzy=fzf`) | +### `--cd-cmd` + +Define the command to be used instead of `cd`. (e.g. `--cd-cmd=z`) + +Default: + +- Bash, ZSH, Fish: `builtin cd` +- Nushell: `cd` +- PowerShell: `Set-Location` + +### `--cmd` + +The name of the main lacy command you use for navigating. (e.g. `--cmd=cd`) + +Default: `y` > [!WARNING] -> For Nushell, the default `--cd-cmd` is just `cd`. Nushell doesn't have a `builtin` option, -> so setting it to `cd` will cause a loop. +> Nushell doesn't have a `builtin cd` option, +> so setting it `--cmd=cd` will cause a loop. > It should be possible to bypass this with some tinkering ([issue in nushell repo](https://github.com/nushell/nushell/issues/3792)). Feel free to open a PR if you have a good solution! + +### `--custom-fuzzy` + +Configure this to disable lacy's built in UI selector and replace it with your own command. (e.g. `--custom-fuzzy=fzf`) + +Default: *none* From 49019309e7d7dd9a07129652b2d5ac0a63c9a03c Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Mon, 30 Mar 2026 16:28:30 +0200 Subject: [PATCH 7/9] fix: Remove external definition of lacy cmds in nu Otherwise all flags must be defined --- templates/nu.nu | 5 ----- 1 file changed, 5 deletions(-) diff --git a/templates/nu.nu b/templates/nu.nu index 1c3eb73..ddec39c 100644 --- a/templates/nu.nu +++ b/templates/nu.nu @@ -40,9 +40,4 @@ module lacy { } } use lacy {{ lacy_cmd }} - -export extern "lacy help" [] -export extern "lacy prompt" [] -export extern "lacy complete" [] -export extern "lacy init" [] # END generated Lacy shell config From 96ff26dd1e4b25bc79d2b359fee5e42bfa8c10b6 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Wed, 1 Apr 2026 19:43:56 +0200 Subject: [PATCH 8/9] chore: Bump changelog and version --- CHANGELOG | 11 +++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a26027c..34698ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.0] - 2026-04-01 + +### Added + +- Nushell support +- Powershell support + +### Fixed + +- Fish integration autocomplete now works as intended + ## [0.6.1] - 2026-01-18 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 0e139c5..4ee53db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "lacy" -version = "0.6.1" +version = "0.7.0" dependencies = [ "clap", "ctrlc", diff --git a/Cargo.toml b/Cargo.toml index 1f797fc..14657ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lacy" description = "Fast magical cd alternative for lazy terminal navigators" -version = "0.6.1" +version = "0.7.0" authors = ["timothebot"] repository = "https://github.com/timothebot/lacy" homepage = "https://github.com/timothebot/lacy" From 5598d8d345b6c8eecd5e409a4f5ac3a318d80ed9 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Wed, 1 Apr 2026 19:47:19 +0200 Subject: [PATCH 9/9] chore: Update cargoHash in flake.nix --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 1a53960..a9f976d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ passthru.updateScript = nix-update-script { }; - cargoHash = "sha256-OJW29CopdO7lbkr0F2KVnfbRGEGIf8J8Vu8YChjeElY="; + cargoHash = "sha256-3K8g/AGpSXFUhgEBg/AzUYsH3vOvsRzAYnrOAZNVS4g="; meta = { description = "Fast magical cd alternative for lacy terminal navigators";