2017-08-18 20:46:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#===============================================================================
|
|
|
|
# bash config for niblock :: source ~/.bashrc
|
|
|
|
#===============================================================================
|
2015-09-07 02:04:45 +00:00
|
|
|
# Source global definitions
|
|
|
|
if [ -f /etc/bashrc ]; then
|
2017-07-05 18:43:45 +00:00
|
|
|
. /etc/bashrc
|
2015-09-07 02:04:45 +00:00
|
|
|
fi
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
2017-07-05 18:43:45 +00:00
|
|
|
# Prompt
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
|
|
|
if [[ ${EUID} == 0 ]] ; then
|
|
|
|
export PS1="\t \u@\h:\w \$"
|
|
|
|
else
|
|
|
|
mp_time="\[\$(tput setaf 6)\][ \t ]"
|
|
|
|
mp_who="\[\$(tput setaf 2)\]\u\[\$(tput setaf 7)\]@\\[\$(tput setaf 2)\]\h"
|
|
|
|
mp_whr="\[\$(tput setaf 7)\]:\[\$(tput setaf 5)\]\w"
|
|
|
|
mp_git="\[\$(tput sgr0)\]\[\$(show_git_info)\] "
|
2017-09-06 17:10:58 +00:00
|
|
|
export PS1="$mp_time $mp_who$mp_whr$mp_git\n\$ "
|
2017-08-18 20:46:13 +00:00
|
|
|
fi
|
|
|
|
#===============================================================================
|
2015-09-07 02:04:45 +00:00
|
|
|
# Aliases
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
2017-07-05 18:43:45 +00:00
|
|
|
alias tssh="source ~/.ssh/auth_ssh; ssh -A"
|
|
|
|
complete -F _ssh tssh
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
2015-09-07 02:04:45 +00:00
|
|
|
# Functions
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
2015-09-07 02:04:45 +00:00
|
|
|
#If redshift wasn't automatically started, this will do it
|
|
|
|
function tint(){
|
2017-07-05 18:43:45 +00:00
|
|
|
redshift -l 42.8864500:-78.8783700 -t 5000:4000 &
|
2015-09-07 02:04:45 +00:00
|
|
|
}
|
2017-07-05 18:43:45 +00:00
|
|
|
# Function for keeping ssh-agent happy
|
|
|
|
function yssh(){
|
|
|
|
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > ~/.ssh/auth_ssh
|
2015-09-07 02:04:45 +00:00
|
|
|
}
|
2017-08-18 20:46:13 +00:00
|
|
|
# Determine git branch and index status
|
|
|
|
function show_git_info(){
|
|
|
|
local results=""
|
|
|
|
type git >/dev/null 2>&1
|
|
|
|
if [[ $? == 0 ]] ; then
|
2017-08-29 16:43:31 +00:00
|
|
|
local bn=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n')
|
2017-08-18 20:46:13 +00:00
|
|
|
if [[ -n "$bn" ]] ; then
|
|
|
|
git diff-index --quiet HEAD --
|
|
|
|
if [[ $? == 0 ]] ; then
|
2017-09-06 17:10:58 +00:00
|
|
|
results="#$(tput setaf 2)$bn$(tput sgr0)"
|
2017-08-18 20:46:13 +00:00
|
|
|
else
|
2017-09-06 17:10:58 +00:00
|
|
|
results="#$(tput setaf 1)$bn$(tput sgr0)"
|
2017-08-18 20:46:13 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $results
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#===============================================================================
|
2017-07-05 18:43:45 +00:00
|
|
|
# Path
|
2017-08-18 20:46:13 +00:00
|
|
|
#===============================================================================
|
2017-07-05 18:43:45 +00:00
|
|
|
# Ruby Gems
|
|
|
|
if which ruby >/dev/null && which gem >/dev/null; then
|
|
|
|
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
|
|
|
|
fi
|
|
|
|
# RVM
|
|
|
|
PATH="$HOME/.rvm/bin:$PATH"
|
2017-08-18 20:46:13 +00:00
|
|
|
# Add Python to path
|
|
|
|
PYTHONPATH="${PYTHONPATH}"
|
|
|
|
#===============================================================================
|
|
|
|
# Defaults
|
|
|
|
#===============================================================================
|
|
|
|
# Set editor, if Vim is available
|
|
|
|
type vim >/dev/null 2>&1
|
|
|
|
if [[ $? == 0 ]]; then
|
|
|
|
export EDITOR=vim
|
|
|
|
fi
|
|
|
|
# History size and time-format
|
|
|
|
export HISTSIZE=10000
|
|
|
|
export HISTTIMEFORMAT="%s "
|
|
|
|
# Paths
|
2017-07-05 18:43:45 +00:00
|
|
|
export PYTHONPATH
|
|
|
|
export PATH
|
2017-08-18 20:46:13 +00:00
|
|
|
# Yubikey support
|
2017-07-05 18:43:45 +00:00
|
|
|
export SSH_AUTH_SOCK=$HOME/.yubiagent/sock
|