2014-02-28 23:42:51 +00:00
|
|
|
# .bashrc
|
|
|
|
|
|
|
|
# Kirsle's Global BashRC
|
2015-05-08 04:22:13 +00:00
|
|
|
# Updated 2015-05-07
|
2014-02-28 23:42:51 +00:00
|
|
|
|
|
|
|
# Source global definitions
|
|
|
|
if [ -f /etc/bashrc ]; then
|
|
|
|
. /etc/bashrc
|
|
|
|
fi
|
|
|
|
|
2015-05-08 04:22:13 +00:00
|
|
|
platform="unknown"
|
|
|
|
unamestr=`uname`
|
|
|
|
if [[ "$unamestr" == "Linux" ]]; then
|
|
|
|
platform="linux"
|
|
|
|
elif [[ "$unamestr" == "Darwin" ]]; then
|
|
|
|
platform="darwin"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# PATH settings.
|
2017-01-11 18:40:10 +00:00
|
|
|
export PATH="/usr/sbin:/sbin:/usr/bin:/bin:$HOME/bin:$HOME/go/bin:$HOME/go/.ext/bin"
|
2015-05-08 04:22:13 +00:00
|
|
|
if [[ $platform == "darwin" ]]; then
|
|
|
|
# Prefer /usr/local/bin because homebrew
|
|
|
|
export PATH="/usr/local/bin:$PATH"
|
2016-01-13 19:59:14 +00:00
|
|
|
|
|
|
|
# Enable colors and set a similar color scheme as Linux (see `man ls`)
|
|
|
|
export CLICOLOR=1
|
|
|
|
export LSCOLORS="ExGxcxdxcxegedabagecec"
|
2015-05-08 04:22:13 +00:00
|
|
|
else
|
|
|
|
export PATH="$PATH:/usr/local/bin:/usr/local/sbin"
|
|
|
|
fi
|
|
|
|
|
2014-02-28 23:42:51 +00:00
|
|
|
# Perlbrew
|
|
|
|
export PERLBREW_ROOT="/opt/perl5"
|
|
|
|
if [ -f /opt/perl5/etc/bashrc ]; then
|
|
|
|
source /opt/perl5/etc/bashrc
|
|
|
|
fi
|
|
|
|
|
2017-06-08 17:20:36 +00:00
|
|
|
# Virtualenv settings. Prefer Python 3 for new environments.
|
2015-07-28 19:07:51 +00:00
|
|
|
export WORKON_HOME=~/.virtualenvs
|
2017-06-08 17:20:36 +00:00
|
|
|
command -v python3 >/dev/null 2>&1 && export VIRTUALENV_PYTHON=`command -v python3`
|
2014-02-28 23:42:51 +00:00
|
|
|
if [ -f /usr/bin/virtualenvwrapper.sh ]; then
|
|
|
|
source /usr/bin/virtualenvwrapper.sh
|
2017-04-19 22:26:53 +00:00
|
|
|
elif [ -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]; then
|
|
|
|
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
|
2014-02-28 23:42:51 +00:00
|
|
|
fi
|
|
|
|
|
2017-01-11 18:40:10 +00:00
|
|
|
# Go
|
|
|
|
export GOPATH="$HOME/go/.ext:$HOME/go"
|
|
|
|
|
2014-02-28 23:42:51 +00:00
|
|
|
# Colors!
|
|
|
|
BLACK='\e[0;30m'
|
|
|
|
NAVY='\e[0;34m'
|
|
|
|
GREEN='\e[0;32m'
|
|
|
|
TEAL='\e[0;36m'
|
|
|
|
MAROON='\e[0;31m'
|
|
|
|
PURPLE='\e[0;35m'
|
|
|
|
BROWN='\e[0;33m'
|
|
|
|
SILVER='\e[0;37m'
|
|
|
|
GRAY='\e[1;30m'
|
|
|
|
BLUE='\e[1;34m'
|
|
|
|
LIME='\e[1;32m'
|
|
|
|
CYAN='\e[1;36m'
|
|
|
|
RED='\e[1;31m'
|
|
|
|
MAGENTA='\e[1;35m'
|
|
|
|
YELLOW='\e[1;33m'
|
|
|
|
WHITE='\e[1;37m'
|
|
|
|
BOLD='\e[1m'
|
|
|
|
NC='\e[0m' # No Color
|
|
|
|
|
2015-07-18 23:57:52 +00:00
|
|
|
# Some 256-colors colors
|
|
|
|
LBLUE="\e[38;5;39m"
|
|
|
|
PINK="\e[38;5;213m"
|
|
|
|
|
2014-02-28 23:42:51 +00:00
|
|
|
function showcolors() {
|
|
|
|
echo -e "$BLACK BLACK $NAVY NAVY $GREEN GREEN $TEAL TEAL"
|
|
|
|
echo -e "$MAROON MAROON $PURPLE PURPLE $BROWN BROWN $SILVER SILVER"
|
|
|
|
echo -e "$GRAY GRAY $BLUE BLUE $LIME LIME $CYAN CYAN $RED RED"
|
|
|
|
echo -e "$MAGENTA MAGENTA $YELLOW YELLOW $WHITE WHITE$NC"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Normalize the terminal.
|
|
|
|
ENLIGHTENED=0
|
|
|
|
if [ "$TERM" = 'xterm' ] || [ "$TERM" = 'xterm-256color' ] || [ "$TERM" = 'linux' ]; then
|
|
|
|
ENLIGHTENED=1
|
|
|
|
elif [ "$TERM" = 'screen' ] || [ "$TERM" = 'screen-256color' ]; then
|
|
|
|
ENLIGHTENED=1
|
|
|
|
elif [ "$TERM" = 'cygwin' ]; then
|
|
|
|
ENLIGHTENED=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Custom bash prompt.
|
2015-06-03 21:33:56 +00:00
|
|
|
git_branch() {
|
|
|
|
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' | perl -pe 's/^\*\s+//g'`
|
|
|
|
if [ "$branch" != '' ]; then
|
|
|
|
echo -n " ($branch)"
|
2014-02-28 23:42:51 +00:00
|
|
|
fi
|
2015-06-03 21:33:56 +00:00
|
|
|
}
|
|
|
|
if [ "$ENLIGHTENED" = '1' ]; then
|
2015-07-18 23:57:52 +00:00
|
|
|
export PS1="\[$BOLD$LBLUE\][\[$PINK\]\u\[$LBLUE\]@\[$PINK\]\h \[$LIME\]\W\[$CYAN\]\$(git_branch)\[$LBLUE\]\[$LBLUE\]]\\$ \[$NC\]"
|
2014-02-28 23:42:51 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# For non-Fedora environments be sure the PROMPT_COMMAND sets the title bar.
|
|
|
|
export PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
|
|
|
|
|
|
|
|
# ___ ____ _ _ ____ ____ __ __
|
|
|
|
# / __)( ___)( \( )( ___)( _ \ /__\ ( )
|
|
|
|
# ( (_-. )__) ) ( )__) ) / /(__)\ )(__
|
|
|
|
# \___/(____)(_)\_)(____)(_)\_)(__)(__)(____)
|
|
|
|
# -==General Bash Aliases and Functions==-
|
|
|
|
|
|
|
|
alias vi='vim'
|
|
|
|
|
|
|
|
# reload .bashrc
|
|
|
|
alias rebash='. ~/.bashrc'
|
|
|
|
|
|
|
|
# a DOS-like title command
|
|
|
|
function title {
|
|
|
|
PROMPT_COMMAND="echo -en \"\033]0;$1\007\""
|
|
|
|
}
|
|
|
|
|
2014-10-08 19:01:51 +00:00
|
|
|
# Custom git command that overrides $PATH settings
|
|
|
|
function git {
|
|
|
|
if [ -x "/usr/local/bin/git" ]; then
|
|
|
|
/usr/local/bin/git $@
|
2016-02-26 23:04:29 +00:00
|
|
|
elif [ -x "/opt/git/bin/git" ]; then
|
|
|
|
/opt/git/bin/git $@
|
2014-10-08 19:01:51 +00:00
|
|
|
elif [ -x "/usr/bin/git" ]; then
|
|
|
|
/usr/bin/git $@
|
|
|
|
else
|
|
|
|
echo "git isn't installed"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-02-28 23:42:51 +00:00
|
|
|
# Case-insensitive searching.
|
|
|
|
shopt -s nocaseglob
|
|
|
|
|
|
|
|
# Save history correctly when using multiple terminals.
|
|
|
|
# Don't save duplicate lines or blank lines.
|
|
|
|
export HISTCONTROL="ignoreboth"
|
|
|
|
export HISTSIZE=1000
|
|
|
|
shopt -s histappend
|
|
|
|
|
|
|
|
export EDITOR="/usr/bin/vim"
|
|
|
|
|
|
|
|
# Color grepping! Highlight grep expression in red text.
|
|
|
|
export GREP_COLOR=31
|
|
|
|
alias grep='grep --exclude=min.js --color=auto'
|
|
|
|
|
|
|
|
# Show proc name with pgrepping.
|
|
|
|
alias pg='ps aux | grep'
|
|
|
|
alias pgrep='pgrep -l'
|
|
|
|
|
|
|
|
# Allow ASCII color codes to work in less/more.
|
|
|
|
alias less='less -r'
|
|
|
|
alias more='less -r' # less is more
|
|
|
|
|
2015-05-08 04:22:13 +00:00
|
|
|
# ls aliases (Fedora defaults but here for portability)
|
|
|
|
if [[ $platform == "darwin" ]]; then
|
|
|
|
alias ll='ls -hl'
|
|
|
|
else
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
alias ll='ls --color=auto -hl'
|
|
|
|
fi
|
2014-02-28 23:42:51 +00:00
|
|
|
|
|
|
|
# More aliases!
|
|
|
|
alias ping='ping -c 10'
|
|
|
|
|
|
|
|
# Shortcuts to graphical programs.
|
|
|
|
alias firefox='nohup firefox 2>/dev/null'
|
|
|
|
alias gedit='nohup gedit 2>/dev/null'
|
|
|
|
|
|
|
|
# Lazy cd commands.
|
|
|
|
alias ...='cd ../..'
|
|
|
|
alias ..='cd ..'
|
|
|
|
alias ~='cd ~'
|
|
|
|
alias cd..='cd ..'
|
|
|
|
alias cd...='cd ../..'
|
|
|
|
|
|
|
|
# Lazy id commands
|
|
|
|
alias me='whoami'
|
|
|
|
alias i='whoami'
|
|
|
|
|
|
|
|
# Typos
|
|
|
|
alias iv='vi'
|
|
|
|
|
|
|
|
# Make cp and mv ask before replacing an existing file.
|
|
|
|
alias cp='cp -i'
|
|
|
|
alias mv='mv -i'
|
|
|
|
|
|
|
|
# 256 Color Terminal! Make sure a .xterm256 file exists in $HOME to enable.
|
|
|
|
if [ -e ".xterm256" ]; then
|
|
|
|
[ "$TERM" = 'xterm' ] && TERM=xterm-256color
|
|
|
|
[ "$TERM" = 'screen' ] && TERM=screen-256color
|
|
|
|
[ "$TERM" = 'rxvt-unicode' ] && TERM=rxvt-unicode-256color
|
|
|
|
|
|
|
|
if [ ! -z "$TERMCAP" ] && [ "$TERM" = "screen-256color" ]; then
|
|
|
|
TERMCAP=$(echo $TERMCAP | sed -e 's/Co#8/Co#256/g')
|
|
|
|
export TERMCAP
|
|
|
|
fi
|
|
|
|
fi
|
2016-01-12 22:21:04 +00:00
|
|
|
|
|
|
|
# Source local system-specific config.
|
|
|
|
if [ -f ~/.localbashrc ]; then
|
|
|
|
. ~/.localbashrc
|
|
|
|
fi
|
2016-06-16 18:24:19 +00:00
|
|
|
|
|
|
|
###
|
|
|
|
# Import common functions (bash/zsh)
|
|
|
|
###
|
|
|
|
|
|
|
|
. ~/.common.sh
|