Skip to content

Conversation

@tahamahmoud7097-wq
Copy link

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:

~$ zoxide add --alias proj ~/path/to/complicated-project
~$ z proj # instantly jump to the project
~/path/to/complicated-project $

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_keywords and 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 add on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant