DirMon is a command-line application written in Go that monitors directories, lists their contents, and allows you to delete files. It provides both interactive and command-line interfaces with persistent configuration storage.
- Directory Monitoring: Watch directories for file creation, modification, deletion, and other changes
- File Management: List directory contents and delete files
- Interactive Mode: User-friendly menu-driven interface
- Persistent Configuration: Save directories to monitor for later use
- Batch Monitoring: Monitor all saved directories simultaneously
- Go 1.18 or higher
# Clone the repository
git clone git@github.com:cds-id/dirmon.git
cd dirmon
# Install dependencies
go mod tidy
# Build the application
go build -o dirmon# For Linux/macOS
sudo cp dirmon /usr/local/bin/
# For Windows
# Move dirmon.exe to a directory in your PATHThe easiest way to use DirMon is through its interactive interface:
dirmon interactive
# or the shorter version
dirmon iThis will present a menu with the following options:
- List directory contents
- Delete a file
- Monitor a directory
- View monitored directories
- Add directory to monitored list
- Remove directory from monitored list
- Monitor all saved directories
You can also use DirMon directly from the command line:
# List directory contents (defaults to current directory)
dirmon list [path]
dirmon ls [path]
# Delete a file (with confirmation)
dirmon delete filename
dirmon rm filename
# Monitor a specific directory for changes
dirmon monitor [path]
dirmon mon [path]
# Add a directory to the monitored list
dirmon add-dir /path/to/directory
# Show all monitored directories
dirmon show-dirs
# Monitor all saved directories
dirmon monitor-allDirMon stores its configuration in a JSON file. By default, it looks for configuration in the following locations:
/opt/dirmon_config.json(system-wide)~/.dirmon_config.json(user's home directory)
The configuration file stores the list of directories to monitor, which can be managed through the interactive interface or with the add-dir command.
# Add important directories to monitor
dirmon add-dir /var/log
dirmon add-dir /home/user/projects
dirmon add-dir /opt/application/data# Start monitoring all saved directories
dirmon monitor-allSample output:
Adding /var/log to watch list
Adding /home/user/projects to watch list
Adding /opt/application/data to watch list
Starting monitoring of all directories... (Press Ctrl+C to stop)
--------------------------------------------------------------------------------
[14:32:15] [/var/log] MODIFIED - syslog
[14:32:23] [/home/user/projects] CREATED - newfile.txt
[14:32:35] [/opt/application/data] DELETED - oldfile.dat
MIT License - See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues:
- Make sure you have sufficient permissions to access the directories you're monitoring
- Check that the Go version is 1.18 or higher
- For Linux users, you may need to run with sudo to monitor system directories
- On some systems, you might need to increase the inotify watches limit:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Repository: github.com/cds-id/dirmon