16 releases (3 stable)

1.1.0 Apr 25, 2024
1.0.1 Nov 13, 2023
1.0.0 Aug 8, 2023
0.6.0 Nov 28, 2022
0.1.3 Mar 8, 2018

#77 in Command line utilities

GPL-3.0 license

527 lines

Projector, a CLI for managing multiple projects

I work on a lot of FOSS projects, it's literally part of my job. Unfortunately this means that moving around my project directories (especially my GOPATH) can get insanely burdensome. So I wrote this CLI to help me find and manage my enormous git repos folder. Projector can be viewed as a "no setup" required version of mr (myrepos). But a bit more flexible than that.


You can install projector from crates.io via cargo:

cargo install projector

Or you can build it locally with:

git clone https://github.com/chasinglogic/projector $PATH_TO_PROJECTOR
cargo install --path .


projector 0.2.0
Mathew Robinson <chasinglogic@gmail.com>

    projector [OPTIONS] [SUBCOMMAND]

    -h, --help       Prints help information
    -V, --version    Prints version information

    -c, --code-dir <CODE_DIR>    The root of where to search for projects. Also can be
                                 configured using the environment variable CODE_DIR.
                                 Default: ~/Code
    -e, --exclude <PATTERN>      A regex which will be used to exclude directories from commands.
    -i, --include <PATTERN>      A regex which will be used to include directories from commands. Overrides
                                 excludes so if a directory is matched by an exclude pattern and an include
                                 pattern the directory will be included.

    help    Prints this message or the help of the given subcommand(s)


Projector considers any git repo as a "project". In future versions I will expand this definition but it works for me now so that's the way it is. Additionally, projector operates off of the assumption that you have all of your code / projects under one directory. For myself I use ~/Code.

Projector has two functions: list and run.


list will literally print a list of the projects under your code directory.

You may be wondering, what would I use this for? The answer is quickly moving around!

You can create a bash function in your bashrc like this:

function sp() {
    cd $(projector list | grep -i $1)

Now if you source your bashrc and type sp $name_of_a_project you will instantly be transported to your project directory. For example:

Users/chasinglogic λ . .bashrc
Users/chasinglogic λ sp projector
Code/projector master λ sp dfm
chasinglogic/dfm master λ pwd
chasinglogic/dfm master λ

Optionally, if you have another tool I'm fond of called FZF you can take this a step further and make a fuzzy searchable list of your projects:

function sp() {
  cd $(projector list | fzf)

Now you get something like this:

> /Users/chasinglogic/Code/go/src/gopkg.in/yaml.v2

and you can search and select using FZF's awesome interface:

> /Users/chasinglogic/Code/archive/projector
> projector

Enter and voila!:

Users/chasinglogic λ sp
Code/projector master λ pwd
Code/projector master λ


Run allows you to run shell commands in all of your projects. For example if you wanted to run git status on every project:

Code/projector master λ projector run git status
nothing to commit, working tree clean
On branch emacs-26
Your branch is up-to-date with 'origin/emacs-26'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   Cargo.lock

no changes added to commit (use "git add" and/or "git commit -a")
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean
Code/projector master λ

Any flags you pass after the program will get passed to the program so you can type the command just like you would normally, no weird shell quoting!

Some Setup (Optionally) Required

Projector does not require any setup to use provided that you either have your code in ~/Code or set the $CODE_DIR environment variable. However every good CLI does provide some configuration for power users, so of course projector does as well. Primarily the configuration centers around inclusion and exclusion of project directories. For example I have a huge amount of go repos in my $GOPATH:

... (list truncated for brevity)

Of which most are not mine so I don't want them to show up in my projector output or be used when I run projector run. I could use the --exclude flag which supports a regular expression as accepted by the regex crate to exclude the go directories. Something like:

projector --exclude '.*go.*' list

But that would also exclude my go source directories. Using the --include flag I can add a regex which will include a directory if it matches the include regex and the exclude regex. This feature exists because the regex crate does not support look-ahead/behind. So the new command is:

projector --exclude '.*go.*' --include '.*github.com/chasinglogic.*' list

This is a pretty tiresome command to type every time so you can make an alias, or create a config file at ~/.projector.yml that looks like this:

code_dir: ~/Code
    - .*github.com/chasinglogic.*
    - .*github.com/mongodb.*
    - .*go.*

This does the same thing. In this config file includes and excludes are lists of regexes which will be or'd together. Anything that matches an exclude pattern will be excluded unless it also matches an include pattern.

code_dir is required inside of the config file.


Copyright 2018 Mathew Robinson <chasinglogic@gmail.com>. All rights reserved.
Use of this source code is governed by the GPLv3 license that can be found in
the LICENSE file.


~174K SLoC