Linux

Basic .bashrc

The Script

HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

case "$TERM" in
xterm-color) color_prompt=yes;;
esac

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
else
    color_prompt=
fi
fi

if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

alias ..='cd ..'
alias ps='ps -A'
alias ls='ls -lsaF --show-control-chars --color=never'
alias la='ls -ACk'
alias ns='netstat -abW | sed -n -e '1,/icm6/p''
alias profile='nano ~/.bashrc'
alias p='ping -c 3 $1'
alias c='clear'
alias rmd='rmdir $1'
alias snano='sudo nano $1'
alias maclean='find . -name "._*" -exec rm -v {} \; && find . -name ".DS_Store" -exec rm -v {} \; && find . -name "__MACOSX" -exec rm -rv {} \;'


h () { history | grep "$*" --color | cut -c 8- ; }
gr () { grep -R "$*" ./ --color ; }
k9 () { for A in $(ps -A | grep $* | grep -v grep | awk '{print $1}') ; do kill -9 "$A" ; done ;}
mkd () { mkdir -p -- "$1" && cd -P -- "$1";}


hosts () {
DEFAULT_IP=0.0.0.0
IP=${3:-$DEFAULT_IP}
case "$1" in
 -a)
    echo "$IP $2" | sudo tee -a /etc/hosts > /dev/null
    ;;
 -r)
    sudo sed -ie "\|^$IP $2\$|d" /etc/hosts
    ;;
 -u)
    echo
    echo "       [ HOST FILE UPDATER ]"
    echo

    # Update manually added to hosts.full

    sed '/#X#/q' /etc/hosts.full | sudo tee -a /etc/hosts.tmp &>/dev/null
    sed -n '/#X#/,$p' /etc/hosts | sed '/#X#/d' | sudo tee -a /etc/hosts.tmp &>/dev/null
    sudo rm /etc/hosts.full
    cat /etc/hosts.tmp | sudo tee -a /etc/hosts.full &>/dev/null
    sudo rm /etc/hosts.tmp
    echo "     updating full file: Done!"

    # Update manually added to hosts.basic

    sed '/#X#/q' /etc/hosts.basic | sudo tee -a /etc/hosts.tmp &>/dev/null
    sed -n '/#X#/,$p' /etc/hosts | sed '/#X#/d' | sudo tee -a /etc/hosts.tmp &>/dev/null
    sudo rm /etc/hosts.basic
    cat /etc/hosts.tmp | sudo tee -a /etc/hosts.basic &>/dev/null
    sudo rm /etc/hosts.tmp
    echo "     updating basic file: Done!"
    ;;
 -c)
   ;;
 -b)
    sudo cp /etc/hosts.basic /etc/hosts
    ;;
 -e)
    nano /etc/hosts
    ;;

 -f)
    sudo cp /etc/hosts.full /etc/hosts
    ;;
 *)
    echo
    echo "   Usage: hosts [option] [hostname] [ip]"
    echo
    echo "   Options: -a = add | -r = remove | -u = update full basic and clean hosts"
    echo "            -c = set clean hosts | -b = set basic hosts | -f = set full hosts | -e = edit hosts"
    echo
    echo "   Examples:"
    echo "             hosts -u"
    echo "             hosts -a testing.com"
    echo "             hosts -r testing.com"
    echo "             hosts -a testing.com 0.0.0.0"
    echo "             hosts -r testing.com 0.0.0.0"
    echo
    echo "   * No ip will default to 0.0.0.0"
    ;;
esac
}

PS1="\n \[\e[0m\]\[\e[0;m\] \u \[\e[34;1m\][\[\e[0;m\]\w\[\e[34;1m\]] \[\e[37;1m\]\[\e[0m\]$ "