Skip to content

Instantly share code, notes, and snippets.

@scottstanfield
Created June 14, 2011 17:03
Show Gist options
  • Save scottstanfield/1025341 to your computer and use it in GitHub Desktop.
Save scottstanfield/1025341 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Includes current git branch in tcsh prompt.
#
# EXAMPLE
#
# Your prompt can look like this:
#
# [myhost.com ~/repos/foo (master)]
#
# USAGE:
#
# 1) Save this script as ~/bin/setprompt
# 2) In .cshrc, include this line:
#
# alias precmd "source ~/bin/setprompt"
#
# AUTHOR
#
# Original from http://acts.as.streeteasy.com/archives/2007/12/19/git_in_your_prompt/
# Modified for tcsh by Geoffrey Grosenbach http://peepcode.com
switch ( `uname` )
case Darwin:
set ptail = "»"; breaksw;
case Linux:
set ptail = "ϕ"; breaksw;
default:
set ptail = "%"; breaksw;
endsw
set color_blue="%{\033[0;34m%}"
set color_gray="%{\033[1;36m%}"
set color_normal="%{\033[0m%}"
setenv GIT_PROMPT "git status |& git-prompt.awk"
set p1="%B%m%b:%B$color_blue%~${color_normal}%b"
#set p1="%B%m%b:%B$color_blue%c${color_normal}%b"
set prompt="${p1}${color_gray}`$GIT_PROMPT`${color_normal} ${ptail} "
@scottstanfield
Copy link
Author

This file requires git-prompt.awk, which is here: https://gist.github.com/1025376

@scottstanfield
Copy link
Author

Stick this in your .cshrc (for a /bin/tcsh shell) and it should all work:
alias precmd "source ~/bin/setprompt"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment