When I saw this article, I was really glad because I thought that I was the only person who use everyday text file. And I could get some tips that I can try in the future.
Ten Clever Uses for Plain Text Files That Can Increase Your Productivity
When I was a Windows programmer, I used Total Commander and UltraEditor as a file manager and text editor. And I made a simple program that makes a text file as a name of the day’s date. For example, diary09_23_2014.txt. Also, in UltraEditor, there was the functionality to insert date and time to the cursor position. I used this combination for a long time to write my thinking, research results, and piece of code.
When I started to use Linux, I had to find a good file manager and text editor for this purpose. For file manager, I tried several programs including Midnight Commander, Gnome Commander and Krusader. Between them, Krusader was the best for me. It is very stable and has many functions including FTP/SFTP connection.
And then, I had to find text editor. I tried many editors: GEdit, Tomboy, Geany, VI, VIM etc. And I decided to use emacs because I knew that emacs is world most customizable editor. At the same time, I knew that it was world most difficult editor to use. So, I spent more than 1 week only to study how to use it. I used a book called “Learning GNU Emacs”. There are still a lot to study.
With emacs, almost everything is possible using LISP script. I haven’t learn LISP yet. However, I could make simple functions using basic LISP syntax and additional bash script for my text diary purpose.
The bash script ~/sh/diary.sh is for making a text file “~/diary/diary11_30_2014.txt” with today’s date, and then put “====Sun Nov 30 15:56:59 EST 2014====” inside the file(end of the file).
_now2=$(date +”%a %b %d %H:%M:%S %Z %Y”)
echo “====$_now2====” >> $_file
If I learn LISP more in the future, I could change it to LISP function. However, the benefit of this bash script is that it can be used outside the emacs.
Following is functions in ~/.emacs file.
|;;;;;;;;;;;;;;;;open diary file
(defun diary ()
(find-file (substring (shell-command-to-string “~/sh/diary.sh”)0 -1) )
)(defun diary-search (newnote)
(interactive “sSearch: “)
(format “grep ‘%s’ ~/diary/*.txt” newnote))
(global-set-key (kbd “C-S-d”) ‘diary)
;;;;;;;;;;;;;;;;insert date and time
(defvar current-date-time-format “====%a %b %d %H:%M:%S %Z %Y====”
“Format of date to insert with `insert-current-date-time’ func
See help of `format-time-string’ for possible replacements”)(defun insert-current-date-time ()
“insert the current date and time into current buffer.
Uses `current-date-time-format’ for the formatting the date/time.”
(insert (format-time-string current-date-time-format (current-time)))
(global-set-key “\C-c\C-d” ‘insert-current-date-time)
insert-current-date-time function is modified from this link.
When I push Ctrl-Shift-D, diary() function makes a text file if there is no today’s diary file, and open it with the buffer name “diary”. If there is today’s file, put current date and time at the end of the file and move the cursor to the last position.
“M-x diary-search” is for searching text from text diaries inside ~/diary directory using grep shell command. Like below. I can open the file and see the contents by clicking it in the result list.
“C-c C-d” is to insert current time to current cursor position while editing diary file.
If I make a text file everyday, after several years, there are so many files. So, I merge the files to 1 file per 1 month or 1 year. Because inside the diary, there are year, date and time in every section. Search works the same, so whether it’s day file or month file doesn’t matter.
Also It can be synchronized to evernote, dropbox etc., to search from my phone.