|
4 | 4 | # iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
|
5 | 5 |
|
6 | 6 | if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
|
7 |
| - export TERM='gnome-256color'; |
| 7 | + export TERM='gnome-256color'; |
8 | 8 | elif infocmp xterm-256color >/dev/null 2>&1; then
|
9 |
| - export TERM='xterm-256color'; |
| 9 | + export TERM='xterm-256color'; |
10 | 10 | fi;
|
11 | 11 |
|
12 | 12 | prompt_git() {
|
13 |
| - local s=''; |
14 |
| - local branchName=''; |
| 13 | + local s=''; |
| 14 | + local branchName=''; |
15 | 15 |
|
16 |
| - # Check if the current directory is in a Git repository. |
17 |
| - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then |
| 16 | + # Check if the current directory is in a Git repository. |
| 17 | + if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then |
18 | 18 |
|
19 |
| - # check if the current directory is in .git before running git checks |
20 |
| - if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then |
| 19 | + # check if the current directory is in .git before running git checks |
| 20 | + if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then |
21 | 21 |
|
22 |
| - # Ensure the index is up to date. |
23 |
| - git update-index --really-refresh -q &>/dev/null; |
| 22 | + # Ensure the index is up to date. |
| 23 | + git update-index --really-refresh -q &>/dev/null; |
24 | 24 |
|
25 |
| - # Check for uncommitted changes in the index. |
26 |
| - if ! $(git diff --quiet --ignore-submodules --cached); then |
27 |
| - s+='+'; |
28 |
| - fi; |
| 25 | + # Check for uncommitted changes in the index. |
| 26 | + if ! $(git diff --quiet --ignore-submodules --cached); then |
| 27 | + s+='+'; |
| 28 | + fi; |
29 | 29 |
|
30 |
| - # Check for unstaged changes. |
31 |
| - if ! $(git diff-files --quiet --ignore-submodules --); then |
32 |
| - s+='!'; |
33 |
| - fi; |
| 30 | + # Check for unstaged changes. |
| 31 | + if ! $(git diff-files --quiet --ignore-submodules --); then |
| 32 | + s+='!'; |
| 33 | + fi; |
34 | 34 |
|
35 |
| - # Check for untracked files. |
36 |
| - if [ -n "$(git ls-files --others --exclude-standard)" ]; then |
37 |
| - s+='?'; |
38 |
| - fi; |
| 35 | + # Check for untracked files. |
| 36 | + if [ -n "$(git ls-files --others --exclude-standard)" ]; then |
| 37 | + s+='?'; |
| 38 | + fi; |
39 | 39 |
|
40 |
| - # Check for stashed files. |
41 |
| - if $(git rev-parse --verify refs/stash &>/dev/null); then |
42 |
| - s+='$'; |
43 |
| - fi; |
| 40 | + # Check for stashed files. |
| 41 | + if $(git rev-parse --verify refs/stash &>/dev/null); then |
| 42 | + s+='$'; |
| 43 | + fi; |
44 | 44 |
|
45 |
| - fi; |
| 45 | + fi; |
46 | 46 |
|
47 |
| - # Get the short symbolic ref. |
48 |
| - # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit |
49 |
| - # Otherwise, just give up. |
50 |
| - branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ |
51 |
| - git rev-parse --short HEAD 2> /dev/null || \ |
52 |
| - echo '(unknown)')"; |
| 47 | + # Get the short symbolic ref. |
| 48 | + # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit |
| 49 | + # Otherwise, just give up. |
| 50 | + branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ |
| 51 | + git rev-parse --short HEAD 2> /dev/null || \ |
| 52 | + echo '(unknown)')"; |
53 | 53 |
|
54 |
| - [ -n "${s}" ] && s=" [${s}]"; |
| 54 | + [ -n "${s}" ] && s=" [${s}]"; |
55 | 55 |
|
56 |
| - echo -e "${1}${branchName}${blue}${s}"; |
57 |
| - else |
58 |
| - return; |
59 |
| - fi; |
| 56 | + echo -e "${1}${branchName}${blue}${s}"; |
| 57 | + else |
| 58 | + return; |
| 59 | + fi; |
60 | 60 | }
|
61 | 61 |
|
62 | 62 | if tput setaf 1 &> /dev/null; then
|
63 |
| - tput sgr0; # reset colors |
64 |
| - bold=$(tput bold); |
65 |
| - reset=$(tput sgr0); |
66 |
| - # Solarized colors, taken from http://git.io/solarized-colors. |
67 |
| - black=$(tput setaf 0); |
68 |
| - blue=$(tput setaf 33); |
69 |
| - cyan=$(tput setaf 37); |
70 |
| - green=$(tput setaf 64); |
71 |
| - orange=$(tput setaf 166); |
72 |
| - purple=$(tput setaf 125); |
73 |
| - red=$(tput setaf 124); |
74 |
| - violet=$(tput setaf 61); |
75 |
| - white=$(tput setaf 15); |
76 |
| - yellow=$(tput setaf 136); |
| 63 | + tput sgr0; # reset colors |
| 64 | + bold=$(tput bold); |
| 65 | + reset=$(tput sgr0); |
| 66 | + # Solarized colors, taken from http://git.io/solarized-colors. |
| 67 | + black=$(tput setaf 0); |
| 68 | + blue=$(tput setaf 33); |
| 69 | + cyan=$(tput setaf 37); |
| 70 | + green=$(tput setaf 64); |
| 71 | + orange=$(tput setaf 166); |
| 72 | + purple=$(tput setaf 125); |
| 73 | + red=$(tput setaf 124); |
| 74 | + violet=$(tput setaf 61); |
| 75 | + white=$(tput setaf 15); |
| 76 | + yellow=$(tput setaf 136); |
77 | 77 | else
|
78 |
| - bold=''; |
79 |
| - reset="\e[0m"; |
80 |
| - black="\e[1;30m"; |
81 |
| - blue="\e[1;34m"; |
82 |
| - cyan="\e[1;36m"; |
83 |
| - green="\e[1;32m"; |
84 |
| - orange="\e[1;33m"; |
85 |
| - purple="\e[1;35m"; |
86 |
| - red="\e[1;31m"; |
87 |
| - violet="\e[1;35m"; |
88 |
| - white="\e[1;37m"; |
89 |
| - yellow="\e[1;33m"; |
| 78 | + bold=''; |
| 79 | + reset="\e[0m"; |
| 80 | + black="\e[1;30m"; |
| 81 | + blue="\e[1;34m"; |
| 82 | + cyan="\e[1;36m"; |
| 83 | + green="\e[1;32m"; |
| 84 | + orange="\e[1;33m"; |
| 85 | + purple="\e[1;35m"; |
| 86 | + red="\e[1;31m"; |
| 87 | + violet="\e[1;35m"; |
| 88 | + white="\e[1;37m"; |
| 89 | + yellow="\e[1;33m"; |
90 | 90 | fi;
|
91 | 91 |
|
92 | 92 | # Highlight the user name when logged in as root.
|
93 | 93 | if [[ "${USER}" == "root" ]]; then
|
94 |
| - userStyle="${red}"; |
| 94 | + userStyle="${red}"; |
95 | 95 | else
|
96 |
| - userStyle="${orange}"; |
| 96 | + userStyle="${orange}"; |
97 | 97 | fi;
|
98 | 98 |
|
99 | 99 | # Highlight the hostname when connected via SSH.
|
100 | 100 | if [[ "${SSH_TTY}" ]]; then
|
101 |
| - hostStyle="${bold}${red}"; |
| 101 | + hostStyle="${bold}${red}"; |
102 | 102 | else
|
103 |
| - hostStyle="${yellow}"; |
| 103 | + hostStyle="${yellow}"; |
104 | 104 | fi;
|
105 | 105 |
|
106 | 106 | # Set the terminal title to the current working directory.
|
|
0 commit comments