Configuration Options¶
The gi tool supports various configuration options through environment variables and command-line arguments.
Environment Variables¶
GI_CACHE_DIR¶
Override the default cache directory location.
Default: Platform-specific cache directory - Linux/macOS: ~/.cache/gi - Windows: %LOCALAPPDATA%\gi\cache
Example:
GI_TIMEOUT¶
Set the network request timeout in seconds.
Default: 30
Example:
GI_OFFLINE¶
Force offline mode, using only cached templates.
Default: false
Example:
Command-Line Options¶
Global Options¶
These options are available for all commands:
--help, -h¶
Show help message and exit.
--version, -v¶
Show version information and exit.
Main Command Options¶
--output, -o¶
Specify the output file path.
Default: .gitignore
Example:
--force, -f¶
Overwrite existing files without confirmation.
Default: false (prompts for confirmation)
Example:
--dry-run¶
Show what would be done without actually creating files.
Example:
--verbose, -V¶
Enable verbose output.
Example:
Search Command Options¶
--exact¶
Perform exact name matching instead of partial matching.
Example:
--limit¶
Limit the number of search results.
Default: 50
Example:
Configuration File¶
You can create a configuration file to set default options.
Location¶
The configuration file is looked for in the following locations (in order):
GI_CONFIG_FILEenvironment variable~/.config/gi/config.toml~/.gi/config.toml./gi.toml(project-local)
Format¶
The configuration file uses TOML format:
# gi.toml
[defaults]
output = ".gitignore"
force = false
timeout = 30
cache_dir = "~/.cache/gi"
[search]
exact = false
limit = 50
[format]
include_headers = true
sort_templates = true
Example Configuration¶
# ~/.config/gi/config.toml
[defaults]
# Always overwrite existing files
force = true
# Use a custom cache directory
cache_dir = "~/Documents/gi-cache"
# Longer timeout for slow connections
timeout = 60
[search]
# Show more results
limit = 100
[format]
# Include section headers in output
include_headers = true
# Sort templates alphabetically
sort_templates = true
Template Aliases¶
You can define custom aliases for template names in your configuration:
# ~/.config/gi/config.toml
[aliases]
# Custom aliases
py = "Python"
js = "Node"
ts = "TypeScript"
react = "React"
vue = "Vue"
Usage:
Cache Management¶
Cache Directory Structure¶
~/.cache/gi/
├── index.json # Template index
├── templates/ # Cached templates
│ ├── Python.gitignore
│ ├── Node.gitignore
│ └── ...
└── metadata.json # Cache metadata
Cache Commands¶
gi cache clear¶
Clear all cached templates and index.
gi cache list¶
List cached templates.
gi cache info¶
Show cache statistics.
Network Configuration¶
Proxy Support¶
The tool respects standard proxy environment variables:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1
Custom User Agent¶
Set a custom User-Agent string:
Debugging¶
Debug Mode¶
Enable debug output:
Verbose Logging¶
Enable verbose logging:
Log File¶
Specify a log file:
Platform-Specific Configuration¶
Windows¶
On Windows, you can use the registry or environment variables:
REM Set cache directory
set GI_CACHE_DIR=C:\Users\%USERNAME%\AppData\Local\gi\cache
REM Set timeout
set GI_TIMEOUT=45
macOS¶
On macOS, you can use defaults or environment variables:
# Using defaults (requires custom implementation)
defaults write com.example.gi cache_dir "~/Library/Caches/gi"
# Using environment variables
export GI_CACHE_DIR="~/Library/Caches/gi"
Linux¶
On Linux, follow the XDG Base Directory specification:
# Cache directory
export XDG_CACHE_HOME="$HOME/.cache"
export GI_CACHE_DIR="$XDG_CACHE_HOME/gi"
# Config directory
export XDG_CONFIG_HOME="$HOME/.config"
Examples¶
Basic Configuration¶
# Set up basic configuration
export GI_CACHE_DIR="~/.cache/gi"
export GI_TIMEOUT=30
# Use the tool
gi python node
Advanced Configuration¶
# ~/.config/gi/config.toml
[defaults]
force = true
timeout = 60
cache_dir = "~/Documents/gi-cache"
[aliases]
py = "Python"
js = "Node"
react = "React"
[search]
limit = 100
exact = false
[format]
include_headers = true
sort_templates = true