83 lines
1.7 KiB
Bash
Raw Normal View History

2014-04-08 11:22:09 -07:00
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
2014-05-01 23:28:17 -07:00
BoldYellow='\e[1;33m' # Yellow
2014-10-20 16:41:14 -07:00
Gray="\[\033[1;30m\]"
2014-04-08 11:22:09 -07:00
2014-04-08 11:00:25 -07:00
function current_directory() {
2014-05-01 23:28:17 -07:00
pwd | sed "s:$HOME:~:"
2014-04-08 11:00:25 -07:00
}
2014-05-01 23:28:17 -07:00
2014-04-08 11:22:09 -07:00
function git_prompt_info() {
2014-04-14 20:49:44 -07:00
if test -z $(git branch-or-sha);
2014-04-08 11:00:25 -07:00
then
echo ""
else
2014-05-01 23:28:17 -07:00
echo " $(separator "on") $(git branch-or-sha)$(git_status_character)"
2014-04-08 11:22:09 -07:00
fi
}
function git_status_character() {
2014-04-14 20:49:44 -07:00
if git dirty;
2014-04-08 11:22:09 -07:00
then
2014-05-01 23:28:17 -07:00
print_with_color "✘" "$Red"
2014-04-08 11:22:09 -07:00
else
2014-05-01 23:28:17 -07:00
print_with_color "✔" "$Green"
2014-04-08 11:22:09 -07:00
fi
}
2014-05-01 23:28:17 -07:00
function command_line_character() {
if ! test -z $(git branch-or-sha);
then
echo "±"
else
echo "○"
2014-04-08 11:00:25 -07:00
fi
}
2014-05-01 23:28:17 -07:00
function prompt_basic_colors() {
export USERNAME_COLOR="$Green"
export SEPARATOR_COLOR="$Black"
export HOSTNAME_COLOR="$Blue"
export CURRENT_DIRECTORY_COLOR="$BoldYellow"
2014-10-20 16:41:14 -07:00
export SEPARATOR_COLOR="$Gray"
2014-05-01 23:28:17 -07:00
}
function print_with_color() {
echo "$2$1\e[0m"
}
function separator() {
print_with_color "$1" "$SEPARATOR_COLOR"
}
prompt_basic_colors
function set_bash_prompt() {
PS1="╭─$(print_with_color "$(whoami)" "$USERNAME_COLOR") $(separator "at") $(print_with_color "`hostname -s`" "$HOSTNAME_COLOR") $(separator "in") $(print_with_color "`current_directory`" "$CURRENT_DIRECTORY_COLOR")$(git_prompt_info)
2014-05-01 23:28:17 -07:00
╰─$(command_line_character) "
}
2014-11-20 17:41:17 -08:00
# export PROMPT_COMMAND=set_bash_prompt
2014-05-01 23:28:17 -07:00
PS2='(%_) '
case "$TERM" in
dumb)
export PS1='> '
;;
esac
2014-11-20 17:41:17 -08:00
function set_powerline_prompt {
source "$(python_module_path powerline)/bindings/bash/powerline.sh"
}
set_powerline_prompt