From f6656487d7b728cffb584d7558074d3850f0d322 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 29 Jun 2016 20:23:51 -0700 Subject: Source custom scripts from directory --- home/.bashrc | 7 +++++-- home/.bashrc.d/prompt.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ home/.bashrc.d/spark.sh | 2 ++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 home/.bashrc.d/prompt.sh create mode 100644 home/.bashrc.d/spark.sh (limited to 'home') diff --git a/home/.bashrc b/home/.bashrc index 4516a35..dc97397 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -112,5 +112,8 @@ if ! shopt -oq posix; then fi fi -# Spark: don't run scalastyle on every compile -export NOLINT_ON_COMPILE=true +if [ -d "$HOME/.bashrc.d" ]; then + for script in "$HOME/.bashrc.d/"*; do + . "$script" + done +fi diff --git a/home/.bashrc.d/prompt.sh b/home/.bashrc.d/prompt.sh new file mode 100644 index 0000000..7471bc6 --- /dev/null +++ b/home/.bashrc.d/prompt.sh @@ -0,0 +1,47 @@ +export PROMPT_COMMAND=__prompt_command + +function __prompt_command() { + local EXIT="$?" + PS1="" + PS1+="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]" + + local red='\[\033[0;31m\]' + local green='\[\033[0;32m\]' + local light_green='\[\033[01;32m\]' + local light_blue='\[\033[01;34m\]' + local reset='\[\033[0m\]' + + PS1+="ā•­ " + + if [ $EXIT = 0 ]; then + PS1+="${green}(āœ”)${reset} " + else + PS1+="${red}(āœ—)${reset} " + fi + + PS1+="${debian_chroot:+($debian_chroot)}${light_green}\u@\h${reset}:${light_blue}\W${reset}" + + ### Add Git Status ### + ## Inspired by http://www.terminally-incoherent.com/blog/2013/01/14/whats-in-your-bash-prompt/ + if [[ $(command -v git) ]]; then + local git_status="$(git status --porcelain -b 2>/dev/null | tr '\n' ':')" + + if [ "$git_status" ]; then + local git_color="${reset}" + ### Test For Changes ### + ## Change this to test for 'ahead' or 'behind'! + local git_changed="$(echo ${git_status} | tr ':' '\n' | grep -v "^$" | grep -v "^\#\#" | wc -l | tr -d ' ')" + if [ "$git_changed" == "0" ]; then + git_color="${green}" + else + git_color="${red}" + fi + + ### Find Branch ### + local git_branch="$(echo ${git_status} | tr ':' '\n' | grep "^##" | cut -c4-)" + PS1+=" ${git_color}[${git_branch}]${reset}" + fi + fi + + PS1+="\nā•°\$ ${RCol}" +} diff --git a/home/.bashrc.d/spark.sh b/home/.bashrc.d/spark.sh new file mode 100644 index 0000000..30b8225 --- /dev/null +++ b/home/.bashrc.d/spark.sh @@ -0,0 +1,2 @@ +# Spark: don't run scalastyle on every compile +export NOLINT_ON_COMPILE=true -- cgit v1.2.3