I've been using iTerm2 with zsh, and with this following alias I get an error every time I open a new iTerm2 window or tab.
alias clear-git-branches="git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done"
The error I get is:
fatal: not a git repository (or any of the parent directories): .git
Since it's throwing an error related to directory not being a git repository, my guess is that it got some problem related with its quotes. I tried changing it but got the same error.
I use this command to clear local branches with no upstream.
.git
sub-directory. Check out what you have in your home directory - that should be your current directory that is changed upon the creation of a new tab. Also, try to take the Operating System Commands (such asgit fetch -p
, for instance) one by one and see what is going on with each one of them. Debugging a whole One-Liner at once in an instant is a Trick performed only by Master Minds. Also, this has nothing to do with the Bourne-Again Shell-Scripting Environment.