Feature: Add alias support for zoxide with tests #1150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Add alias support to zoxide.
This PR introduces alias support to zoxide, allowing users to associate short names with frequently used directories. The feature integrates cleanly into the existing database format and query logic without adding overhead to normal scoring or traversal.
Why?
Aliases are a common quality-of-life feature in directory jumpers. Users often want human-friendly shortcuts that aren’t tied to fuzzy matching or scoring.
Example:
This gives users predictable “bookmarks” while still benefiting from zoxide’s ranking system.
What this PR adds
New alias field on database entries with support for fuzzy matching aliases for easier jumping to frequently used directories.
Support for:
Adding aliases (
zoxide add --alias name path)Resolving aliases via the normal z command.
Searching using alias names alongside paths.
Aliases participate in fuzzy matching, first-match, and interactive modes.
Zero behavioral regression for existing users.
Implementation notes
Alias values are stored as
Option<String>for ownership for database serialization.Matching logic was added in
Stream::filter_by_keywordsand integrates with the existing lowercase-search pipeline.Editing existing aliases intentionally deferred for a separate PR: this PR focuses on core resolution + DB integration.
Tests
The test suite was updated to include:
Matching by alias.
Behavior when running
zoxide addon a directory with an alias without providing a new alias.Fallback behavior when paths and aliases overlap.
Happy to add more if needed, especially around interactive mode or DB serialization, but these tests cover the core logic.