Faxmachine is a powerful utility for storing, organizing, and injecting commonly used files and templates across your projects. It serves as a centralized repository for your frequently used code snippets, configuration files, boilerplate templates, and documentation.
- Simple Command Line Interface: Easy to use commands for managing your file templates
- Interactive Browser: Navigate your template collection with a user-friendly interface featuring:
- Tree-like visualization of categories and files
- Smart dropdowns showing file summaries
- Multi-select capability for batch operations
- Vim-like navigation options for power users
- Smart Search: Find templates by filename, contents, tags, or description
- File Preview: See what you're getting before injecting files, with:
- Syntax highlighting for code files
- Content analysis for quick understanding
- Diff preview when overwriting existing files
- Metadata Support: Add descriptions and tags to better organize your templates
- Automatic tag suggestion based on file content
- Smart file summarization for better organization
- Category Organization: Keep templates neatly arranged in categories and subcategories
- Smart Document Analysis: Automatic content analysis that:
- Extracts key information from PDFs, JSON, CSV and code files
- Suggests relevant tags based on content
- Provides summary of file structure and purpose
- Batch Operations: Add, view, or inject multiple files at once
- Recent Files Tracking: Quick access to your most recently used templates
- Clone this repository:
git clone https://github.com/yourusername/faxmachine.git
- Add the
src
directory to your PATH, or create a symlink tofaxmachine.sh
in a directory that's already in your PATH:
ln -s /path/to/faxmachine/src/faxmachine.sh /usr/local/bin/faxmachine
# Optional: Create shorter alias
ln -s /path/to/faxmachine/src/faxmachine.sh /usr/local/bin/fm
- Make sure both scripts are executable:
chmod +x /path/to/faxmachine/src/faxmachine.sh
chmod +x /path/to/faxmachine/src/faxmachine.py
- Initialize the database:
faxmachine init
- (Optional) Add built-in templates to your faxmachine database:
./add_templates_to_faxmachine.sh
- Python 3.6 or higher
- Bash shell
- Optional dependencies (automatically installed when needed):
- NLTK, spaCy, or YAKE for intelligent keyword extraction
- pdfplumber for PDF analysis
- pygments for syntax highlighting
The easiest way to use Faxmachine is in interactive mode, which you can access by running faxmachine
or fm
with no arguments:
faxmachine
# or
fm
This presents a menu with options to:
- Browse files (interactive mode)
- Add a file to the database
- Find and inject a file
- Show recent files
- List all files
- Delete a file
- Mass add files
- File browser (with shortcuts & smart preview)
- Show version h. Help q. Quit
The interactive file browser (faxmachine browse
) offers a powerful way to navigate your templates:
- View files organized by category
- Navigate with cursor keys (j/k/h/l in Vim mode)
- Toggle file summaries with 'd'
- Select multiple files with space bar in multi-select mode
- Perform batch operations on selected files
- View smart previews of files before opening them
- Quick access to system shortcuts and recent files
# Browse files with interactive browser
faxmachine browse
# Add a file to the database
faxmachine add path/to/your/file.txt
# Add a file with metadata
faxmachine add config.json --category config --description "My config template" --tags "json,config,template"
# Search for templates
faxmachine search gitignore
# Search in file contents as well
faxmachine search "import os" --content-search
# List all available templates
faxmachine list
# Inject a template into your current directory
faxmachine inject git/gitignore
# Show template contents
faxmachine show git/gitignore
# Show recently used templates
faxmachine recent
# Delete a template
faxmachine delete git/gitignore
# Mass add multiple files at once
faxmachine mass-add
# Smart document browsing with previews
faxmachine browser
faxmachine add [FILE] [--category CATEGORY] [--subcategory SUBCATEGORY] [--name NAME] [--description DESC] [--tags TAGS]
When adding files, Faxmachine offers smart content analysis that:
- Automatically extracts metadata from files (especially PDFs, CSVs, and JSON)
- Suggests descriptions based on file content
- Recommends tags based on content analysis
- Shows previews of content to help with organization
faxmachine search [QUERY] [--content-search] [--tags TAGS] [--list-only] [--show-index INDEX] [--inject-index INDEX] [--delete-index INDEX]
The search command supports:
- Basic file name and description search
- Full-text content search with the
--content-search
flag - Tag filtering to narrow down results
- Direct actions on search results without prompting
faxmachine inject [FILE] [--name NAME] [--no-preview]
When injecting files:
- Shows diff preview if overwriting existing files
- Option to rename files during injection
- Updates access history for quick access later
faxmachine browser [FILE]
The smart document browser provides:
- File system navigation with shortcuts
- Smart preview generation for files
- Automatic tag extraction
- Dropdown summaries of file content
- Multi-select capability for batch operations
faxmachine mass-add
For adding multiple files at once:
- Select destination category/subcategory
- Batch select files via dialog or manual input
- Apply common metadata to all files
- Smart content analysis for quick categorization
Faxmachine stores your templates and metadata in the following locations:
~/.faxmachine/
│
├── db/ # Main database directory containing actual files
│ ├── git/ # Example category
│ ├── python/ # Example category
│ ├── web/ # Example category
│ ├── config/ # Example category
│ └── other/ # Example category
│
├── metadata/ # Metadata storage directory
│ └── git_python-gitignore.json # Example metadata file
│
├── config/ # Configuration directory
│ ├── config.json # User configuration
│ └── cache/ # Cache directory
│
Each file in the database has associated metadata stored as JSON with the following structure:
{
"description": "Description of the file",
"source_path": "Original path when added",
"added_date": "ISO format date when added",
"tags": ["tag1", "tag2", "tag3"]
}
The main configuration file (~/.faxmachine/config/config.json
) stores:
{
"version": "1.1.0",
"aliases": {},
"last_accessed": ["recently used file paths"],
"settings": {
"default_editor": "vi",
"search_content": true,
"preview_before_inject": true
}
}
Faxmachine includes intelligent document analysis capabilities:
-
PDF Analysis:
- Extracts title, sections, and key topics
- Identifies document type and purpose
- Suggests tags based on content
-
JSON Analysis:
- Identifies key structures and patterns
- Extracts key fields for quick understanding
- Recommends appropriate tags
-
CSV Analysis:
- Identifies headers and data types
- Provides row count and column summary
- Suggests domain-specific tags
-
Code Analysis:
- Identifies programming language
- Extracts key identifiers and concepts
- Suggests language-appropriate tags
For users familiar with Vim, Faxmachine offers a Vim-like navigation mode in the browser:
j/k
to move up/downh
to go to parent directoryl
to enter directory or view fileq
to exit Vim mode
The multi-select mode allows you to:
- Select multiple files with the space bar
- Perform batch operations (view, inject, add to database)
- Clear selections with 'c'
- Process selected files with 'a'
When available, Faxmachine uses a curses-based terminal UI for improved navigation and visualization, including:
- Color highlighting for better readability
- Dropdown summaries for quick information
- Visual selection indicators
- Directory tree visualization
-
Project Bootstrapping:
- Store common project structures
- Inject configuration files with one command
- Maintain consistent project setups
-
Configuration Management:
- Store configuration templates for different environments
- Keep standardized config files for various services
- Easily update configurations across projects
-
Boilerplate Code:
- Store frequently used code patterns
- Maintain language-specific utilities
- Inject common functions and classes
-
Documentation:
- Keep README templates
- Store license files
- Maintain consistent documentation formats
-
Infrastructure as Code:
- Store Terraform/CloudFormation templates
- Maintain Docker/Kubernetes configurations
- Organize deployment scripts
-
CI/CD Templates:
- Store GitHub Actions workflows
- Maintain Jenkins pipeline configurations
- Keep standardized CI/CD setups
-
Server Configurations:
- Store Nginx/Apache configurations
- Maintain system initialization scripts
- Keep monitoring configurations
-
Standardization:
- Maintain team-wide coding standards
- Share common utilities and helpers
- Ensure consistent project structures
-
Onboarding:
- Provide new team members with standard templates
- Share common project components
- Enable quick access to team conventions
-
Efficiency:
- Eliminate repetitive file creation
- Reduce copy-paste errors
- Streamline project setup and maintenance
-
Consistency:
- Maintain standardized files across projects
- Ensure all team members use the same templates
- Reduce deviations from best practices
-
Organization:
- Centralize all commonly used files
- Categorize templates for easy access
- Add metadata for better searchability
-
Time Savings:
- Quick access to frequently used files
- Reduce time spent recreating common structures
- Batch operations for working with multiple files
-
Smart Analysis:
- Automatic content understanding
- Context-aware tag suggestions
- File summarization for better organization
Faxmachine is implemented as a combination of Python and Bash scripts:
-
faxmachine.py: The core Python implementation containing:
- File management functions
- Template database operations
- Smart document analysis
- Interactive browser implementation
- Command processing logic
-
faxmachine.sh: A Bash wrapper providing:
- Simple command line interface
- Interactive menu for common operations
- Input handling and environment setup
- Python script execution
-
db.py: Database management module with:
- Metadata handling functions
- File storage operations
- Search and retrieval logic
- Category management
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.