Bashrc

From digital-bit.ch's wiki
Jump to: navigation, search
# /home/t4c/.bashrc
# t4c's bashrc nothin spectacular
# last change: 07/03/2012

export LC_ALL="en_US.utf8"
export LANG="en_US.utf8"
export GREP_COLOR=36
export HISTSIZE=1000
export HISTFILESIZE=1000
export HISTCONTROL=ignoredups


############### 
# bash tuning #
###############

# no more overwriting existing files with <> > >&
# complete && cdspell
# bash save all lines of a multiple-line cmd to same hist
set -C noclobber
complete -d cd
shopt -s cdspell cmdhist dotglob
#shopt -s extglob

### history for multiple shells ###
shopt -s histappend
PROMPT_COMMAND='history -a'
 
########################
# setting some aliases #
########################

alias d='ls --color'
alias dsc='sudo dispatch-conf'
alias eixsync='sudo eix-sync'
alias emerge='sudo emerge'
alias euse='sudo euse'
# grep faster with color on UTF8 Systems
alias grep='LC_ALL=posix grep --color=auto'
alias halt='sudo halt'
alias ll='tree --dirsfirst -L 1 -i'
alias ls='ls -X --color=auto'
alias reboot='sudo reboot'
alias sx='startx'
alias wu='emerge -auvDN world'
alias wusa='eixsync; emerge -auvDN world'
alias ':wq'='exit'


#######################
# some more functions #
#######################

function calc()   { awk "BEGIN { print $* ; }"; }
function calcfx() { gawk -v CONVFMT="%12.2f" -v OFMT="%.9g"  "BEGIN { print $* ; }"; }
function p	{ ${PAGER} $@; }
function dmsg	{ dmesg | p; }
function use	{ euse -E $@; }
function unuse	{ euse -D $@; }
function unmask	{ sudo sh -c "echo $@>>/etc/portage/package.keywords"; }
function ipmi { sudo ipmitool -I lanplus -H $1 shell; }

function googlespeak() {
	if [ "$2" = "" ]; then
	   2="en"
	fi
	wget --user-agent="" -O - "http://translate.google.com/translate_tts?tl=$2&q=$1" > /tmp/google_translate.mp3
	mplayer /tmp/google_translate.mp3
	rm /tmp/google_translate.mp3

function ncput	{ 
	if [ $# -lt 2 ]; then
		echo "usage: ncput files ip"
		return 0
	fi
	tar -cv $1 | nc $2 1337; 
 }
 
function ncget	{ 
	if [ $# -lt 1 ]; then
		echo "usage: ncget destination"
		return 0
	fi
	nc -l -p 1337 | tar -C $@ -xv; 
}

extract() {
if [ -f $1 ] ; then
    case $1 in
        *.tar.bz2)   tar xvjf $1    ;;
        *.tar.gz)    tar xvzf $1    ;;
        *.bz2)       bunzip2 $1     ;;
        *.rar)       rar e $1       ;;
        *.gz)        gunzip $1      ;;
        *.tar)       tar xvf $1     ;;
        *.tbz2)      tar xvjf $1    ;;
        *.tgz)       tar xvzf $1    ;;
        *.zip)       unzip $1       ;;
        *.Z)         uncompress $1  ;;
        *.7z)        7z x $1        ;;
        *)           echo "don't know how to extract '$1'..." ;;
    esac
else
    echo "'$1' is not a valid file!"
fi
}

pwgen() {
        local l=$1
        [ "$l" == "" ] && l=20
        tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

function hilight {
	if [ $# -lt 1 ]; then
		echo "usage: hilight inputfile"
		return 0
	fi
	highlight -O ansi -i $@
}

#############
# std stuff #
#############

if  $- != *i*  ; then 
	return
fi

if  -f ~/.dir_colors ; then
	eval `dircolors -b ~/.dir_colors`
else
	eval `dircolors -b /etc/DIR_COLORS`
fi

# Change the window title of X terminals 
case ${TERM} in
	xterm*|rxvt|Eterm|aterm|rxvt-unicode)
		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
		export PS1='\[\033[01;36m\]\u@\h \[\033[01;34m\]\w \$ \[\033[00m\]'
		;;
	screen)
		PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
		export PS1='\[\033[01;34m\]\u@\h \[\033[01;36m\]\w \$ \[\033[00m\]'
		;;
esac

# Midnight Commander chdir enhancement
if [ -f /usr/share/mc/mc.gentoo ]; then 
	. /usr/share/mc/mc.gentoo
fi

### bash-completion ###
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion

# adding some lame ms-dos prompt
PS1='C:${PWD//\//\\\}>'

# adding some pathes for my android devel/fun
PATH="$PATH:~/bin/:~/mydroid/out/host/linux-x86/bin"

#EOF

powered by

    ip-exchange.de

Personal tools