-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_prompt
executable file
·51 lines (44 loc) · 1.82 KB
/
.bash_prompt
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
46
47
48
49
50
51
#!/bin/bash
BLACK="\[\033[0;30m\]"
BLACK_B="\[\033[1;30m\]"
RED="\[\033[0;31m\]"
RED_B="\[\033[1;31m\]"
GREEN="\[\033[0;32m\]"
GREEN_B="\[\033[1;32m\]"
YELLOW="\[\033[0;33m\]"
YELLOW_B="\[\033[1;33m\]"
BLUE="\[\033[0;34m\]"
BLUE_B="\[\033[1;34m\]"
PURPLE="\[\033[0;35m\]"
PURPLE_B="\[\033[1;35m\]"
CYAN="\[\033[0;36m\]"
CYAN_B="\[\033[1;36m\]"
WHITE="\[\033[0;37m\]"
WHITE_B="\[\033[1;37m\]"
CLEAR="\[\033[0m\]"
TTY=$(/usr/bin/basename $(/usr/bin/tty))
SSH_WORD="${YELLOW_B}ssh"
#PS1_HOSTNAME=${HOSTNAME}
PS1_HOSTNAME="mbp"
PS1_PWD=$(pwd)
$(echo $TTY| grep '[^0-9]' >/dev/null)
IS_PTY=$?
if [ "`id -u`" -eq 0 ]; then # user is root
if [ "$SSH_TTY" != "" ]; then # we are SSH'd in
PS1="${WHITE_B}[${WHITE}${SSH_WORD}${WHITE_B}!${RED}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${RED}#${CLEAR} "
elif [ "$SSH_TTY" = "" ] && [ "$IS_PTY" -eq 1 ]; then # terminal is a pty
PS1="${WHITE_B}[${RED}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${RED}#${CLEAR} "
else # likely a standard virtual terminal or a serial terminal
PS1="${WHITE_B}[${WHITE}${TTY}${WHITE_B}!${RED}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${RED}#${CLEAR} "
fi
else # user is not root
if [ "$SSH_TTY" != "" ]; then # we are SSH'd in
PS1="${WHITE_B}[${WHITE}${SSH_WORD}${WHITE_B}!${CYAN}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${CYAN}\$${CLEAR} "
elif [ "$SSH_TTY" = "" ] && [ "$IS_PTY" -eq 1 ]; then # terminal is a pty
PS1="${WHITE_B}[${CYAN}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${CYAN}\$${CLEAR} "
else # likely a standard virtual terminal or a serial terminal
PS1="${WHITE_B}[${WHITE}${TTY}${WHITE_B}!${CYAN}\u${WHITE_B}@${CLEAR}${PS1_HOSTNAME}${WHITE_B}:${CLEAR}\W${WHITE_B}]${CYAN}\$${CLEAR} "
fi
fi
export PROMPT_COMMAND='pwd'
echo $PS1