dtags is a lightweight command line tool which lets you:
- Tag and un-tag directories
- Run commands in multiple directories in parallel
- Change directories quickly via tag names
- Use shell variables to reference directories
- Easily manage git repositories, vagrant machines etc.
Check requirements:
- Python 2.7+ or 3.4+
- Recent version of pip
- Recent version of Bash, Zsh or Fish with tab-completion enabled
Install the package:
Add the following line at the end of your shell runtime configuration and reload the shell:
# For zsh, place in ~/.zshrc:
command -v dtags-activate > /dev/null 2>&1 && eval "`dtags-activate zsh`"
# For bash, place in ~/.bashrc (or ~/.bash_profile for OS X):
command -v dtags-activate > /dev/null 2>&1 && eval "`dtags-activate bash`"
# For fish, place in ~/.config/fish/config.fish:
command -v dtags-activate > /dev/null 2>&1; and dtags-activate fish | source
Once installed, you will have the following at your disposal:
- Utility commands
t
,u
,d
,e
,p
- Main command
dtags
All commands come with tab-completion.
Tag directories with t
:
Un-tag directories with u
:
Change directories with d
(designed to fully replace cd
!):
Execute commands in one or more directories with e
:
~$ e app git status # execute 'git status' in all directories tagged 'app'
~$ e ~/vm vagrant halt # regular directory paths are accepted as well
~$ e app,~/vm,~/foo ls # multiple tags and/or paths can be specified using commas
~$ e -i app myalias # use -i (interactive shell) to use functions, aliases etc.
Execute commands in parallel with p
(same interface as e
):
Display, search and manage tags with dtags
:
~$ dtags # display the directories-to-tags mapping
~$ dtags list ~ ~/vm # list the tags and directories associated with ~ and ~/vm
~$ dtags list foo bar # list the tags and directories associated with 'foo' or 'bar'
~$ dtags reverse # list the tags-to-directories (reverse) mapping
~$ dtags edit # edit tags and directories via editor
~$ dtags clean # remove invalid or stale tags and directories
~$ dtags commands # display all available dtags commands (e.g. t, u, d, e, p)
If a tag points to a single directory, shell variables are automatically created:
You can always use the --help
option to find out more about each command!
Streamline your Git workflows:
Control multiple vagrant machines at the same time:
- The directory-to-tags mapping is stored in
~/.dtags/mapping
- Tags are also stored on their own in
~/.dtags/tags
for tab-completion p
is currently not fully supported on Windowsp
cannot execute interactive commands that wait on inputp
spawns child processes and redirects all output to temp files and then to stdoutp
does not retain font colors due to shell limitationsp
sends sigterm to its child processes when killede
(orp
) uses environment variable $SHELL to guess which shell is in usee
(orp
) redirects stderr to stdout and always returns an exit status of 0- Using
-i
(interactive shell) has caveats:- The shell runtime configuration must be "sourced" for every command execution
- The performance is affected by the shell startup time (beware oh-my-zsh users)
- Any errors thrown during the "sourcing" will be displayed in the output
dtags edit
uses environment variable $EDITORd
prefers tags over subdirectories when there are name conflicts- To go to the subdirectory, put
/
after the directory name
- To go to the subdirectory, put
d
expects~/.dtags/mapping
to be correctly formatted:- Refrain from editing
~/.dtags/mapping
directly. - Instead, use
dtags edit
which does the validation and formatting for you
- Refrain from editing
- Tab-completion expects
~/.dtags/tags
to be correctly formatted:- Refrain from touching this file
- This file is auto-generated whenever a dtags command is run.
- A shell variable is created only if its name does not conflict with environment variables
- When shell variables are created, any disallowed characters in the name are replaced with underscores