A lightweight, cross-platform Python wrapper that adds WakaTime tracking to the GNU Nano editor.
Unlike modern IDEs (VS Code, JetBrains), nano does not support native plugins. This tool solves that by using the Wrapper Pattern. It launches a background file watcher alongside the editor to detect "Save" events and sync them to the WakaTime API silently.
How it works under the hood:
sequenceDiagram
participant User
participant NanoW as nanow (Wrapper)
participant Editor as GNU Nano
participant Watcher as Watchdog (Thread)
participant CLI as WakaTime CLI
User->>NanoW: run "nano file.py"
NanoW->>Watcher: Start background monitoring on file.py
NanoW->>Editor: Launch Editor (Foreground)
loop Editing Session
User->>Editor: Edit & Save (Ctrl+O)
Editor-->>Watcher: File System Event (MODIFY)
Watcher->>CLI: Trigger heartbeat
CLI-->>WakaTime API: HTTP POST (201 Created)
end
User->>Editor: Exit (Ctrl+X)
Editor->>NanoW: Process Ends
NanoW->>Watcher: Stop & Cleanup
- Zero Latency: The editor runs natively; the tracking happens in a non-blocking background thread.
- Atomic Save Detection: Uses
watchdogto handle complex file system events (more robust than polling). - Smart Argument Parsing: Distinguishes between Nano flags (e.g.,
-w,-c) and actual filenames. - Cross-Platform: Works on Linux and macOS.
- Python 3.6+
- WakaTime CLI (Standard Go binary)
- Python Watchdog Library
pip3 install -r requirements.txtcurl -fsSL https://raw.githubusercontent.com/wakatime/vim-wakatime/master/install_cli.py | python3pip install nano-wakatime
echo 'alias nano="nanow"' >> ~/.bashrc
source ~/.bashrcClone this repository or download the script directly.
git clone https://github.com/YOUR_USERNAME/nano-wakatime.git
cd nano-wakatimeMove the script to your local binary folder and make it executable.
mkdir -p ~/.local/bin
cp nanow.py ~/.local/bin/nanow
chmod +x ~/.local/bin/nanowTo make this seamless, alias nano to use this wrapper. Add this to your .bashrc or .zshrc:
alias nano="nanow"Reload your shell:
source ~/.bashrcCreate your WakaTime config file if you haven't already.
- Get your API Key from wakatime.com/api-key.
- Create the config file:
# Note: Use \nano to bypass the alias for initial setup
\nano ~/.wakatime.cfg- Paste the following:
[settings]
api_key = your_secret_api_key_hereJust use nano as you normally would!
# The wrapper automatically starts
nano my_script.py
# Works with flags too
nano -c -w my_script.pyNote: Time is tracked when you Save (
Ctrl+O).