Rename _bkdate to insert-datestamp and enter date at cursor position instead of end...
authorMichael Prokop <mika@grml.org>
Mon, 31 May 2010 16:25:04 +0000 (18:25 +0200)
committerMichael Prokop <mika@grml.org>
Mon, 31 May 2010 16:39:43 +0000 (18:39 +0200)
Thanks to Martin Krafft for the inspiration.

etc/zsh/zshrc

index 430d9a7..a1853f3 100644 (file)
@@ -906,11 +906,11 @@ if is4 && [[ -n ${(k)modules[zsh/complist]} ]] ; then
 fi
 
 # press "ctrl-e d" to insert the actual date in the form yyyy-mm-dd
-_bkdate() { BUFFER="$BUFFER$(date '+%F')"; CURSOR=$#BUFFER; }
-zle -N _bkdate
+insert-datestamp() { LBUFFER+=${(%):-'%D{%Y-%m-%d}'}; }
+zle -N insert-datestamp
 
 #k# Insert a timestamp on the command line (yyyy-mm-dd)
-bindkey '^Ed' _bkdate
+bindkey '^Ed' insert-datestamp
 
 # press esc-m for inserting last typed word again (thanks to caphuso!)
 insert-last-typed-word() { zle insert-last-word -- 0 -1 };