A sophisticated terminal-based text editor wrapper that provides safe file editing with built-in validation for multiple file formats. Perfect for system administrators and developers who need reliable file editing with syntax checking.
- 🔍 Automatic syntax validation for multiple file formats
- 🔒 Safe editing using temporary files
- 🎯 Smart editor detection and fallback
- 📝 Support for line number targeting
- 🛡️ Binary file protection
- 🔄 Path resolution and symlink handling
- ⚡ Executable file detection and safety prompts
- JSON/JSONLD
- YAML/YML
- XML/XSLT/SVG
- TOML
- INI/Config files
- CSV/TSV
- Markdown
- Python
- Shell scripts (with shellcheck integration)
- PHP
- HTML/XHTML
- Clone the repository:
git clone https://github.com/yourusername/edit_file.git
cd edit_file
- Make the script executable:
chmod +x edit_file.py
- Optional: Create symlinks for easier access:
sudo ln -s edit_file.py /usr/local/bin/edit_file
Basic usage:
edit_file filename
With options:
edit_file [-n] [-l LINE] filename
-n, --no-validate
: Skip validation-l, --line LINE
: Start editing at specified line number-h, --help
: Show help message
Edit a Python file with validation:
edit_file script.py
Edit starting at line 50:
edit_file -l 50 config.yaml
Edit without validation:
edit_file -n data.json
The script will use editors in the following order:
- Value of
$EDITOR
environment variable - Available system editors: nano, vim, vi, mcedit, joe, ne, micro, emacs, jed, gedit
- Bash
- Python 3.8+
- Standard Python libraries
- shellcheck (for shell script validation)
- yamllint (for YAML validation)
- php-cli (for PHP validation)
- html5lib (for HTML validation)
- tomli (for TOML validation)
On Ubuntu/Debian:
sudo apt install shellcheck yamllint php-cli python3-html5lib python3-tomli
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GPL3 License - see the LICENSE file for details.
Gary Dean - garydean@yatti.id