PROMPT with git branch

Jul 22, 2015
2
0
I'm looking to duplicate some of the functionality that my other programmer friends utilize in TCC.

Specifically, the ability to output the current git-branch of the directory that I'm in.

Not every directory will be a git directory, and I would want any directory under the local repo to report the branch.

Anyone accomplished this?
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I am not familiar with git. How do you get the information you are interested in? I assume there is a git command that returns that information.

Assuming you have a function that returns the text you want, lets call it @gitbranch, you could create a PROMPT that looks like this:
Code:
PROMPT [%@if[%@gitbranch[].==.,,(%@gitbranch[]) ]$P]$s

You could also do something similar with TITLEPROMPT to update the Tab text or console window title.

Assuming the command to get the branch is "git branch --list" then a simple @gitbranch could be:
Code:
function gitbranch=`%@execstr[git branch --list]`
If the command returns data that needs to be parsed, then you can use @WORD and/or have @execstr return a specific line of the output.
 
Similar threads
Thread starter Title Forum Replies Date
vefatica ANSI, PROMPT ... ??? Support 1
FreezerBurnt ANSI Prompt messes up list output. Support 39
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
M How to? Black TCC Prompt Support 2
N Command execution slows down in TCC Prompt after a while Support 6
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
vefatica Timing commands with $= in the prompt? Support 16
samintz How to? Alias or prompt? Support 1
T Elapsed time format in prompt changed in TCC 25 Support 10
samintz MOVE and Prompt on overwrite Support 3
robinsiebler Creating a custom prompt Support 9
K TCC prompt background color Support 4
Alpengreis Problem if command prompt is not legacy Support 4
Joe Caverly Documentation Customizing the TCC Prompt Support 0
C How to? handle the UAC prompt on computer restarts with Everything Support 3
B when doing SFTP via IFTP to my secure site my users always get the finger print key prompt Support 1
MikeBaas How to? SELECT: exclude files / display prompt Support 2
vefatica ? "prompt" command Support 3
S Elapsed time in TCC prompt question Support 0
Joe Caverly Determine if program started from command prompt Support 2
W Opening a new tab takes forever to get the command prompt Support 5
vefatica UAC prompt? Support 0
C How to? ctrl-c does not prompt "Terminate batch job" Support 2
Mordachai TCMD Prompt Here?!@ Support 14
vefatica Fixed DO, OSD, and cancel batch prompt Support 3
CWBillow Send Command-line with prompt? Support 6
David McClelland Why the prompt to del c:\* Support 7
S WAD BDEBUGGER command changes window title to "TCC Prompt" Support 4
S WAD Invoking BDEBUGGER changes window title to "TCC Prompt" Support 7
vefatica Cancel batch prompt? Support 0
1 CMD file kicks out to prompt Support 18
Steve Pitts Are you sure prompt from DEL command Support 5
Exolon Strange Prompt. Support 6
JohnQSmith TC 13 - Prompt Support 2
S TITLEPROMPT - width x height in prompt? Support 14
T Wrong prompt in Windows command console Support 3
S 4NT - delete from command prompt and recycle bin Support 12
vefatica @@key aliases cause new prompt? Support 16
H Another multiple FTP password prompt issue Support 2
H Double prompt for password with * in FTP syntax Support 3
CWBillow TCMD prompt here only opens to root Support 6
D setting days back at prompt Support 12
M TCC Prompt Here Colors Support 0
Phileosophos Using a percent sign in the PROMPT Support 3
Charles Dye INPUT prompt oddity Support 5
R Start Prompt Here? Support 9
Ville Changing folders location from TCC prompt? Support 7
E Shorter prompt / ANSI codes support Support 10
Ó Recent git output not shown on TCC Support 1
R How do I get a Git Bash shell to appear in TCC window? Support 7

Similar threads