Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to write a script for GeekTool that will show my last X (20) commands on my screen.

I can either display a file or use the output of a shell command (preferred).

The problem is that when I run the command from a script I get ~/bin/ no such event: 0 as an error.

My script file is:

#!/bin/zsh --login
#history | tail -n 25 > /tmp/history.txt

export HISTFILE=~/.zsh_history 
fc -l -20 -1

The fc command works if I run it from a shell; however if I run it from the script then it fails. I think it has something to do with it not being able to read the history file, but have no confirmation of this.

I can not directly use the .zsh_history file as I use ZSH extended history and has embedded meta data.

share|improve this question
up vote 2 down vote accepted

You should add a fc -R to force reading the history file, and delete that -1

#!/bin/zsh --login
#history | tail -n 25 > /tmp/history.txt

export HISTFILE=~/.zsh_history 
fc -R
fc -l -20
share|improve this answer
This was the exact problem... it wasn't clear to me that it must happen in two separate commands. Thanks! – Andrew Burns Jan 9 '13 at 22:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.