-
Notifications
You must be signed in to change notification settings - Fork 0
/
_promptrc
62 lines (52 loc) · 1.64 KB
/
_promptrc
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
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
### .promptrc - custom command prompt
# local vars for prompt colors
_RESET="$(tty -s && tput sgr0)"
# fg colors
#_BLACK_FG="$(tty -s && tput setaf 0)"
_RED_FG="$(tty -s && tput setaf 1)"
_GREEN_FG="$(tty -s && tput setaf 2)"
_YELLOW_FG="$(tty -s && tput setaf 3)"
#_PURPLE_FG="$(tty -s && tput setaf 4)"
#_MAGENTA_FG="$(tty -s && tput setaf 5)"
#_DARKCYAN_FG="$(tty -s && tput setaf 6)"
#_WHITE_FG="$(tty -s && tput setaf 7)"
_BRIGHTCYAN_FG="$(tty -s && tput setaf 14)"
_BOLD="$(tty -s && tput bold)"
_ddev_pst1() {
if [ -f ".ddev/config.yaml" ]; then
# mycmd="$(grep 'OK' <(ddev st))"
# if [ "$mycmd" -eq 0 ]; then
# echo "${_YELLOW_FG}${_BOLD} [ddev-on]${_RESET}"
# else
# echo "${_YELLOW_FG} [ddev-off]${_RESET}"
# fi
echo "${_YELLOW_FG} [ddev]${_RESET}"
fi
}
_ruby_pst1() {
# true;
if hash ruby 2>/dev/null; then
if [[ "$PWD" =~ ruby ]]; then
echo -e "(${_RED_FG}ruby:$(ruby -v 2>&1 | cut -d' ' -f2)${_RESET})"
fi
fi
}
# prompt vars
PS1_DIR="${_GREEN_FG}[\w]${_RESET}"
PS1_GIT="${_BOLD}${_BRIGHTCYAN_FG}\$(__git_ps1)${_RESET}"
PS1_DDEV="\$(_ddev_pst1)"
PS1_RUBY="\$(_ruby_pst1)"
PS1_HOST="\h"
PS1_USER="\[${_GREEN_FG}${_BOLD}\]\u\[${_YELLOW_FG}${_BOLD}\]@\[${_GREEN_FG}${_BOLD}\]$PS1_HOST\[${_RESET}\]"
PS1_DATE="\[${_YELLOW_FG}${_BOLD}\](\$(date +%T))\[${_RESET}\]"
# [dir] [ddev] (git)
export PS1_CUSTOM1="$PS1_DIR$PS1_DDEV$PS1_RUBY$PS1_GIT\n"
# adding emoji via emo
# if [ -f $GOPATH/bin/emo ]; then
# export PS1_CUSTOM1="$($GOPATH/bin/emo -n house-building) $PS1_CUSTOM1"
# fi
# user(date) $
export PS1_CUSTOM1="$PS1_CUSTOM1$PS1_USER$PS1_DATE "
# save prompt
export PS1=$PS1_CUSTOM1