I’m trying to log the time I spend working in vim. I’ve got a script that works with gvim but when I try to set it up with vim it locks up the terminal session silently or with the message ‘Vim: Warning: Output is not to a terminal’
Here is the script that works with gvim:
#!/bin/sh
workfile="/home/na/writing/fiction.txt"
worklog="/home/na/writing/worktime.log"
d=`date --rfc-3339 date`
t=$( { /usr/bin/time -f "%e" /usr/local/bin/gvim -f -S /home/na/.vim/writeroom/writeroom.vim $workfile; } 2>&1 )
w=`wc -w $workfile`
echo $d $t $w >> $worklog
When I close the gvim window I get a logfile containing a date, the number of seconds I spent editing the file, and a word count for the file.
2011-08-15 700.15 238869 /home/na/writing/fiction.txt
I would like the same using vim in a terminal session.
I understand vim talks to the terminal directly instead of to stdout but I don’t care about what vim returns, I want the output from the time command.
These don’t work:
t=`/usr/bin/time -f "%e" /usr/local/bin/vim -f $workfile`
t=$( { /usr/bin/time -f "%e" /usr/local/bin/vim -f $workfile; } 2>&1 )
t=$( { /usr/bin/time -f "%e" /usr/local/bin/vim -f $workfile; } )
I suspect there’s some combination of backticks and paranthesis that will make this work but I haven’t stumbled onto it yet.
The backtick or
$()operators capture vim’s output (what you see on the terminal when opening vim is vim’s output from its stdout), so you can’t do that.You could try this instead: