Loading repository data…
Loading repository data…
RedHatRanger / repository
header – File Header Management Script header is a Bash utility that automatically adds or updates a standardized metadata header at the top of files (YAML, Bash, Python, configs, etc.).It’s designed to help teams maintain consistent file documentation and versioning, while preserving shebangs (#!/usr/bin/env bash) and file permissions.
header – File Header Management Script - by RedHatRangerheader is a Bash utility that automatically adds or updates a standardized metadata header at the top of files (YAML, Bash, Python, configs, etc.).
It’s designed to help teams maintain consistent file documentation and versioning, while preserving shebangs (#!/usr/bin/env bash) and file permissions.
Adds a new header to files without one, or updates existing headers
Preserves shebang (#!) line if present
Preserves original file permissions
Header fields managed automatically:
v1.0, increments by 0.1 on each modificationSave the script and make it executable:
sudo cp header /usr/local/bin/header
sudo chmod 755 /usr/local/bin/header
To automatically insert or update headers when editing YAML files, add the following to your ~/.vimrc (or globally in /etc/vim/vimrc):
autocmd BufRead,BufNewFile *.yml,*.yaml !header % # Not Recommended as this will give a warning message each time to Load the File
autocmd FileType yaml setlocal et ai ts=2 sw=2 sts=2 # RECOMMENDED FOR 2-SPACED-TABS
header [OPTIONS] FILE [FILE2 ...]
| Option | Description |
|---|---|
-a, --author NAME | Set author (default: current user) |
-m, --modified-by NAME | Set Modified By field (default: current user) |
-d, --desc TEXT | Set Description. Use "-" to preserve existing |
-f, --force-author | Overwrite existing Author with the provided name |
-h, --help | Show usage |
header --author "Alice" --desc "Production Configuration Template" sample.yaml
header -m "Bob" -d "Alice's code, modified by Bob" sample_with_header.yaml
header --author "Bob" --force-author app.yaml
header --author devops --desc "Infra configs" config1.yaml config2.yaml
--force-author is required to overwrite Author--desc "-" preserves existing descriptionv1.0, v1.1, v1.2, …)