From owner-freebsd-git@freebsd.org Fri Dec 4 16:19:16 2015 Return-Path: Delivered-To: freebsd-git@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CFC0A41E2C for ; Fri, 4 Dec 2015 16:19:16 +0000 (UTC) (envelope-from bright@mu.org) Received: from elvis.mu.org (elvis.mu.org [IPv6:2001:470:1f05:b76::196]) by mx1.freebsd.org (Postfix) with ESMTP id 6DBB21CEE for ; Fri, 4 Dec 2015 16:19:16 +0000 (UTC) (envelope-from bright@mu.org) Received: from Alfreds-MacBook-Pro-2.local (unknown [IPv6:2601:645:8004:7515:c1b:8b90:5c08:82e7]) by elvis.mu.org (Postfix) with ESMTPSA id D9A6D345A921 for ; Fri, 4 Dec 2015 08:19:15 -0800 (PST) Subject: Re: Put working git branch in shell prompt for bash and zsh? To: freebsd-git@freebsd.org References: From: Alfred Perlstein Message-ID: <5661BD03.2090204@mu.org> Date: Fri, 4 Dec 2015 08:19:15 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-git@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion of git use in the FreeBSD project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 16:19:16 -0000 On 12/4/15 6:20 AM, Craig Rodrigues wrote: > Hi, > > I am heavily using git for my projects these days. > Typically I am working on multiple projects, with > multiple checked out trees. I am also switching > between branches a lot. > > Sometimes because I am working with so many > checked out trees, I lose track of what branch > I am working on. > > Can anyone point me to a "stupid shell trick" > which would put the currently active branch in the > shell prompt? I typically use bash and zsh shells, > so having the trick for those shells would be useful. > > Thank! I believe you can use the output of `git rev-parse --abbrev-ref HEAD` If this doesn't work exactly, then just play around with git's "rev-parse" command, it should work. -Alfred