DEV Community

Tony Metzidis
Tony Metzidis

Posted on • Originally published at tonym.us on

A Timeless Directory Layout for Projects

Directory layouts are like log cabins that start from a basic shed, gradually adding a room at a time.When you start out on UNIX, everything gets thrown inyour home directory. Over time you start to develop a structure for your sources, binaries,projects, data files (like CSV, images, tar files), config, etc

My layout is called TDL -- because it allows me to juggle open sourceprojects, partnerships and jobs in a consistent structure across machines and time.

~/
│── .cfg            # bare git repo with my dotfiles
│── local           # e.g. make install --prefix=~/local
│   - lib, bin, man  
│── .trash          # files to delete
│       # VARIOUS DIRECTORIES WITH REPOS
│── src             # clone public open source repos, e.g. for contribution, research or debugging
│── stellar         # personal repositories
│   - archive       # hold tgz of repos to save space and indexing
│   - repo1
│   - repo2
│── apple           # contains repos for a previous company
│── microsoft.      # repos from another company , consulting project, charity effort

.cfg

Store your dotfiles using the git bare repo technique. this way your config travels with you. If you have host-specific config, either test for the hostname e.g. in your .bashrc, or git checkout -b $(hostname)

local

e.g. make --prefix=~/local -- install binaries, libs, man pages into your home directory. Add $HOME/local/bin to your path with export PATH=$PATH:$HOME/local/binThe contents are machine specific

Storing Repos

Within your home dir, choose "business names" , e.g. for my personal workit's stellar, open source is src and then a directory each for businesseslike apple , microsoft etc

Archiving Sources

Sources get huge, so archive them with tar -czf archive/repo1.tgz repo1 && rm -rf repo1

Syncing Files Across Hosts

most sources will be synced via your git repo, but for large files (e.g. a 5gb csv), generally you'll rsync

Add the alias to your .ssh/config so you can quickly send files among machines. Naturally commit that into your .cfg repo

e.g.

cat ~/.ssh/config
Host cloud9-env1
        User ec2-user
        IdentityFile ~/.ssh/id_rsa
        Hostname cloud9-env1.tonymet.com

Then you can easily sync with rsync myfile cloud9-env1:$(pwd)/

Summary

Keeping things consistent over time, across projects and machines is key.

What's your layout look like?

Discussion (0)