Skip to main content

Dtags: Directory Tags for Lazy Programmers

Build CodeQL codecov PyPI version GitHub license Python version

Dtags is a command-line tool that lets you tag directories for faster filesystem navigation and command execution.

Demo GIF

Requirements

  • Recent versions of Bash, Zsh or Fish
  • Python 3.6+

Installation

Install via pip:

pip install dtags

For Bash, add the following line in ~/.bashrc:

source <(dtags-activate)

For Zsh, add the following line in ~/.zshrc:

autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit

source <(dtags-activate)

For Fish, add the following line in ~/.config/fish/config.fish:

dtags-activate fish | source

For Git Bash on Windows, add the following lines in ~/.bashrc:

export DTAGS_GIT_BASH=1
source <(dtags-activate)

Restart your shell. The following commands will be available after:

tag --help
untag --help
tags --help
d --help
run --help

Tab-completion should work out-of-the-box.

Usage

Tag directories with tag:

# Tag directory ~/foo with "work" (tags are indicated with the "@" prefix)
$ tag ~/foo -t work
/home/user/foo +@work

# If tag names are not specified, directory basenames are used instead
$ tag ~/foo
/home/user/foo +@foo

# Tag directories ~/bar and ~/baz with "app" and "work" (many-to-many)
$ tag ~/bar ~/baz -t app work
/home/user/bar +@app +@work
/home/user/baz +@app +@work

Execute commands in one or more directories with run:

# Run "git status" in all directories tagged "work"
$ run work -c git status

# Run "git status" in directories ~/foo and ~/bar
$ run ~/foo ~/bar -c git status

# Mix tags and directory paths
$ run work ~/foo -c git status

Change directories by path or tag with d:

# Go to directory tagged "work" 
# If there are multiple directories, a selection prompt is displayed
$ d work

# Go to directory ~/foo (works just like cd)
$ d ~/foo

# Use -t/--tag to always assume the argument is a tag
$ d -t foo

Untag directories with untag:

# Remove tags "app" and "work" from directory ~/foo and ~/bar
$ untag ~/foo ~/bar -t app work

# Remove all tags from directory ~/foo
$ untag ~/foo

# Remove tag "app" from all directories
$ untag -t app

Manage tags with tags:

# List all tags
$ tags

# List all tags in JSON format
$ tags --json

# Clean invalid directories
$ tags --clean

# Remove all tags
$ tags --purge

Use --help to see more information on each command.

Technical Notes

  • Tags are saved in ~/.dtags directory (created when a dtags command is first run).
  • The files in ~/.dtags are not meant to be edited manually.
  • By default, directory paths take precedence over tags when name collisions occur.
  • Tag names are automatically slugified (e.g. "foo bar" to "foo-bar").
  • Tag names are displayed with the "@" character prefix for easy identification.
  • Directory paths and tag names are ordered alphabetically.

Uninstallation

Run the following commands to completely uninstall dtags:

$ pip uninstall dtags
$ rm -rf ~/.dtags

Then remove the dtags-activate line from your shell runtime configuration.

Metadata

Release files for dtags 4.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dtags 4.0.4
File Size Uploaded
dtags-4.0.4.tar.gz 340.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dtags 4.0.4
File Interpreter ABI Platform
dtags-4.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 355.7 kB

Release files / dtags-4.0.4.tar.gz

Download URL dtags-4.0.4.tar.gz
Size 340.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8b53dc50efebb0a91a9d80f01857be3f6189a4fb1374891275f2accc199138eb
BLAKE2b-256 checksum
How to use checksums
6c57e20ddf69c3cd39ad529958c9af44c060f50aa754b58fc1e88ebe14213a2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / dtags-4.0.4-py3-none-any.whl

Download URL dtags-4.0.4-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
263a1c31720fe71506d668cefcbca5a690216f9bc3dfa1ddf39914f83a8188e8
BLAKE2b-256 checksum
How to use checksums
cc3007526b13da0bc59aaef748877db18ca6c620d8d43db342e71a55c545d4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

4.0.4 This release

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.2.4

1 release file

3.2.3

1 release file

3.2.2

1 release file

3.2.1

1 release file

3.2.0

1 release file

3.1.2

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.0.7

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page