# If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac __SCRIPT=$BASH_SOURCE RBASH_HOME="$HOME/.rbash" RBASH_SOURCES="$RBASH_HOME/sources" # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Source for Custom bash ENV if [ -f ~/.rbashenv ]; then . ~/.rbashenv fi mkdir -p "$RBASH_SOURCES" # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize # If set, the pattern "**" used in a pathname expansion context will # match all files and zero or more directories and subdirectories. #shopt -s globstar # make less more friendly for non-text input files, see lesspipe(1) #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # set variable identifying the chroot you work in (used in the prompt below) if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color) color_prompt=yes;; esac # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi which gpg-agent 2>&1 > /dev/null if [ $? -eq 0 ]; then GPG_ENV="$HOME/.gnupg/environment" function __start_agent { gpg-agent --daemon > "${GPG_ENV}" chmod 600 "${GPG_ENV}" . "${GPG_ENV}" > /dev/null } if [ -f "${GPG_ENV}" ]; then . "${GPG_ENV}" > /dev/null gpg-agent > /dev/null 2>&1 [ "$?" -ne 0 ] && { __start_agent; } else __start_agent; fi fi function __download { which curl 2>&1 > /dev/null if [ $? -eq 0 ]; then curl -s "$1" return fi which wget 2>&1 > /dev/null if [ $? -eq 0 ]; then wget -qO- "$1" return fi } function rbash_cache { local CACHE_FILE MLINK=$( echo "$1" | md5sum | cut -d' ' -f1 ) CACHE_FILE="$RBASH_SOURCES/$MLINK" if [ ! -f "$CACHE_FILE" ]; then __download "$1" > "$CACHE_FILE" fi chmod 700 "$CACHE_FILE" echo -n "$CACHE_FILE" } function rbash_upgrade { echo "Updating $__SCRIPT" local TMPFILE TMPFILE=$( mktemp ) __download "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/bash/bashrc/rbashrc" > $TMPFILE if [ -z "$1" ]; then MC_NAME="" MCC_NAME="" else MC_NAME=$1 MCC_NAME=$2 fi PMC_NAME=$( echo "#_MACHINE_NAME_#" | sed -e "s/#_//g" ) PMCC_NAME=$( echo "#_MACHINE_COLORED_NAME_#" | sed -e "s/#_//g" ) COLOR_CODE_TOK=$( echo "#_COLOR_CODE_#" | sed -e "s/#_//g" ) COLOR_CODE=$(( $RANDOM * 6 / 32767 + 1 )) sed -i \ -e "s/$PMC_NAME/$MC_NAME/g" \ -e "s/$PMCC_NAME/$MCC_NAME/g" \ -e "s/$COLOR_CODE_TOK/$COLOR_CODE/g" \ $TMPFILE mv $TMPFILE $__SCRIPT # Clean up the old dir if [ $? -eq 0 ] && [ -d "$RBASH_SOURCES" ]; then rm -r "$RBASH_SOURCES" fi source $__SCRIPT } function rbash_run { local f echo "Getting: $1" f=`rbash_cache "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/$1"` shift "$f" "$@" } export PS1='This is \e[1;3m\e[0m: \w\n\$ ' export EDITOR=vim # User specific aliases and functions function rbash_load { local f path echo " $1" path="sources/$1" f=`rbash_cache "https://git.k8s.astropenguin.net/penguin/utils/raw/branch/master/bash/bashrc/$path"` source "$f" } # Create default source config if [ ! -f "$RBASH_HOME/source.conf" ]; then cat <<___DEFAULT___ > "$RBASH_HOME/source.conf" echo "Source:" rbash_load "package.sh" 1 rbash_load "10_aliases" rbash_load "12_shortcuts" rbash_load "20_fast-greps" rbash_load "40_go-command" rbash_load "41_pivot-command" ___DEFAULT___ chmod 600 "$RBASH_HOME/source.conf" fi source "$RBASH_HOME/source.conf"