Created
June 26, 2018 08:24
-
-
Save srkiNZ84/b48dd244fb77b885b4a74ace4e59b7bb to your computer and use it in GitHub Desktop.
My .bashrc file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
export BASH_CONF="bashrc" | |
# Some useful colours | |
hash _c_define > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
. _c_define | |
elif [[ -f "$HOME/bin/_c_define" ]]; then | |
source "$HOME/bin/_c_define" | |
fi | |
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# 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)" | |
# 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 | |
# Alias definitions. | |
if [ -f ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
# enable color support of ls and also add handy aliases | |
if [ "$TERM" != "dumb" ]; then | |
hash dircolors > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
eval "`dircolors -b`" | |
fi | |
ls --color=auto > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
alias ls='ls --color=auto' | |
else | |
alias ls='ls -G' | |
fi | |
fi | |
complete -o default -o nospace -F _git g | |
hash ack-grep > /dev/null 2>&1 | |
ack=$? | |
hash ack > /dev/null 2>&1 | |
if [[ $? -ne 0 && $ack -eq 0 ]]; then | |
alias ack='ack-grep' | |
fi | |
hash vimpager > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
alias vp='vimpager' | |
# Use vim for the pager | |
export PAGER=`type -p vimpager` | |
export GIT_PAGER=less | |
alias less=$PAGER | |
alias zless=$PAGER | |
fi | |
# general environment | |
export CFLAGS='-O0 -g' | |
if [[ -d "/usr/lib/jvm/java-6-sun" ]]; then | |
export JAVA_HOME="/usr/lib/jvm/java-6-sun" | |
fi | |
if [[ -d "$HOME/bin" ]]; then | |
export PATH="$HOME/bin:${PATH}" | |
fi | |
# other path locations | |
if [[ -d "/usr/local/sbin" ]]; then | |
export PATH="/usr/local/sbin:${PATH}" | |
fi | |
if [[ -d "/usr/local/bin" ]]; then | |
export PATH="/usr/local/bin:${PATH}" | |
fi | |
if [[ -d "/usr/local/percona/bin" ]]; then | |
export PATH="${PATH}:/usr/local/percona/bin" | |
fi | |
if [[ -d "/usr/local/heroku/bin" ]]; then | |
export PATH="${PATH}:/usr/local/heroku/bin" | |
fi | |
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then | |
export rvmsudo_secure_path=0 | |
source "$HOME/.rvm/scripts/rvm" | |
fi | |
# chruby | |
if [[ -f /usr/local/share/chruby/chruby.sh ]]; then | |
source /usr/local/share/chruby/chruby.sh | |
chruby ruby-2.1 | |
fi | |
# android development | |
if [[ -d "/usr/local/share/android/tools" ]]; then | |
export PATH="${PATH}:/usr/local/share/android/tools" | |
fi | |
if [[ -d "/usr/local/share/android/platform-tools" ]]; then | |
export PATH="${PATH}:/usr/local/share/android/platform-tools" | |
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 | |
# and for Homebrew | |
hash brew > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
fi | |
# Autojump configuration | |
hash brew > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
if [ -f `brew --prefix`/etc/autojump ]; then | |
. `brew --prefix`/etc/autojump | |
fi | |
fi | |
# NVM | |
[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh" | |
hash brew > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
if [ -f `brew --prefix nvm`/nvm.sh ]; then | |
export NVM_DIR=~/.nvm | |
. `brew --prefix nvm`/nvm.sh | |
fi | |
fi | |
# general compiler optimisations | |
export MAKEOPTS="-j3" | |
# history | |
export HISTSIZE=10000 | |
export HISTFILESIZE=10000 | |
export HISTCONTROL=ignoreboth | |
if [ ! -f $HOME/.bash_history_eternal ]; then | |
touch $HOME/.bash_history_eternal | |
fi | |
export HISTTIMEFORMAT="%s " | |
#PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND;}"'echo $$ $USER \ | |
"$(history 1)" >> ~/.bash_history_eternal' | |
chmod go-rwx ~/.bash_history_eternal | |
# cgroup - TTY based task grouping | |
if [[ -d $HOME/.cgroups ]]; then | |
if [ "$PS1" ] ; then | |
mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1 | |
echo $$ > /dev/cgroup/cpu/user/$$/tasks | |
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release | |
fi | |
fi | |
# Make sure an SVN editor is set up (only required for MacOS) | |
export SVN_EDITOR="vim" | |
export EDITOR="vim" | |
# Fancy git branch in PS1 | |
hash __git_ps1 > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
gitps1="\$(__git_ps1 \"\[$c_normal\]:\[$c_cyan\]%s\[$c_normal\]\")" | |
else | |
gitps1="" | |
fi | |
hash whoami > /dev/null 2>&1 | |
if [[ `whoami` == "root" ]]; then | |
user_color='\['$c_magenta'\]' | |
elif [[ $c_defined != 0 ]]; then | |
user_color="" | |
else | |
user_color='\['$c_yellow'\]' | |
fi | |
case "$TERM_PROGRAM" in | |
iTerm.app) | |
PS1='${debian_chroot:+($debian_chroot)}'$user_color'\u\[\e[0;1m\]@\[\e[32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'$gitps1'\$ ' | |
;; | |
*) | |
PS1='${debian_chroot:+($debian_chroot)}'$user_color'\u\[\e[0;1m\]@\[\e[32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'$gitps1'\$ ' | |
;; | |
esac | |
# Show git status | |
if [ -f "/proc/cpuinfo" ]; then | |
cores=$(grep -c ^processor /proc/cpuinfo 2> /dev/null) | |
[ "$cores" -eq "0" ] && cores=1 | |
threshold="${cores:-1}.0" | |
threshold="1.0" | |
else | |
threshold="1.0" | |
fi | |
load=$(uptime | sed -E 's/^.*: ([0-9]\.[0-9]{2}),?.*$/\1/g') | |
over=$(echo "$load < $threshold" | bc) | |
if [[ "$over" -eq 1 && -d .git ]]; then | |
git st | |
else | |
uptime | |
fi | |
# custom config for dev vm | |
if [[ -f ~/.bash_custom ]]; then | |
. ~/.bash_custom | |
fi | |
PATH="/Users/srdan/perl5/bin${PATH+:}${PATH}"; export PATH; | |
PERL5LIB="/Users/srdan/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB; | |
PERL_LOCAL_LIB_ROOT="/Users/srdan/perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT; | |
PERL_MB_OPT="--install_base \"/Users/srdan/perl5\""; export PERL_MB_OPT; | |
PERL_MM_OPT="INSTALL_BASE=/Users/srdan/perl5"; export PERL_MM_OPT; | |
# tabtab source for serverless package | |
# uninstall by removing these lines or running `tabtab uninstall serverless` | |
[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash ] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash | |
# tabtab source for sls package | |
# uninstall by removing these lines or running `tabtab uninstall sls` | |
[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash ] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment