Skip to content

Instantly share code, notes, and snippets.

@BlazOrazem
Last active May 8, 2016 09:44
Show Gist options
  • Save BlazOrazem/a599898da601184dcd5b1cc55dd36ce3 to your computer and use it in GitHub Desktop.
Save BlazOrazem/a599898da601184dcd5b1cc55dd36ce3 to your computer and use it in GitHub Desktop.
BashRC for Git use
# SSH Environment
# SSH_ENV=$HOME/.ssh/environment
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Don't put duplicate lines in the history. See bash(1) for more options
# export HISTCONTROL=ignoredups
# Check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# The prompt information
export PS1="\[\e[00;33m\]\u\[\e[0m\]\[\e[00;37m\]@\h:\[\e[0m\]\[\e[00;36m\][\[\e[0m\]\[\e[00;33m\]\w\[\e[0m\]\[\e[00;36m\]]\[\e[0m\]\[\e[00;37m\]\$(parse_git_branch): \[\e[0m\]"
# Leave some commands out of history log
export HISTIGNORE="&:??:[ ]*:clear:exit:logout"
# Default editor
export EDITOR=vi
# Define color to additional file types
export LS_COLORS=$LS_COLORS:"*.wmv=01;35":"*.wma=01;35":"*.flv=01;35":"*.m4a=01;35"
# Alias definitions
# Enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
fi
# User-defined aliases
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 [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Start the SSH-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
# GIT repository - parse branch name
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment