Created
January 5, 2012 13:49
-
-
Save voyeg3r/1565325 to your computer and use it in GitHub Desktop.
bashrc based on Linux mint bashrc and other stuffs
This file contains 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
# Last Change: 2012 Jan 05 10:48:29 | |
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# http://www.caliban.org/bash/ | |
# Author: Sérgio Luiz Araújo Silva | |
# Site: http://vivaotux.blogspot.com | |
# twitter: http://www.twitter.com/voyeg3r | |
# | |
# ( O O ) | |
# +===========oOO==(_)==OOo==============+ | |
# | | | |
# | °v° Sergio Luiz Araujo Silva | | |
# | /(_)\ Linux User #423493 | | |
# | ^ ^ voyeg3r gmail.com | | |
# +======================================+ | |
# if has ~/bin set to path | |
if [ -d ~/bin ]; then | |
PATH=$PATH:~/bin | |
fi | |
if [ -f .pythonstartup ]; then | |
PYTHONSTARTUP="$HOME/.pythonstartup" | |
export PYTHONSTARTUP | |
fi | |
INPUTRC=~/.inputrc | |
# find default netcard if [eth0, eth1 ...] | |
DEV=`netstat -i | awk '/eth/ {print $1}'` | |
LOCALIP=`ifconfig $DEV 2>/dev/null || /sbin/ifconfig $DEV 2>/dev/null | awk '/inet end/ {print $3}'` | |
myip (){ | |
clear | |
echo | |
DEV=`awk '/eth/ {print $1}' <(netstat -i)` # indentifica o device | |
MEUIP=`hostname -I` | |
#echo " IP LOCAL: .....`awk '/inet end/ {print $3}' <(ifconfig eth0)`" | |
echo " IP LOCAL: .....${MEUIP:-'Not connected'}" | |
echo " NETMASK: ......`awk -F':' '/Mas/ {print $4}' <(/sbin/ifconfig $DEV)`" | |
echo " MAC ADDRESS: ..`awk '/HW/ {print $7}' <(/sbin/ifconfig $DEV)`" | |
echo " ROUTER: .......`awk '/UG/ {print $2}' <(/sbin/route -n)`" | |
echo " IP EXTERNO: ...`curl --connect-timeout 4 -s sputnick-area.net/ip`" | |
echo | |
read -sn 1 -p " Pressione uma tecla para continuar..." | |
clear | |
} | |
# bash completion to sudo command | |
complete -cf sudo | |
complete -d cd mkdir rmdir | |
alias tt='zzdicbabelfish' | |
alias syncode='hg push ssh://[email protected]/sergio/vimfiles' | |
alias ssh="ssh -C" | |
alias scp='scp -r ' | |
alias gril="grep -ril" | |
alias lvim="vim -c \"normal '0\"" | |
alias iso2utf='iconv -f iso-8859-1 -t utf-8' | |
alias utf2iso='iconv -f utf-8 -t iso-8859-1' | |
alias curl='curl --proxy 192.168.1.11:8080' | |
alias path='echo -e ${PATH//:/\\n}' | |
export HISTCONTROL=ignoreboth | |
export HISTIGNORE="&:ls:pwd:[bf]g:exit" | |
export HISTCONTROL=ignoredups | |
export LESS="-P ?c<- .?f%f:Standard input. ?n:?eEND:?p%pj\%.. .?c%ccol . ?mFile %i of %m .?xNext\ %x.%t Press h for help" | |
export EDITOR=vim | |
export VISUAL=vim | |
export MOZ_DISABLE_PANGO=1 | |
export FLASH_GTK_LIBRARY=libgtk-x11-2.0.so.0 | |
export PROMPT_COMMAND="history -a" | |
export HISTFILESIZE=2000 | |
# enable color support of ls and also add handy aliases | |
if [ "$TERM" != "dumb" ]; then | |
eval "`dircolors -b`" | |
alias ls='ls --color=auto' | |
#alias dir='ls --color=auto --format=vertical' | |
#alias vdir='ls --color=auto --format=long' | |
fi | |
shopt -s histverify # verifica comandos do histórico | |
shopt -s checkwinsize # ajusta janela redimensionada | |
shopt -s hostcomplete | |
[ ${BASH_VERSINFO[0]} -ge 4 ] && shopt -s globstar | |
shopt -s cdspell # fix wrong type keys | |
shopt -s dirspell | |
# convert text to lowcase | |
lower() { echo ${@,,}; } | |
expandurl() { curl -sIL $1 | awk '/^Location/ || /^Localização/ {print $2}' ; } | |
# calculadora com o comando bc | |
calc(){ echo "scale=2;$@" | bc;} | |
ff () { find . -type f -iname '*'"$@"'*' ; } | |
mkcd() { mkdir -p "$@" && cd $_; } | |
function decToBin { echo "ibase=10; obase=2; $1" | bc; } | |
decTohex() { bc <<< "obase=16; $1"; } | |
# make less more friendly for non-text input files, see lesspipe(1) | |
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" | |
CDPATH=.:..:~:~/docs/img:~/docs:~/bin:~/tmp | |
biggest (){ | |
du -k * | sort -nr | cut -f2 | head -20 | xargs -d "\n" du -sh | |
#du | sort -r -n | awk '{split("k m g",v); s=1; while($1>1024){$1/=1024; s++} print int($1)" "v[s]"\t"$2}' | |
} | |
top10 () { | |
history | awk '{print $2}' | sort | uniq -c | sort -rn | head | |
} | |
beep () { | |
echo -e -n \\a | |
} | |
# To enable the settings / commands in this file for login shells as well, | |
# this file has to be sourced in /etc/profile. | |
# 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 | |
# 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 | |
use_color=false | |
# Set colorful PS1 only on colorful terminals. | |
# dircolors --print-database uses its own built-in database | |
# instead of using /etc/DIR_COLORS. Try to use the external file | |
# first to take advantage of user additions. Use internal bash | |
# globbing instead of external grep binary. | |
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM | |
match_lhs="" | |
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" | |
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)" | |
[[ -z ${match_lhs} ]] \ | |
&& type -P dircolors >/dev/null \ | |
&& match_lhs=$(dircolors --print-database) | |
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true | |
if ${use_color} ; then | |
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489 | |
if type -P dircolors >/dev/null ; then | |
if [[ -f ~/.dir_colors ]] ; then | |
eval $(dircolors -b ~/.dir_colors) | |
elif [[ -f /etc/DIR_COLORS ]] ; then | |
eval $(dircolors -b /etc/DIR_COLORS) | |
fi | |
fi | |
if [[ ${EUID} == 0 ]] ; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]${LOCALIP:-`hostname`}\[\033[01;34m\] \W \$\[\033[00m\] ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@${LOCALIP:-`hostname`}\[\033[01;34m\] \w \$\[\033[00m\] ' | |
fi | |
alias ls='ls --color=auto' | |
alias grep='grep --colour=auto' | |
else | |
if [[ ${EUID} == 0 ]] ; then | |
# show root@ when we don't have colors | |
PS1='\u@${LOCALIP:-`hostname`} \W \$ ' | |
else | |
PS1='\u@${LOCALIP:-`hostname`} \w \$ ' | |
fi | |
fi | |
# Try to keep environment pollution down, EPA loves us. | |
unset use_color safe_term match_lhs | |
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. | |
# If this is an xterm set the title to user@host:dir | |
#case "$TERM" in | |
#xterm*|rxvt*) | |
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' | |
# ;; | |
#*) | |
# ;; | |
#esac | |
# enable bash completion in interactive shells | |
if [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
# if the command-not-found package is installed, use it | |
if [ -x /usr/lib/command-not-found ]; then | |
function command_not_found_handle { | |
# check because c-n-f could've been removed in the meantime | |
if [ -x /usr/lib/command-not-found ]; then | |
/usr/bin/python /usr/lib/command-not-found -- $1 | |
return $? | |
else | |
return 127 | |
fi | |
} | |
fi | |
extract() { | |
for i in "$@"; do | |
if [ -f "$i" ]; then | |
case "$i" in | |
*.[tT][aA][rR].[bB][zZ]|*.[tT][bB][zZ]) tar xjvf "$i" ;; | |
*.[tT][aA][rR].[bB][zZ]2|*.[tT][bB][zZ]2) tar xjvf "$i" ;; | |
*.[tT][aA][rR].[gG][zZ]|*.[tT][gG][zZ]) tar xzvf "$i" ;; | |
*.[gG][tT][gG][zZ]) tar xzvf "$i" ;; | |
*.[bB][zZ]2) bunzip2 "$i" ;; | |
*.[rR][aA][rR]) rar x -o+ "$i" ;; | |
*.[gG][zZ]) gunzip "$i" ;; | |
*.[tT][aA][rR]) tar xvf "$i" ;; | |
*.[zZ][iI][pP]) unzip -o "$i" ;; | |
*.Z) uncompress "$i" ;; | |
*.7[zZ]) 7z x "$i" ;; | |
*) echo "don't know how to extract '$i' ..." ;; | |
esac | |
else | |
echo "$i is not a valid file" | |
fi | |
done | |
} | |
/usr/bin/mint-fortune | |
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 | |
# Instalacao das Funcoes ZZ (www.funcoeszz.net) | |
#export ZZOFF="" # desligue funcoes indesejadas | |
export ZZPATH="${HOME}/bin/funcoeszz" # script | |
source "$ZZPATH" | |
alias translate='zzdicbabelfish' | |
alias tt='zzdicbabelfish' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment