Command-line tool to bookmark directories and jump to them quickly.
- Save a directory under a short alias.
- Jump to saved directories from any shell.
- List, find, update, and remove saved entries.
- Rank aliases using frequency and recency.
- Diagnose missing, inaccessible, moved, and duplicate saved directories.
- Track history and usage stats safely across concurrent shells.
- Optional bash helpers and autocompletion.
- Bash (or compatible shell)
- Python 3
- SQLite (bundled with Python)
- Clone this repository.
- Add the following to your shell profile (
~/.bashrc,~/.zshrc, or similar):
export MYDIRS_DIRECTORY="/absolute/path/to/mydirs/src"
source "$MYDIRS_DIRECTORY/bashrc.sh"This:
- Sets up
PYTHONPATHto include the package. - Adds the
mydirsalias. - Enables bash autocompletion.
- Installs optional helper functions (
my,myd,mk,m).
Run the installer to append configuration to ~/.profile:
./install.shIf you use gil-install, you can run:
gil-install -iSee: https://github.com/adrianogil/gil-tools/blob/master/src/python/gil_install.py
MYDIRS_DIRECTORY: Path to this repository'ssrcdirectory.MYDIRS_DB(optional): Directory where data files are stored. Defaults to../db/relative toMYDIRS_DIRECTORY.- Data files include:
mydirs.sqlite(saved paths)mydirs.history(jump history)mydirs_stats.json(legacy usage stats, imported once when present)
- Data files include:
Example:
export MYDIRS_DB="$HOME/.local/share/mydirs/"Aliases are case-sensitive. Exact alias commands treat characters such as %
and _ literally rather than as database wildcard characters.
The SQLite schema is versioned and upgraded automatically. Existing aliases
remain valid. On the first upgrade, valid counts in the legacy
mydirs_stats.json file are imported without modifying or deleting that file.
Usage counts and last-used timestamps are then maintained in SQLite with atomic
updates, so simultaneous shells cannot lose increments. History updates use a
portable sidecar lock and atomic replacement on macOS, Linux, and Termux.
mydirs -h
# or
mydirs --helpmydirs -s <alias>
# or
mydirs --save <alias>If <alias> is omitted, the current folder name is used.
mydirs -o <alias>
# or
mydirs --open <alias>mydirs -r <alias>
# or
mydirs --remove <alias>mydirs -u <alias>
# or
mydirs --update <alias>mydirs -l
# or
mydirs --list--list retains its alphabetical, alias:path output for compatibility.
mydirs --rankNormal --open navigation increments the alias's use count and records its
last-used time. Ranking uses this deterministic integer formula:
age_days = 30 if last_used is unknown else max(0, (now - last_used) // 86400)
score = use_count * 30000 // (age_days + 30)
New aliases with no uses have score zero. Imported legacy counts have no timestamp, so they start with a conservative 30-day age. Ties are resolved by most recent use, then higher use count, then the alias's case-sensitive UTF-8 byte order, then its database ID. Autocomplete and the optional fuzzy-picker helpers use the same ranking. A future last-used timestamp is treated as zero days old.
mydirs -f <search>
# or
mydirs --find <search>mydirs -p <alias>
# or
mydirs --path <alias>mydirs -q
# or
mydirs --currentmydirs -bh <number> # Show last N entries
mydirs -bk # Go back to previous directory
# long options
mydirs --history <number>
mydirs --backExport the directory history to a portable, versioned JSON file:
mydirs --export-history mydirs-history.jsonRestore the history from a backup:
mydirs --import-history mydirs-history.jsonImport validates the complete backup before replacing the current history. It rejects malformed or unsupported JSON without changing the existing history, and collapses consecutive duplicate paths just like normal history tracking.
mydirs -c
# or
mydirs --clean--clean is the legacy mutating cleanup command. For a safe inspection first,
use the doctor.
mydirs --doctorDoctor is read-only. It reports:
MISSING: the saved path no longer exists, including dangling symlinks.INACCESSIBLE: the path cannot be inspected, read, or entered.DUPLICATE: another alias resolves to the same directory, including a symlink and its target.MOVED: the saved filesystem device/inode identity was found at a plausible nearby path.NOT-DIRECTORY: the saved path now names another kind of filesystem entry.
Moved suggestions are conservative: candidates come only from other saved paths, navigation history, and the missing path's immediate parent, and must match the device/inode identity captured when the alias was saved or updated. Doctor never changes a record. To accept a suggestion explicitly:
mydirs --repair-moved <alias> <new-path>Repair succeeds only when the new path is an accessible directory with the
same stored filesystem identity. It preserves the alias's usage history. For a
deliberate unrelated replacement, change to the new directory and continue to
use the backward-compatible mydirs --update <alias> command.
mydirs --statsStats retain the historical path: count display and are now derived from the
transactional SQLite usage records.
mydirs --db# Save current directory as "work"
mydirs -s work
# Jump to it
mydirs -o work
# Update alias to the current directory
mydirs -u work
# List all entries
mydirs -lThese are optional but useful if you source src/bashrc.sh.
mysaves the current directory or opens an alias.my(save current directory)my <alias>(open alias)
mydopens a fuzzy picker for commands (requiresdefault-fuzzy-finder).mkopens a fuzzy picker for aliases.mopens a tmux session named after the alias (requirestmuxandtenter/tnew).
- Remove
mydirsentries from your shell profile (~/.bashrc,~/.zshrc, or~/.profile). - Remove the data directory (
$MYDIRS_DB) if you want to delete saved paths.
PRs are welcome. Please keep changes focused and add documentation for new behavior.
This project is in an early/alpha state and may not follow consistent coding standards.