Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

to

Persistent, keyword-based directory shortcuts with longest-prefix matching, expirations, recents, bulk add, and shell completions — reimplemented in Rust.

Note: As a standalone binary, goto cannot change the parent shell’s directory. Wrap it in a shell function to cd into the printed path (see “Shell integration”).

Installation

Install directly from the repository (latest main):

cargo install --git https://github.com/kgruiz/goto.git to

Or build from a local checkout (handy while iterating):

git clone https://github.com/kgruiz/goto.git
cd goto
cargo build --release

If you already have the repo locally, you can run the helper script which wraps cargo install --locked --force against the current checkout:

./install

Any extra flags are forwarded to cargo install (e.g., ./install --features foo). Requires Rust 1.85+ (edition 2024).

Quick start

to --add proj ~/code/my-project          # save keyword
to proj/src/lib                          # jump (creates missing dirs)
to --print-path proj/docs                # print resolved path
to --list proj                           # search keyword + path
to --list                                # list all shortcuts
to --rm proj                             # remove

Features

  • Keyword shortcuts stored in ~/.goto/to_dirs; expirations in ~/.goto/to_dirs_meta; recents in ~/.goto/to_dirs_recent; sort preference in ~/.goto/to_zsh_config.
  • Longest-prefix resolution for keyword/any/depth.
  • Automatic directory creation (opt out with --no-create).
  • Recents tracking for recent sort mode.
  • Expiring shortcuts via --expire <epoch>.
  • Bulk add via glob patterns; copy keywords or retarget paths.
  • Search shortcuts by keyword and/or path with smart-case regex, glob, or fuzzy matching.
  • Colorful, zsh-like output (disable with --no-color or NO_COLOR=1).
  • Shell completions with dynamic keyword/path suggestions.

Options (summary)

  • -a, --add [<keyword>] <path> [-x|--expire <ts>]
  • -b, --bulk-add <pattern>
  • -c, --copy <existing> <new>
  • -f, --force (with add/copy/bulk-add) to replace an existing keyword or skip duplicate-path confirmation
  • -r, --remove <keyword>
  • -l, --list[=QUERY] [-g|--glob | -F|--fuzzy] [-p|--path | -A|--any | -B|--both] [-w|--within <path> | -H|--here] [-d|--max-depth N] [-j|--json] [-n|--limit N]
  • -P, --print-path <target>
  • -u, --cursor (open in Cursor) or -C, --code (open in VS Code) — mutually exclusive
  • -N, --no-create
  • -s, --sort added|alpha|recent (and --show-sort)
  • --completions <shell> (alias: --generate-completions)
  • --write-default-completions (with --completions zsh; aliases: --write-completions, --install-completions)
  • --no-color

Shell integration (cd)

to prints the resolved path; to change your shell directory, wrap it:

function to() {
  local dest
  dest="$(command to --print-path "$@")" || return
  [ -z "$dest" ] && return
  mkdir -p "$dest"
  cd "$dest"
}

For cursor support, keep passing -u to the binary; the wrapper simply handles cd.

Completions

Generate completion scripts:

to --completions zsh   > _to
to --completions bash  > to.bash
to --completions fish  > to.fish

# write zsh completions to the default location (~/.config/zsh/completions/_to)
to --completions zsh --write-completions

Zsh uses dynamic completion hooks for path-aware keyword + subpath behavior.

Notes

  • Implemented in Rust; uses the same config files for compatibility.
  • Dynamic completion handled by the binary; no sourcing a large shell script.
  • Requires a wrapper to cd (common for standalone binaries).

Configuration details

  • Files: ~/.goto/to_dirs, ~/.goto/to_dirs_meta, ~/.goto/to_dirs_recent, ~/.goto/to_zsh_config.
  • Env overrides (useful for testing or custom setups): TO_CONFIG_FILE, TO_CONFIG_META_FILE, TO_USER_CONFIG_FILE, TO_RECENT_FILE.
  • Env overrides (useful for tests): TO_CONFIG_FILE, TO_CONFIG_META_FILE, TO_USER_CONFIG_FILE, TO_RECENT_FILE.
  • Sorting: alpha (natural), added (file order), recent (uses recents file).

Search

  • to --list QUERY searches shortcut keywords with an unanchored regular expression by default; omit QUERY to list everything.
  • Default regex, glob, and fuzzy matching use smart case: an all-lowercase query is case-insensitive, while any uppercase character makes the query case-sensitive.
  • Change fields with -p/--path for paths only, -A/--any for keyword or path, or -B/--both to require matches in both.
  • Scope results to a root with -w/--within <path> or -H/--here, and limit depth with -d/--max-depth N (0 = root only).
  • Pattern modes: regex (default), -g/--glob, or -F/--fuzzy.
  • Fuzzy search ranks keyword matches ahead of path-only matches, then prefers exact, prefix, and substring matches before other subsequence matches.
  • Quote regex and glob patterns to prevent the shell from expanding them before to receives them.
  • Output as JSON with -j/--json; limit rows with -n/--limit.
to --list go                       # regex: matches "goto"
to --list '^go'                    # regex: starts with "go"
to --list 'g.*t'                   # regex: "g" followed later by "t"
to --list --glob '*go*'            # glob: contains "go"
to --list --fuzzy gt               # fuzzy: ranked subsequence match
to --list doc --path               # regex: search stored paths only
to --list doc --any                # regex: search keyword or path
to --list doc --both               # regex: require keyword and path

MSRV

Minimum supported Rust version: 1.85 (edition 2024). Update Cargo.toml and release notes if this changes.

License

GPL-3.0-only. See LICENSE.

Changelog

See CHANGELOG.md.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages