Skip to content

Basic ExamplesΒΆ

This page provides simple examples of common Recursivist usage patterns. These examples are designed to help you get familiar with the basic capabilities of the tool.

Simple VisualizationΒΆ

Viewing the Current DirectoryΒΆ

To visualize the current directory structure:

recursivist visualize

This will produce output similar to:

πŸ“‚ my-project
β”œβ”€β”€ πŸ“ src
β”‚   β”œβ”€β”€ πŸ“„ main.py
β”‚   β”œβ”€β”€ πŸ“„ utils.py
β”‚   └── πŸ“ tests
β”‚       β”œβ”€β”€ πŸ“„ test_main.py
β”‚       └── πŸ“„ test_utils.py
β”œβ”€β”€ πŸ“„ README.md
β”œβ”€β”€ πŸ“„ requirements.txt
└── πŸ“„ setup.py

Viewing a Specific DirectoryΒΆ

To visualize a different directory:

recursivist visualize ~/projects/my-app

Limiting Directory DepthΒΆ

To limit the depth of the directory tree (useful for large projects):

recursivist visualize --depth 2

Output:

πŸ“‚ my-project
β”œβ”€β”€ πŸ“ src
β”‚   β”œβ”€β”€ πŸ“„ main.py
β”‚   β”œβ”€β”€ πŸ“„ utils.py
β”‚   └── πŸ“ tests
β”‚       β‹― (max depth reached)
β”œβ”€β”€ πŸ“„ README.md
β”œβ”€β”€ πŸ“„ requirements.txt
└── πŸ“„ setup.py

Showing Full PathsΒΆ

To show full file paths instead of just filenames:

recursivist visualize --full-path

Output:

πŸ“‚ my-project
β”œβ”€β”€ πŸ“ src
β”‚   β”œβ”€β”€ πŸ“„ /home/user/my-project/src/main.py
β”‚   β”œβ”€β”€ πŸ“„ /home/user/my-project/src/utils.py
β”‚   └── πŸ“ tests
β”‚       β”œβ”€β”€ πŸ“„ /home/user/my-project/src/tests/test_main.py
β”‚       └── πŸ“„ /home/user/my-project/src/tests/test_utils.py
β”œβ”€β”€ πŸ“„ /home/user/my-project/README.md
β”œβ”€β”€ πŸ“„ /home/user/my-project/requirements.txt
└── πŸ“„ /home/user/my-project/setup.py

File StatisticsΒΆ

Showing Lines of CodeΒΆ

To display and sort by lines of code:

recursivist visualize --sort-by-loc

Output:

πŸ“‚ my-project (4328 lines)
β”œβ”€β”€ πŸ“ src (3851 lines)
β”‚   β”œβ”€β”€ πŸ“„ main.py (245 lines)
β”‚   β”œβ”€β”€ πŸ“„ utils.py (157 lines)
β”‚   └── πŸ“ tests (653 lines)
β”‚       β”œβ”€β”€ πŸ“„ test_main.py (412 lines)
β”‚       └── πŸ“„ test_utils.py (241 lines)
β”œβ”€β”€ πŸ“„ README.md (124 lines)
β”œβ”€β”€ πŸ“„ requirements.txt (18 lines)
└── πŸ“„ setup.py (65 lines)

Showing File SizesΒΆ

To display and sort by file sizes:

recursivist visualize --sort-by-size

Output:

πŸ“‚ my-project (1.2 MB)
β”œβ”€β”€ πŸ“ src (850.5 KB)
β”‚   β”œβ”€β”€ πŸ“„ main.py (12.4 KB)
β”‚   β”œβ”€β”€ πŸ“„ utils.py (8.2 KB)
β”‚   └── πŸ“ tests (45.7 KB)
β”‚       β”œβ”€β”€ πŸ“„ test_main.py (28.9 KB)
β”‚       └── πŸ“„ test_utils.py (16.8 KB)
β”œβ”€β”€ πŸ“„ README.md (4.2 KB)
β”œβ”€β”€ πŸ“„ requirements.txt (512 B)
└── πŸ“„ setup.py (3.8 KB)

Showing Modification TimesΒΆ

To display and sort by modification times:

recursivist visualize --sort-by-mtime

Output:

πŸ“‚ my-project (Today 14:30)
β”œβ”€β”€ πŸ“ src (Today 14:25)
β”‚   β”œβ”€β”€ πŸ“„ main.py (Today 14:25)
β”‚   β”œβ”€β”€ πŸ“„ utils.py (Yesterday 18:10)
β”‚   └── πŸ“ tests (Feb 15)
β”‚       β”œβ”€β”€ πŸ“„ test_main.py (Feb 15)
β”‚       └── πŸ“„ test_utils.py (Feb 10)
β”œβ”€β”€ πŸ“„ README.md (Today 10:15)
β”œβ”€β”€ πŸ“„ requirements.txt (Jan 20)
└── πŸ“„ setup.py (Jan 15)

Combining StatisticsΒΆ

To show multiple statistics at once:

recursivist visualize --sort-by-loc --sort-by-size

Output:

πŸ“‚ my-project (4328 lines, 1.2 MB)
β”œβ”€β”€ πŸ“ src (3851 lines, 850.5 KB)
β”‚   β”œβ”€β”€ πŸ“„ main.py (245 lines, 12.4 KB)
...

Simple ExclusionsΒΆ

Excluding Specific DirectoriesΒΆ

To exclude directories like node_modules or .git:

recursivist visualize --exclude "node_modules .git"

Excluding File ExtensionsΒΆ

To exclude files with specific extensions:

recursivist visualize --exclude-ext ".pyc .log"

Combining ExclusionsΒΆ

You can combine different exclusion methods:

recursivist visualize --exclude "node_modules .git" --exclude-ext ".pyc .log"

Basic ExportsΒΆ

Exporting to MarkdownΒΆ

To export the current directory structure to Markdown:

recursivist export --format md

This creates a file named structure.md in the current directory.

Exporting to Multiple FormatsΒΆ

To export to multiple formats at once:

recursivist export --format "txt md json"

Exporting to a Specific DirectoryΒΆ

To export to a different directory:

recursivist export --format html --output-dir ./docs

Customizing the FilenameΒΆ

To use a custom filename prefix:

recursivist export --format json --prefix my-project

This creates a file named my-project.json.

Exporting with StatisticsΒΆ

To include file statistics in the export:

recursivist export --format html --sort-by-loc --sort-by-size

Simple ComparisonsΒΆ

Comparing Two DirectoriesΒΆ

To compare two directories:

recursivist compare dir1 dir2

This displays a side-by-side comparison in the terminal.

Exporting a ComparisonΒΆ

To save the comparison as an HTML file:

recursivist compare dir1 dir2 --save

This creates a file named comparison.html in the current directory.

Comparing with StatisticsΒΆ

To include file statistics in the comparison:

recursivist compare dir1 dir2 --sort-by-loc

This makes it easy to see not just structural differences but also differences in code volume.

Shell CompletionΒΆ

Generating Shell Completion for BashΒΆ

mkdir -p ~/.bash_completion.d
recursivist completion bash > ~/.bash_completion.d/recursivist
source ~/.bash_completion.d/recursivist

Generating Shell Completion for ZshΒΆ

mkdir -p ~/.zsh/completion
recursivist completion zsh > ~/.zsh/completion/_recursivist

Then add to your .zshrc:

fpath=(~/.zsh/completion $fpath)
autoload -U compinit; compinit

Version InformationΒΆ

To check the version of Recursivist:

recursivist version

Next StepsΒΆ

These basic examples should help you get started with Recursivist. For more advanced examples, check out: