Created
August 11, 2012 13:42
-
-
Save draptik/3324534 to your computer and use it in GitHub Desktop.
PS1 prompt with git branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Idea from: | |
# | |
# https://bbs.archlinux.org/viewtopic.php?pid=1068202 | |
# Colors https://wiki.archlinux.org/index.php/Color_Bash_Prompt | |
# Note: We require escape '\[' and '\]' around the ansi escapes | |
# (i.e. '\e[0m')! Otherwise the shell does not know that the ansi | |
# escapes should be excluded from the line wrapping calculation. | |
# | |
# See | |
# http://hintsforums.macworld.com/showthread.php?t=17068 and | |
# http://www.davidpashley.com/articles/bash-prompts.html | |
## for details. | |
# Reset | |
NC='\[\e[0m\]' # Text Reset | |
# Regular Colors | |
Black='\[\e[0;30m\]' # Black | |
Red='\[\e[0;31m\]' # Red | |
Green='\[\e[0;32m\]' # Green | |
Yellow='\[\e[0;33m\]' # Yellow | |
Blue='\[\e[0;34m\]' # Blue | |
Purple='\[\e[0;35m\]' # Purple | |
Cyan='\[\e[0;36m\]' # Cyan | |
White='\[\e[0;37m\]' # White | |
# High Intensty | |
IBlack='\[\e[0;90m\]' # Black | |
IRed='\[\e[0;91m\]' # Red | |
IGreen='\[\e[0;92m\]' # Green | |
IYellow='\[\e[0;93m\]' # Yellow | |
IBlue='\[\e[0;94m\]' # Blue | |
IPurple='\[\e[0;95m\]' # Purple | |
ICyan='\[\e[0;96m\]' # Cyan | |
IWhite='\[\e[0;97m\]' # White | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="${NC}[${IYellow}\w${NC}] has ${IYellow}\$((\$(find . -maxdepth 1 | wc -l) - 1))${NC} total files,\ | |
${IYellow}\$((\$(find . -maxdepth 1 | wc -l) - \$(find . -maxdepth 1 ! -name \.\* | wc -l) -1))${NC} hidden,\ | |
${IYellow}\$(find . -maxdepth 1 -type f -perm -u+rx | wc -l)${NC} executable.\n${Green}\$(parse_git_branch) ${IYellow}\$${NC} " | |
export PS1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment