Added remote bashrc script

This commit is contained in:
斟酌 鵬兄 2015-03-04 12:43:33 +08:00
parent 055a7ef6a9
commit de997c2a60

106
bash/bashrc/rbashrc Normal file
View File

@ -0,0 +1,106 @@
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh 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
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
function update_bashrc {
echo "Updating the .bashrc"
TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid )
curl -s "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/rbashrc;hb=HEAD" > $TMPFILE
if [ -z "$1" ]; then
MC_NAME="<MACHINE_NAME>"
MCC_NAME="<MACHINE_COLORED_NAME>"
else
MC_NAME=$1
MCC_NAME=$2
fi
PMC_NAME=$( echo "#_MACHINE_NAME_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
PMCC_NAME=$( echo "#_MACHINE_COLORED_NAME_#" | sed -e "s/#_/</g" -e "s/_#/>/g" )
sed -i -e "s/$PMC_NAME/$MC_NAME/g" -e "s/$PMCC_NAME/$MCC_NAME/g" $TMPFILE
mv $TMPFILE ~/.bashrc
. ~/.bashrc
}
export PS1='This is <MACHINE_NAME>\e[1;31m<MACHINE_COLORED_NAME>\e[0m: \w\n$ '
export EDITOR=vim
# User specific aliases and functions
echo "Source:"
function __ns {
echo " $1"
TMPFILE=/tmp/$( cat /proc/sys/kernel/random/uuid )
curl -s "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/sources/$1;hb=HEAD" > $TMPFILE
. $TMPFILE
rm $TMPFILE
}
__ns "10_aliases"
__ns "20_fast-greps"
__ns "30_mysql"
__ns "40_go-command"
__ns "41_pivot-command"
# Source for additional rc
if [ -f ~/.bashrc_local ]; then
. ~/.bashrc_local
fi