I am a heavy Vim user and I also use a ton of tmux and a load of bash in my everyday computer activities.

In order to optimize my work flow, even more, I would like a way to get a log of all key presses, I do during my computer sessions.

What I am looking for is a program that would work something like this:

keylogger -o log.txt | bash

And then everything I type in my bash session gets logged, to log.txt. Where log.txt ends up something like this:

vi wefwef.c<cr>
iHello, world!<esc>
VUoHAHAHAHAHAHA hahahah!<esc>hhllb
:!grep -a 66 /usr/bin/vi | aplay<cr>
cat wefwef.txt<cr>
make war<cr>
echo vivivi is the editor of the beast!!<cr>
yes | rm -rf /<cr>
ps -A | grep '[0-9]\+' -o | xargs kill -9<cr>
exit 666<cr>

… And then I can use this information to optimize my workflow even more!

Is there an Unix tool similar to the one I described?


1 Answer 1


From zsh, you could do something like:

cmd="stty rows $LINES cols $COLUMNS; stty '$(stty -g)'; bash"
STTY='raw -echo' cat > typescript.in | script -c "$cmd"

Then you'd have what you typed in typescript.in and the output in typescript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .