I am using a Mac Mini running Lion (10.7.5) and zsh 4.3.12 (i386-apple-darwin11.0.1) with oh-my-zsh installed. In the Terminal.app I retrieve the UNIX timestamp using the following command

date +%s

It should print out a string of decimal digits - as the time of writing 1357294199, however it prints 27m1357294199. Notice the 27mprefix. It stays constant aka. does not change with time.

I already tried the following but to no avail

  • Closed and reopened the Terminal.app
  • Restarted my computer

Why does the date command print this extra prefix and how do I get rid of it?

Follow-ups (Note: For the sake of simplicity outputs will use a constant timestamp)

  • The command date '+%s' outputs 27m'1357294199
  • Command /bin/echo Hello World prints Hello World
  • type date gives date is /bin/date
  • /bin/date +%s prints 27m'1357294199
  • What happens if you run it as date '+%s? And what does /bin/echo Hello World display? If they show the same problem, try PS1= date +%s. – nohillside Jan 4 '13 at 11:07
  • patrix, please find the information you requested in the follow-up section as also more about the shell I use – lunohodov Jan 4 '13 at 12:13
  • Can you tell us the output of type date? And can you try /bin/date +%s? – Matteo Jan 4 '13 at 12:34
  • 1
    Which version of oh-my-zsh are you using? The issue was solved several month ago: github.com/robbyrussell/oh-my-zsh/issues/57 – Matteo Jan 4 '13 at 12:58
  • 1
    Looks like a misplaced ANSI escape character – Thorbjørn Ravn Andersen Jan 4 '13 at 15:44

The issue was due to a bug in oh-my-zsh:

  1. The bug was fixed several months ago: update oh-my-zsh and the issue should be solved.

  2. If for any reason you cannot update there is fix on StackOverflow (https://stackoverflow.com/questions/12321564/date-command-with-zsh) but it involves the editing of lib/termsupport.zsh: remove the 12th line (warning I do not have oh-my-zsh installed and cannot check if the line number is really the correct one).

|improve this answer|||||

You must log in to answer this question.

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