[disclaimer]: This repo is under active coding so it’s still not fully released.
The aim of this repo is to build a coding tracker to reccord the time spent on any file and on any programming language. Currently, the script supports the following programming languages:
- Python (extension file .py)
- Bash (extension file .sh)
- Perl (entension file .pl)
- Org-mode (extesion file .org)
More languages could be added on demand.
- Clone the repo
- Install the python package inotify in your python environment that you use with emacs for programming.
- In the file named emacs_coding_tracker.py, set up the path of the files that lead to the bookmark that you use, the emacs history and the file that will save all your coding stats.
- In the file .emacs you will need to add the following lines of code so the history is saved every seconds instead of every five minutes and also enable the reccording of the command history.
;; save the history every seconds
(defcustom savehist-autosave-interval (* 1)
"The interval between autosaves of minibuffer history.
If set to nil, disables timer-based autosaving."
:type '(choice (const :tag "Disabled" nil)
(integer :tag "Seconds"))
:group 'savehist)
(setq savehist-additional-variables
'(command-history))
(savehist-mode) - Now you’re almost ready to start the tracker, just add an alias in your .bashrc file to start the tracker at the same time as emacs like the following line of code:
alias emacs_full='devEnviLoad emacs >log & python3 ~/toy_playgrounds/emacs_coding_tracker/emacs_coding_tracker.py'
You’re ready to track your coding time. This should also work on remote host file use (using tramp) but don’t hesitate to let me know if something is wrong.
What is still needed to do is a script to build graphs and use the stat file. I’ll try to add this as fast as I can.
- Just start emacs using your new alias that launch the tracker at the same time. It will load the bookmarks and start listening for events happening to your history file.
- Each time you open a file by doing C-f or C-r-b the time of coding will start to be recorded for the file opened.
- To Save the time of coding for the files just close the buffer before closing emacs by doing C-k and the time spent on the file will be saved!
- If you close emacs and have still some files running it will save the time of work before closing the tracker also!
- Set the variable to point to your stat file in the script coding_stat_plotter.py
- Run the script and it will generate a pie chart of the different languages to see which language you used the most and a stat file of hours per day spent coding for the whole time you recorded your coding stats. It’s still experimental so I will need to tune those graphs and add some more graphs…