Welcome to E8 :: [eon8]

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll also be able to use the shoutbox, customize your profile, change themes, gain reputation points for submitting content, while also communicating with other members via your own private messenger, plus much more!

 

This message will be removed once you have signed in.

Sign in to follow this  
molossus

LINUX: share your bashrc ?

4 posts in this topic


# .bashrc


# Source global definitions

if [ -f /etc/bashrc ]; then

	. /etc/bashrc

fi


# User specific aliases and functions

##################################

#    _   _ _                     #

#   /_\ | (_) __ _ ___  ___ ___  #

#  //_\\| | |/ _` / __|/ _ | __| #

# /  _  \ | | (_| \__ \  __|__ \ #

# \_/ \_/_|_|\__,_|___/\___|___/ #

##################################

alias ut='tar -zxvf' # untar

alias t='tar -cvf'

alias tsee='tar -tvf'

alias off="su -c 'shutdown -h now'"

alias restart="su -c 'reboot'"

alias x='exit'

alias cls='clear'

alias ..='cd ..'

alias ...='cd ../..'

alias pdir='cd $OLDPWD'

alias docs='cd /home/klesk/Documents;ls -l'

alias downs='cd /home/klesk/Downloads;ls -l'

# chmod and permissions commands

alias mx='chmod a+x'

alias 000='chmod 000'

alias 644='chmod 644'

alias 755='chmod 755'

alias mynet="su -c 'nmap -O -sS 192.168.1.0/24'"

# System info

alias cpuu="ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"

alias memu='ps -e -o rss=,args= | sort -b -k1,1n | pr -TW$COLUMNS'

alias pg='ps aux | grep'  #requires an argument

#Use human-readable filesizes

alias du="du -h"

alias df="df -h"



#-------------------------------------------------------------

# The 'ls' family (this assumes you use a recent GNU ls)

#-------------------------------------------------------------

alias l='ls'

alias ll="ls -l --group-directories-first"

alias ls='ls -hF --color'  # add colors for filetype recognition

alias la='ls -Al'          # show hidden files

alias lx='ls -lXB'         # sort by extension

alias lk='ls -lSr'         # sort by size, biggest last

alias lc='ls -ltcr'        # sort by and show change time, most recent last

alias lu='ls -ltur'        # sort by and show access time, most recent last

alias lt='ls -ltr'         # sort by date, most recent last

alias lm='ls -al |more'    # pipe through 'more'

alias lr='ls -lR'          # recursive ls

alias tree='tree -Csu'     # nice alternative to 'recursive ls'


#-------------------------------------------------------------

# spelling typos - highly personnal and keyboard-dependent :-)

#-------------------------------------------------------------

alias xs='cd'

alias vf='cd'

alias moer='more'

alias moew='more'

alias kk='ll'


############################################################

#  _____ _              ___                           _    #

# /__   \ |__   ___    / _ \_ __ ___  _ __ ___  _ __ | |_  #

#   / /\/ '_ \ / _ \  / /_)/ '__/ _ \| '_ ` _ \| '_ \| __| #

#  / /  | | | |  __/ / ___/| | | (_) | | | | | | |_) | |_  #

#  \/   |_| |_|\___| \/    |_|  \___/|_| |_| |_| .__/ \__| #

#                                              |_|         #

############################################################ 	


# Greeting, motd etc...

#-------------------------------------------------------------

# Define some colors first:

LIGHTGRAY='\e[0;37m'

LIGHTBLUE='\e[1;34m'

LIGHTGREEN='\e[1;32m'

LIGHTCYAN='\e[1;36m'

red='\e[0;31m'

RED='\e[1;31m'

blue='\e[0;34m'

BLUE='\e[1;34m'

cyan='\e[0;36m'

CYAN='\e[1;36m'

NORMAL='\[\033[00m\]'

NC='\e[0m'              # No Color

PS1="$cyan[\u@\h] -> $LIGHTBLUE\w $NC \n \$ "

##################################################

#    ___                  _   _                  #

#   / __\_   _ _ __   ___| |_(_) ___  _ __  ___  #

#  / _\ | | | | '_ \ / __| __| |/ _ \| '_ \/ __| #

# / /   | |_| | | | | (__| |_| | (_) | | | \__ \ #

# \/     \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ #

##################################################

# edit bashrc

ebash ()

{

  cd;vim .bashrc

}

#source bashrc

sbash ()

{

  source .bashrc

}


# grep for active process

function psgrep()

{

        ps aux | grep -e $1

}

#------------------------------------------------

# Makes extraction easier

function extract() {

     if [ -f $1 ] ; then

         case $1 in

             *.tar.bz2)   tar xvjf $1     ;;

             *.tar.gz)    tar xvzf $1     ;;

             *.bz2)       bunzip2 $1      ;;

             *.rar)       unrar x $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 "'$1' cannot be extracted via >extract<" ;;

         esac

     else

         echo "'$1' is not a valid file"

     fi

}


#-------------------------------------------------------------

# cut last n lines in file, 10 by default

#-------------------------------------------------------------

function cuttail() 

{

    nlines=${2:-10}

    sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1

}


#-------------------------------------------------------------

# Process/system related functions:

#-------------------------------------------------------------

function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; }


function pp() { my_ps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; }


function killps()                 # Kill by process name.

{

    local pid pname sig="-TERM"   # Default signal.

    if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then

        echo "Usage: killps [-SIGNAL] pattern"

        return;

    fi

    if [ $# = 2 ]; then sig=$1 ; fi

    for pid in $(my_ps| awk '!/awk/ && $0~pat { print $1 }' pat=${!#} ) ; do

        pname=$(my_ps | awk '$1~var { print $5 }' var=$pid )

        if ask "Kill process $pid <$pname> with signal $sig?"

            then kill $sig $pid

        fi

    done

}

#-------------------------------------------------------------

# Get IP adresses.

#-------------------------------------------------------------

function my_ip() 

{

    MY_IP=$(/sbin/ifconfig ppp0 | awk '/inet/ { print $2 } ' | \

sed -e s/addr://)

    MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | \

sed -e s/P-t-P://)

}


#-------------------------------------------------------------

# Get Host Information

#-------------------------------------------------------------

function hostinfo()   # Get current host related info.

{

    echo -e "\nYou are logged on ${RED}$HOST"

    echo -e "\nAdditionnal information:$NC " ; uname -a

    echo -e "\n${RED}Users logged on:$NC " ; w -h

    echo -e "\n${RED}Current date :$NC " ; date

    echo -e "\n${RED}Machine stats :$NC " ; uptime

    echo -e "\n${RED}Memory stats :$NC " ; free

    my_ip 2>&- ;

    echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"}

    echo -e "\n${RED}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}

    echo -e "\n${RED}Open connections :$NC "; netstat -pan --inet;

    echo

}


#-------------------------------------------------------------

# Creates an archive from given directory

#-------------------------------------------------------------

mktar() { tar cvf  "${1%%/}.tar"     "${1%%/}/"; }

mktgz() { tar cvzf "${1%%/}.tar.gz"  "${1%%/}/"; }

mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }


#-------------------------------------------------------------

#Automatically do an ls after each cd

#-------------------------------------------------------------

#cd() {

#  if [ -n "$1" ]; then

#    builtin cd "$@" && ls -hF --color

#  else

#   builtin cd ~ && ls -hF --color

#  fi

#}

#-------------------------------------------------------------

# Network Information

#-------------------------------------------------------------

netinfo ()

{

echo "--------------- Network Information ---------------"

/sbin/ifconfig | awk /'inet addr/ {print $2}'

echo ""

/sbin/ifconfig | awk /'Bcast/ {print $3}'

echo ""

/sbin/ifconfig | awk /'inet addr/ {print $4}'

/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'

myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `

echo "${myip}"

echo "---------------------------------------------------"

}

# --- Exports --- #

export EDITOR=vim

export VISUAL=vim

#-----------------------------#

#      WELCOME SCREEN		  #

#-----------------------------#

clear


echo -ne "${LIGHTGREEN}""Hello, $USER. today is, "; date

echo -e "${LIGHTGREEN}"; cal -3;

echo -e "${WHITE}"; uname -a ;

echo ""

#------------------------------


Share this post


Link to post
Share on other sites

Its in the title

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this