Tyrael Tong
Tyrael Tong

Reputation: 761

extra output in zsh when define git log output format

when I try using

git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short

in zsh, there's always some extra output like:

27m/Users/tyraeltong/tmp/git-immersion/hello [n]' --graph --date=...* b1ca0c6 2012-01-08 | Added README (HEAD, master) [Tyrael Tong]
* 6844069 2012-01-08 | Added a Rakefile [Tyrael Tong]
* 99430f3 2012-01-08 | Moved hello.rb to lib [Tyrael Tong]
* da616c8 2012-01-08 | Add an author/email info [Tyrael Tong]
* d997079 2012-01-06 | Added a comment (v1) [Tyrael Tong]
* ea557cd 2012-01-06 | Added a default value (v1-beta) [Tyrael Tong]
* 0111ccd 2012-01-06 | First Commit [Tyrael Tong]

How could I remove the 27m/Users/tyraeltong/tmp/git-immersion/hello [n]' --graph --date=...?

Upvotes: 3

Views: 726

Answers (4)

ZyX
ZyX

Reputation: 53604

What you see is discussed in this oh-my-zsh issue. There is also a temporary fix:

All problems are because lib/termsupport.zsh lines 12. for a temporary fix, simply comment this line. this line try to set caption on terminal window. so its not a big deal to remove it :)

In the last comment there is a link to another fix:

You could also fix it like stated in https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/435336/comments/2

(note: it is better that you go to https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/435336/ as “/comments/2” URL displays only the second comment and nothing else)

Upvotes: 2

Martin Lundberg
Martin Lundberg

Reputation: 182

I tried to alias a slightly different command and had exactly the same issue.

This solved it for me:

alias glp='git log --pretty=format:"%h %an %ar - %"s""'

So by just putting s in quotation marks the output isn't prepended with garbage à la 27m anymore.

Upvotes: 1

Leventix
Leventix

Reputation: 3859

Inserting "" between % and s solved it for me:

git log --pretty=format:"%h %ad | %""s%d [%an]" --graph --date=short

Upvotes: 4

mkomitee
mkomitee

Reputation: 760

It's not your prompt. This happens to me with zsh and an empty PS1. zsh is doing something to expand %s thinking that in this case it is part of your prompt. It's fixed with a setopt nopromptpercent, but that will likely mess up your prompt.

A possibly non-portable solution is to prompt-escape the %s. Try running this instead:

git log --pretty=format:"%h %ad | %%s%d [%an]" --graph --date=short

Upvotes: 0

Related Questions