forked from ozsun88/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.prompt
More file actions
45 lines (37 loc) · 1.39 KB
/
.prompt
File metadata and controls
45 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
tput sgr0
LIGHTRED=$(tput setaf 9)
ORANGE=$(tput setaf 172)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 256)
BOLD=$(tput bold)
RESET=$(tput sgr0)
function git_info() {
# check if we're in a git repo
git rev-parse --is-inside-work-tree &>/dev/null || return
# quickest check for what branch we're on
branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
# check if it's dirty (via github.com/sindresorhus/pure)
dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
echo $RESET" on "$LIGHTRED$branch$dirty
}
# Only show username/host if not default
function usernamehost() {
if [ "$SSH_TTY" ]; then
echo "${PURPLE}$USER@$HOSTNAME${RESET}:";
fi
}
# iTerm Tab and Title Customization and prompt customization
# http://sage.ucsc.edu/xtal/iterm_tab_customization.html
# Put the string " [bash] hostname::/full/directory/path"
# in the title bar using the command sequence
# \[\e]2;[bash] \h::\]$PWD\[\a\]
# Put the penultimate and current directory
# in the iterm tab
# \[\e]1;\]$(basename $(dirname $PWD))/\W\[\a\]
PS1="\[\e]2;$PWD\[\a\]\[\e]1;\]$(basename "$(dirname "$PWD")")/\W\[\a\]\$(usernamehost)\[$ORANGE\]\w\$(git_info)\[$RESET\]\n\$ "