Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ lacy init fish | source

</details>

<details>
<summary>Nushell</summary>

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")
```

</details>

<details>
<summary>PowerShell</summary>

Expand Down
41 changes: 36 additions & 5 deletions docs/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 at [`--cmd`](#--cmd).

```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")
```

### PowerShell

```powershell
Expand All @@ -42,8 +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]
> 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*
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 4 additions & 1 deletion src/cmd/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ $ echo \"eval \\\"\\$(lacy init bash)\\\"\" >> ~/.bashrc
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

PowerShell:
$ echo \"lacy init powershell | Out-String | iex\" >> $PROFILE"
)]
pub struct Init {
/// Currently supported shells: bash, fish, zsh, powershell
/// Currently supported shells: bash, fish, zsh, nu, powershell
pub shell: String,

/// Allows you to specify another command than cd, e.g. z
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ 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"));
let _ = engine.add_template("powershell", include_str!("../../templates/powershell.ps1"));

// Overwrite the default cd_cmd for certain shells
let cd_cmd = if cd_cmd == "builtin cd" {
match shell {
"powershell" => "Set-Location",
// Nushell does not have a builtin command
"nu" => "cd",
_ => cd_cmd,
}
} else {
Expand Down Expand Up @@ -74,6 +77,9 @@ mod tests {
engine
.add_template("fish", include_str!("../../templates/fish.fish"))
.unwrap();
engine
.add_template("nu", include_str!("../../templates/nu.nu"))
.unwrap();
engine
.add_template("powershell", include_str!("../../templates/powershell.ps1"))
.unwrap();
Expand Down
43 changes: 43 additions & 0 deletions templates/nu.nu
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It does, when given lacy only returns the name of the folder instead of the whole path :)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ah, that must have slipped through somehow. I didn't add the definitions for every argument to nu, only the main commands. I removed that (so no completion for lacy init/help/complete/prompt), it's not worth the effort imo.
Should work now

}

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 "\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" {
{{ cd }} $new_path
} else {
print $"Error: No matching directory found for '($query)'"
}
}
}
use lacy {{ lacy_cmd }}
# END generated Lacy shell config
Loading