commit 2898289fe06eba0f2986e51edb3561538b439331 Author: Danny Robson Date: Fri Feb 22 13:13:19 2019 +1100 initial import diff --git a/05-ssh-detect/profile b/05-ssh-detect/profile new file mode 100644 index 0000000..9cd2c03 --- /dev/null +++ b/05-ssh-detect/profile @@ -0,0 +1,9 @@ +if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + SESSION_TYPE=remote/ssh +else + case $(ps -o comm= -p $PPID) in + sshd|*/sshd) SESSION_TYPE=remote/ssh;; + esac +fi + +# vim: set syntax=bash: diff --git a/30-ssh-agent/profile b/30-ssh-agent/profile new file mode 100644 index 0000000..5d58186 --- /dev/null +++ b/30-ssh-agent/profile @@ -0,0 +1,10 @@ +if [ -f ~/.agent.env ] ; then + . ~/.agent.env > /dev/null + if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then + #echo "Stale agent file found. Spawning new agent… " + eval `ssh-agent | tee ~/.agent.env` >/dev/null + fi +else + #echo "Starting ssh-agent" + eval `ssh-agent | tee ~/.agent.env` >/dev/null +fi diff --git a/90-history/profile b/90-history/profile new file mode 100644 index 0000000..42db95f --- /dev/null +++ b/90-history/profile @@ -0,0 +1,5 @@ +export HISTSIZE=-1 +export HISTFILESIZE=-1 +export HISTCONTROL=ignorespace +export HISTIGNORE="$HISTIGNORE:rm *" + diff --git a/91-tick/profile b/91-tick/profile new file mode 100644 index 0000000..467d248 --- /dev/null +++ b/91-tick/profile @@ -0,0 +1,46 @@ +function fg_color +{ + if [ -n "$1" ]; then + echo -n "\\[\\033[01;${1}m\\]" + else + echo -n "\\[\\033[00m\\]" + fi +} + +RED=$(fg_color 31) +GREEN=$(fg_color 32) +YELLOW=$(fg_color 33) +BLUE=$(fg_color 34) +RESET=$(fg_color) + +case "${SESSION_TYPE}" in + remote\/*) PROMPT_COLOUR=${YELLOW};; + *) PROMPT_COLOUR=${GREEN};; +esac + +function prompt_command { + res=$? + + PS1="" + + if [ -n "$VIRTUAL_ENV" ]; then + PS1="($(basename $VIRTUAL_ENV)) " + fi + + PS1="${PS1}$(fg_color 32)${USER:-$(whoami 2>/dev/null)}" + PS1="${PS1}@" + PS1="${PS1}${PROMPT_COLOUR}$(uname -n 2>/dev/null) \$ " + PS1="${PS1}$(fg_color 34)" + + if [ $res == "0" ]; then + PS1="$PS1✓ " + else + PS1="$PS1✗ " + fi + + PS1="$PS1\w \$\[\033[00m\] " + PS1="${PS1}$(fg_color)" +} + + +export PROMPT_COMMAND=prompt_command diff --git a/bash_profile.sh b/bash_profile.sh new file mode 100755 index 0000000..bcd2fa3 --- /dev/null +++ b/bash_profile.sh @@ -0,0 +1,8 @@ +SELF="$(realpath "${BASH_SOURCE[0]}")" +DIR="$(cd "$(dirname "${SELF}")"; pwd -P)" + +source "${DIR}/bashrc.sh" + +for d in $(ls "${DIR}"/*/profile); do + source "${d}" +done diff --git a/bashrc.sh b/bashrc.sh new file mode 100755 index 0000000..34dbd8c --- /dev/null +++ b/bashrc.sh @@ -0,0 +1,18 @@ +# /etc/skel/.bashrc +# +# This file is sourced by all *interactive* bash shells on startup, +# including some apparently interactive shells such as scp and rcp +# that can't tolerate any output. So make sure this doesn't display +# anything or bad things will happen ! + + +# Test for an interactive shell. There is no need to set anything +# past this point for scp and rcp, and it's important to refrain from +# outputting anything in those cases. +if [[ $- != *i* ]] ; then + # Shell is non-interactive. Be done now! + return +fi + + +# Put your fun stuff here. diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..83c1453 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +SELF="$(realpath "${BASH_SOURCE[0]}")" +DIR="$(cd "$(dirname "${SELF}")"; pwd -P)" + +ln -s "${DIR}/bash_profile.sh" ~/.bash_profile +ln -s "${DIR}/bashrc.sh" ~/.bashrc