Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 67 lines (53 sloc) 1.954 kb
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
1 # @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
2 # Shamelessly copied from https://github.com/gf3/dotfiles
3
4cbdac7 @paulirish only show user/host for not my machine.
authored
4 default_username='paulirish'
5
6
7
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
8 if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
9 export TERM=gnome-256color
10 elif infocmp xterm-256color >/dev/null 2>&1; then
11 export TERM=xterm-256color
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
12 fi
13
14 if tput setaf 1 &> /dev/null; then
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
15 tput sgr0
16 if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
17 MAGENTA=$(tput setaf 9)
18 ORANGE=$(tput setaf 172)
19 GREEN=$(tput setaf 190)
20 PURPLE=$(tput setaf 141)
21 WHITE=$(tput setaf 256)
22 else
23 MAGENTA=$(tput setaf 5)
24 ORANGE=$(tput setaf 4)
25 GREEN=$(tput setaf 2)
26 PURPLE=$(tput setaf 1)
27 WHITE=$(tput setaf 7)
28 fi
29 BOLD=$(tput bold)
30 RESET=$(tput sgr0)
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
31 else
6b75bfc @mathiasbynens Use tabs instead of double-space indents
mathiasbynens authored
32 MAGENTA="\033[1;31m"
33 ORANGE="\033[1;33m"
34 GREEN="\033[1;32m"
35 PURPLE="\033[1;35m"
36 WHITE="\033[1;37m"
37 BOLD=""
38 RESET="\033[m"
7d02270 @mathiasbynens Initial commit.
mathiasbynens authored
39 fi
40
cd40d5e @paulirish iterm title tab stuff almost working
authored
41
42 function parse_git_dirty() {
43 [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
44 }
45
46 function parse_git_branch() {
47 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
48 }
49
4cbdac7 @paulirish only show user/host for not my machine.
authored
50 # Only show username/host if not default
51 function usernamehost() {
52 if [ $USER != $default_username ]; then echo "${MAGENTA}$USER ${WHITE}at ${ORANGE}$HOSTNAME $WHITEin "; fi
53 }
54
8d23239 @paulirish iterm title bar attempt #2
authored
55 # iTerm Tab and Title Customization and prompt customization
5f27494 @paulirish add url
authored
56 # http://sage.ucsc.edu/xtal/iterm_tab_customization.html
8d23239 @paulirish iterm title bar attempt #2
authored
57
58 # Put the string " [bash] hostname::/full/directory/path"
59 # in the title bar using the command sequence
60 # \[\e]2;[bash] \h::\]$PWD\[\a\]
61
5d583a9 @paulirish whitespace
authored
62 # Put the penultimate and current directory
8d23239 @paulirish iterm title bar attempt #2
authored
63 # in the iterm tab
64 # \[\e]1;\]$(basename $(dirname $PWD))/\W\[\a\]
65
4cbdac7 @paulirish only show user/host for not my machine.
authored
66 PS1="\[\e]2;$PWD\[\a\]\[\e]1;\]$(basename "$(dirname "$PWD")")/\W\[\a\]${BOLD}\$(usernamehost)\[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
Something went wrong with that request. Please try again.