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
19 changes: 19 additions & 0 deletions docs/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,22 @@ Default: `y`
Configure this to disable lacy's built in UI selector and replace it with your own command. (e.g. `--custom-fuzzy=fzf`)

Default: *none*

## Environment variables

### `$LACY_NO_ARGS_PATH`

Controls where you will jump if you use the lacy command without extra arguments.

Default: `~`

### `$LACY_FILTER_CWD`

Controls whether current directory (or its parents) would be ignored when matching.

For example, say you're in `~/git`, you also have `~/Games`, and you use `y .. g`.
- `0` would prompt you to choose between `~/git` and `~/Games`.
- `1` would just jump to `Games`.
- `2` would exclude `git` even if you were in `~/git/lacy` and used `y ... g`.

Default: `1`
15 changes: 14 additions & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::path::{Path, PathBuf};
use std::{
env, fs,
path::{Path, PathBuf},
};

use crate::{
directory::{sub_directories, Directory},
Expand Down Expand Up @@ -58,6 +61,16 @@ impl Query {
directories = part.matching_directories(&directories);
}

// https://lacy.tiimo.space/setup.html#LACY_FILTER_CWD
match env::var("LACY_FILTER_CWD").as_deref() {
Ok("0") => (),
Ok("2") => directories.retain(|dir| {
!fs::canonicalize(dir.location()).is_ok_and(|dir| cwd.starts_with(dir))
}),
Ok("1") | Ok(_) | Err(_) => directories
.retain(|dir| !fs::canonicalize(dir.location()).is_ok_and(|dir| dir == cwd)),
}

directories
.iter()
.map(|dir| dir.location().clone())
Expand Down
Loading