#!/bin/bash #=============================================================================== # bash config for niblock :: source ~/.bashrc #=============================================================================== # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi #=============================================================================== # Path #=============================================================================== # Custom stuff PATH="$HOME/bin:$PATH" # Add Python to path PYTHONPATH="${PYTHONPATH}" export PYTHONPATH PATH="$PATH:/opt/python/bin" # Add Rust cargo bin PATH="$PATH:$HOME/.cargo/bin" # RVM. Make sure this is the last PATH variable change. PATH="$PATH:$HOME/.rvm/bin" # Set it. export PATH #=============================================================================== # Defaults #=============================================================================== # Disable CTRL+S flow control stty -ixon # 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 " #=============================================================================== # Prompt #=============================================================================== 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)\] " export PS1="$mp_time $mp_who$mp_whr$mp_git\n\$ " fi #=============================================================================== # Aliases #=============================================================================== #=============================================================================== # Functions #=============================================================================== # Determine git branch and index status function show_git_info(){ local results="" type git >/dev/null 2>&1 if [[ $? == 0 ]] ; then local bn=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n') if [[ -n "$bn" ]] ; then git diff-index --quiet HEAD -- if [[ $? == 0 ]] ; then results="#$(tput setaf 2)$bn$(tput sgr0)" else results="#$(tput setaf 1)$bn$(tput sgr0)" fi fi echo $results fi } # Start tmux session: Sojourner function sojourner_tmux(){ type tmux >/dev/null 2>&1 if [[ $? == 0 ]]; then tmux has-session -t Sojourner &>/dev/null # If there is no session named Sojourner if [ $? != 0 ] ; then # Create a new session named Sojourner tmux new-session -s Sojourner -d fi # Get our SSH socket documented echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > ~/.ssh/auth_ssh # Attack to the Sojourner session tmux attach -t Sojourner else echo "Tmux not installed." fi }