bashrc

Razne diskusije nevezane za Linux.

Moderator/ica: Moderatori/ce

Lutherus

bashrc

Post Postao/la Lutherus »

Mislim da bi bilo zgodno da ima kutak na forumu gdje bi mogli pokazati svoje bash skripte.
Pa evo i moje.Nastala je od više manjih skriptica koje skupil kroz svo ovo vrijeme po raznim forumima a neke su i moje djelo.

slika

i evo bashrc

https://sites.google.com/site/listapaketa/

da,ispričavam se , zbog previše znakova je bilo bnemoguće postati direktno na forum.
Avatar
stefan
Moderator
Postovi: 4366
Pridružen/a: 28 sij 2009, 18:46
Spol: M
OS: openSUSE Leap KDE

Re: bashrc

Post Postao/la stefan »

Odlicna ideja!!!
Cudno da se netko nije ranije sjetio..

Bilo bi dobro da napises i brief objasnjenje sto skripta radi. Iako se da zakljuciti iz skrinsota.
Lutherus

Re: bashrc

Post Postao/la Lutherus »

stavil .bashrc u prilogu na

google/sites/list jer bi bilo preko 13 000 znakova a to je malo puno previše za forum.
inače ima tu računanje trigonometrije,ascii,bin i hex konverter,skrinšat tool,riper u ogg,razne šale,....
Avatar
drade
Postovi: 910
Pridružen/a: 12 svi 2010, 07:57
OS: linux

Re: bashrc

Post Postao/la drade »

Kod: Označi sve

#!/bin/bash
#
# SCRIPT :      sys-info
#
# AUTHOR :      drade
#
# DATE   :	17.04.2004 <DDMMYYYY>
#
# REV    :      1.1-P
#
# PLATFORM: GNU/Linux
#
#
# PURPOSE : Script that will gather general system information such as
#           info about: users, memory usage, hardware... after it finnishes
#           gathering information it shall append stats to a file and/or
#           display statistics to user in xmessage window.
#
#
# CHANGELOG: Thanks to ****** for pointing me 
#	     to error that occurs when the script is being ran from default 
#	     directory.	
#	     
# REV_LIST : Changed script name :) to sys-info.
#
# LICENCE: GPL
#
############################################################################
##############   AND SO WE EMBARK ON NEW SCRIPTING FRONTIERS   #############
############################################################################

# Constant variables definition

# General variables
dev_pci=/proc/pci
opt_for=`echo $MACHTYPE | awk -F- '{print $1}'`

# Functions
function stats_file
{
	stats_dir=sys-stats

	dest=

	while [ -z $dest ]
	do
		echo -e "\nPlease choose where system stats shall be written to !\n"
		echo -e "\t\t1 I will set destination myself ( path )"
		echo -e "\t\t2 Use default path ( ~/sys-stats )\n"

	echo -en "Your Choice => "; read DESTINATION
	case $DESTINATION
	in
		1 ) echo -ne "Provide full path ( e.g /home/user/sys-stats ) => "; read MYPATH
		    if [ -e $MYPATH/$stats_dir -a -d $MYPATH/$stats_dir ]
		    then
				stats_file=$MYPATH/$stats_dir/sys-stats.info
				stats_file_other=$MYPATH/$stats_dir/sys-stats			
		    else
				mkdir -p $MYPATH/$stats_dir
				stats_file=$MYPATH/$stats_dir/sys-stats.info
			        stats_file_other=$MYPATH/$stats_dir/sys-stats
		    fi
		    dest=TRUE;;

		2 ) if [ -e ~/$stats_dir -a -d ~/$stats_dir ]
		    then
			  	stats_file=~/$stats_dir/sys-stats.info
                                stats_file_other=~/$stats_dir/sys-stats

		    else
				mkdir -p ~/$stats_dir
				stats_file=~/$stats_dir/sys-stats.info
                                stats_file_other=~/$stats_dir/sys-stats
		    fi
		    dest=TRUE;;

		* ) echo -e "\nInvalid choice, please reenter !\n";;
	esac
done
echo
}

function progress_bar
{

        while true
        do
                echo -ne "##"
		sleep 15
        done
}

function distro_type
{
        if [ -e /etc/*release* -a -f /etc/*release* ]
        then
                DISTRO=`cat /etc/*release*`

        elif [ -e /etc/*version* -a -f /etc/*version* ]
        then
                DISTRO=`cat /etc/*version*`

        else
                DISTRO="Unable to determine"
        fi

}

function root_check
{
        if [ "$UID" -ne 0 ]
        then
                echo -e "\n###############################################"
                echo -e "# r00t check failed, please login as r00t and #"
                echo -e "# run this script again. THANK YOU :)         #"
                echo -e "###############################################\n"
		exit 1
        else
                echo -e "\n##############################################"
                echo -e "#  Started on `date`  #"
                echo -e "##############################################"
        fi
}

function gnuc-gcc_test
{
        /lib/libc.so.6 2>&1 > /dev/null

        if [ $? -ne 0 ]
        then
                GNUC_LIB="Unable to determine"
        else
		GNUC_LIB=`/lib/libc.so.6 | grep "GNU C L*" | awk -F" " '{print $6,$7}'`
	fi

	# gcc

	GCC_VER=`echo -n "version " && gcc -dumpversion`
}


function stat_file_header
{
echo '# Information displayed in this file was gathered by sys-stats script' > $stats_file
echo "# made by drade <> on `date`" >> $stats_file
echo >> $stats_file
echo '# SYSTEM STATISTICS:' >> $stats_file
echo >> $stats_file
}

function ip_class
{
        IFACE=`ifconfig | awk -F" " '{print $1}' | grep eth`
        OCT_1=`echo $ADDR | awk -F. '{print $1}'`
        ROUTE=`route | grep default | awk -F" " '{print $2}'`
}

function hardware_info
{
        cpu_spec=/proc/cpuinfo
        dev_pci=/proc/pci
        proc_temp=/proc/acpi/thermal_zone/THRM/temperature

        # processor specifics

        PROC_VENDOR=`cat $cpu_spec | grep "vendor_id" | awk -F: '{print $2}' | sed 's/^ //' | uniq`
        PROC_MODEL=`cat $cpu_spec | grep "model name" | awk -F: '{print $2}' | sed 's/^ //' | uniq`
        PROC_NO=`cat $cpu_spec | grep "processor" | wc -l`
        PROC_MHZ=`cat $cpu_spec | grep "cpu MHz" | awk -F: '{print $2}' | sed 's/^ //' | uniq`
        PROC_CACHE=`cat $cpu_spec | grep "cache size" | awk -F: '{print $2}' | sed 's/^ //' | uniq`

        if [ -e $proc_temp -a -f $proc_temp ]
        then
                CPU_TEMP=`cat $proc_temp | awk -F" " '{print $2,$3}'`
        else
                CPU_TEMP="Unable to determine"
        fi

        # network card specifics
	IFACE_MODEL=`lspci | grep -i ethernet | awk -F: '{print $3}' | sed 's/^ //'`

        # audio card
	AUDIO_CARD=`lspci | grep -i audio | awk -F: '{print $3}' | sed 's/^ //'`
	
        # graphic card
	VGA_CARD=`lspci | grep -i vga | awk -F: '{print $3}' | sed 's/^ //'`

        # firewire
	ILINK=`lspci | grep -i firewire | awk -F: '{print $3}' | sed 's/^ //'`

        # usb
	USB=`lspci | grep -i usb | awk -F: '{print $3}' | sed 's/^ //'`

        # Devices

        HDD=`ls /dev/[sh]d?`

	# Bridges and SMBus
	
	ISA_BRIDGE=`lspci | grep -i isa | awk -F: '{print $3}' | sed 's/^ //'`
	PCI_BRIDGE=`lspci | grep -i pci | awk -F: '{print $3}' | sed 's/^ //'`
	IDE_IFACE=`lspci | grep -i ide | awk -F: '{print $3}' | sed 's/^ //'`
	SMBUS=`lspci | grep -i smbus | awk -F: '{print $3}' | sed 's/^ //'`
}

function proc_mem
{
        mem_file=/proc/meminfo

        # users and processes

        PROC_USR=`ps aux | awk -F" " '{print $1}' | sed '1d' | sort | uniq -w 25`
        USERS_NUM=`who | awk -F" " '{print $1}' | wc -l`
        USER_NAMES=`who | awk -F" " '{print $1}'`

        # Memory

        SWAP_TOTAL=`cat $mem_file | grep -i swaptotal | awk -F" " '{print $2}'`
        SWAP_FREE=`cat $mem_file | grep -i swapfree | awk -F" " '{print $2}'`
        MEM_TOTAL=`cat $mem_file | grep -i memtotal | awk -F" " '{print $2}'`
        MEM_FREE=`cat $mem_file | grep -i memfree | awk -F" " '{print $2}'`
}

function fs_sec
{
	# Searching setgid
	find / -perm +2000 2> /dev/null > $stats_file_other.SGID

	# Searching setuid
	find / -perm +4000 2> /dev/null > $stats_file_other.SUID

	# Searching files and folder that are owned by nouser and nogroup
	find / \( -nogroup -a -nouser \) 2> /dev/null > $stats_file_other.NO-GRPUSR

	# Searching world writable files
	find / -type f -perm -2 2> /dev/null > $stats_file_other.WORLD
} 

function select_menu
{
	value=

	while [ -z $value ]
	do
		echo -e "\nPlease Select:\n"
		echo -e "\t\t1 I have X running, show my report in popup window and EXIT."
		echo -e "\t\t2 I do not have X running, show my report in terminal and EXIT."
		echo -e "\t\t3 I will look at my report manaully ( EXIT ).\n"
		
	echo -ne "Your Choice => "; read CHOICE

		case $CHOICE
	 	in
			1 ) PATH=$PATH:/usr/X11R6/bin  # Because some distributions do not have it in r00t's PATH
			    xmessage -center -file $stats_file
			    value=TRUE;;
			2 ) cat $stats_file | less
			    value=TRUE;;
			3 ) value=TRUE;;
			* ) echo -e "\nInvalid choice, please reenter !\n";;
		esac
	done
}
 		
function final_words
{
        echo
        echo -e "###########################################################################"
        echo -e " Your system statistic file is located in: $stats_file ."
        echo -e "###########################################################################"
        echo
}

# Script starts here
# Checking weather user who ran the script is r00t user
root_check

# Promptimg user to select the destination of teh sys-stats directory
stats_file

# Appending nice lil header to sys-stat file
stat_file_header

# Gathering distro specific information ( distribution name and architecture )
echo "# Distribution information" >> $stats_file
echo >> $stats_file
echo -e "\nGathering information, plase wait..."
echo

progress_bar &
pbar_pid=$!

distro_type
echo -e "DISTRIBUTION:\t$DISTRO\n" >> $stats_file
echo -e "BUILT FOR:\t$opt_for\n" >> $stats_file

gnuc-gcc_test
echo -e "GNU C LIBRARY:\t$GNUC_LIB\n" >> $stats_file
echo -e "GCC VERSION:\t$GCC_VER\n" >> $stats_file
echo -e "KERNEL VERSION:\t`uname -r`\n" >> $stats_file

# Gathering network information

echo "# Network information" >> $stats_file
echo >> $stats_file

ip_class
echo -e "HOSTNAME:\t$HOSTNAME\n" >> $stats_file
echo -e "IP ADDRESS:" >> $stats_file

        for iface in $IFACE
        do
                echo -e "INTERFACE: $iface => `ifconfig $iface | awk '/inet/ { print $2 } ' | sed -e s/addr://`" >> $stats_file
        done
echo >> $stats_file
echo -e "MAC ADDRESS:" >> $stats_file

        for mac in $IFACE
        do
                echo -e "INTERFACE: $mac => `ifconfig $mac | awk '/HWaddr/ { print $5 } ' | sed -e s/addr://`" >> $stats_file
        done
echo >> $stats_file
echo -e "IP CLASS(subnetmask):" >> $stats_file

	for subnet in $IFACE
	do
		echo -e "INTERFACE: $subnet => `ifconfig $subnet | awk '/Mask/ {print $4}' | awk -F: '{print $2}'`" >> $stats_file
	done
echo >> $stats_file
echo -e "DEFAULT GATEWAY:\t$ROUTE\n" >> $stats_file
echo -e "IPv6 ADDRESS:\t$IP_ADDR6" >> $stats_file

        for inet6 in $IFACE
        do
                echo -e "INTERFACE: $inet6 => `ifconfig $inet6 | awk '/inet6/ { print $3 } ' | sed -e s/addr://`" >> $stats_file
        done

echo >> $stats_file

# Gathering hardware information

echo "# Hardware information" >> $stats_file
echo >> $stats_file

hardware_info

echo -e "CPU VENDOR:\t$PROC_VENDOR" >> $stats_file
echo -e "CPU MODEL:\t$PROC_MODEL" >> $stats_file
echo -e "NUMBER OF CPU:\t$PROC_NO" >> $stats_file
echo -e "CPU SPEED:\t$PROC_MHZ" >> $stats_file
echo -e "CPU CACHE:\t$PROC_CACHE" >> $stats_file
echo -e "CPU TEMPERATURE:\t$CPU_TEMP\n" >> $stats_file
echo -e "NETWORK INTERFACE:\n`lspci | grep -i ethernet | awk -F: '{print $3}' | sed 's/^ //'`\n" >> $stats_file
echo -e "AUDIO CARD:\t$AUDIO_CARD\n" >> $stats_file
echo -e "VIDEO CARD:\t$VGA_CARD\n" >> $stats_file
echo -e "FIREWIRE CONTROLLER(s):\n`lspci | grep -i firewire | awk -F: '{print $3}' | sed 's/^ //'`\n" >> $stats_file
echo -e "USB CONTROLLER(s):\n`lspci | grep -i usb | awk -F: '{print $3}' | sed 's/^ //'`\n" >> $stats_file
echo -e "ISA BRIDGE:\n$ISA_BRIDGE\n" >> $stats_file
echo -e "PCI BRIDGE:\n$PCI_BRIDGE\n" >> $stats_file
echo -e "IDE INTERFACE:\n$IDE_IFACE\n" >> $stats_file
echo -e "SMBus:\n$SMBUS\n" >> $stats_file

# devices like hard disk and CD/DVD are handled with the code below, i know its a bit bogus
# but it does what it is supposed to do :)

echo "DEVICES:" >> $stats_file

        for disk in $HDD
        do
                DEVNAME=`hdparm -i $disk 2> /dev/null | grep -i "model" | awk -F= '{print $2}' | awk -F, '{print $1}'`
                echo -e "( $disk ):\nMODEL: $DEVNAME\nSIZE:`fdisk -l $disk 2>&1 | awk -F: '{print $2}' | sed '1d'`\n" 2> /dev/null >> $stats_file
        done 2> /dev/null

# Find setgid,setuid,files owned by noone and world readable file append output to
# appropriate file ( notation sys-stats.SGID ....etc )
fs_sec

echo "# File and Folder information" >> $stats_file
echo >> $stats_file

echo -e "SETGID FILES and DIRECTORIES:\t`cat $stats_file_other.SGID | wc -l`\n\
( consult $stats_file_other.SGID for list of files and directories )\n" >> $stats_file
echo -e "SETUID FILES and DIRECTORIES:\t`cat $stats_file_other.SUID | wc -l`\n\
( consult $stats_file_other.SUID for list of files and directories )\n" >> $stats_file
echo -e "FILES and DIRECTORIES OWNED BY NOUSER and NOGROUP:\t`cat $stats_file_other.NO-GRPUSR | wc -l`\n\
( consult $state_file_other.NO-GRPUSR for list of files and directories )\n" >> $stats_file
echo -e "FILES and DIRECTORIES that are WORLD writable:\t`cat $stats_file_other.WORLD | wc -l`\n\
( consult $state_file_other.WORLD for list of files and directories )\n" >> $stats_file

# Users and processes
proc_mem

echo "# User, process and memory information" >> $stats_file
echo >> $stats_file
echo -e "LOGGED USERS:\t$USERS_NUM" >> $stats_file

        for user in $USER_NAMES
        do
                echo "NAME: $user" >> $stats_file
        done
echo >> $stats_file
echo -e "PROCESSES RUNNING AS:" >> $stats_file

        for users in $PROC_USR
        do
                echo "USER: ( $users ) => `ps -U $users | wc -l`" >> $stats_file
        done
echo >> $stats_file

# Memory section
echo -e "MEMORY TOTAL(kb):\t$MEM_TOTAL" >> $stats_file
echo -e "MEMORY FREE(kb):\t$MEM_FREE" >> $stats_file
echo -e "SWAP TOTAL(kb):\t$SWAP_TOTAL" >> $stats_file
echo -e "SWAP FREE(kb):\t$SWAP_FREE" >> $stats_file

echo -n " => DONE <="
echo

echo
kill $pbar_pid 2> /dev/null > term.pbar && rm term.pbar
select_menu
final_words
Vrlo davno radjeno (2004), za osobne potrebe, nekakva "system profiler" skriptica. Danas kod vjerojatno ima nekakvih greskica no radi bez problema (za one koji zeli isprobati skriptu), takodjer je vrlo vjerojatno da neki od pathova definiranih unutar koda vise ne postoje pa finalni izvjestaj nece biti potpun.
When you're a kid and you wanna go "Weee !", but you ain't got drugs yet ... You hold out for your life, hold on to your little GONADS ... and STRIFE.
Avatar
madone
Postovi: 1594
Pridružen/a: 09 srp 2008, 09:49
Spol: M
OS: Debian
Lokacija: Zagreb

Re: bashrc

Post Postao/la madone »

@odin
Ima svega u tvom bashrc-u baš mi je zanimljiv.
Neke stvari se i ponavljaju (kao extract)
Budem kasnije stavio i ja svog kad ga malo sredim tvoj je tako uredan da mi je neugodno :)

Može jedno objašnjenje čemu služi PATH

Kod: Označi sve

##################################################
# PATH						                         #
##################################################

PATH=$PATH:$HOME/bin

if [ "$UID" -eq 0 ]; then
    PATH=$PATH:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
fi

#remove duplicate path entries
export PATH=$(echo $PATH | awk -F: '
{ for (i = 1; i <= NF; i++) arr[$i]; }
END { for (i in arr) printf "%s:" , i; printf "\n"; } ')
i

Kod: Označi sve

##################################################
# Temporarily add to PATH			               #
##################################################

function apath()
{
    if [ $# -lt 1 ] || [ $# -gt 2 ]; then
        echo "Temporarily add to PATH"
        echo "usage: apath [dir]"
    else
        PATH=$1:$PATH
    fi
}
Lutherus

Re: bashrc

Post Postao/la Lutherus »

pokušal već neke stvari koje se ponavljaju izbaciti kao i neke skripte koje više nerade :?: i neke koje su mi sa vremenom postale nepotrebne i svel ga na svega 687 redova no onda mi počel javljati greške u redovima koji nepostoje kao recimo 779 red i prestala je raditi skripta za trigonometriju a i kalendar crknul :?

PATH je Linux/UNIX varijabla koja shellu kaže u kojim direktorijima tražiti izvršne datoteke.
Avatar
madone
Postovi: 1594
Pridružen/a: 09 srp 2008, 09:49
Spol: M
OS: Debian
Lokacija: Zagreb

Re: bashrc

Post Postao/la madone »

Evo i moj bashrc.
Imao sam brdo toga ali sam skužio da pola toga ne upotrebljavam pa sam izbacio.

Kod: Označi sve

# Veličina bash history
export HISTFILESIZE=1500

######   POTREBNO ZA WIFFY SKRIPTU
export DISPLAY=:0.0

[ -f ~/.bash_alias ] && source $HOME/.bash_alias

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    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

# 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 [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi



#!/bin/bash
#------------------------------------------////
# Lapbox ~/.bashrc file
# Last Modified 20 January 2009
# Running on Debian GNU/Linux - Lenny
#------------------------------------------////


#------------------------------------------////
# Some original .bashrc contents:
#------------------------------------------////
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(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
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#------------------------------------------////
# Prompt:
#------------------------------------------////
#PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] '
PS1='\[\033[00;35m\]\[\033[0;32m\]\[\033[0;32m\]\u\[\033[0;35m\]@\[\033[0;32m\]\h\[\033[00;35m\](\[\033[01;35m\]\w\[\033[00;35m\])\[\033[0;32m\]#\[\e[m\]\[\e[1;37m\]'

#PS1='${debian_chroot:+($debian_chroot)}[\t]\u@\h:\$\[\e[m\]\[\e[1;37m\]' 
# Fancy bash
#PS1='\[\033[2;32m\][\t]\[$White\]@\[$Cyan\]\h\[$LightBlue\]:\[$LightCyan\]\w\[$LightBlue\]\$\[\e[m\]\[\e[1;37m\] '

#------------------------------------------////
# Colors:
#------------------------------------------////
#Black       0;30     Dark Gray     1;30
#Blue        0;34     Light Blue    1;34
#Green       0;32     Light Green   1;32
#Cyan        0;36     Light Cyan    1;36
#Red         0;31     Light Red     1;31
#Purple      0;35     Light Purple  1;35
#Brown       0;33     Yellow        1;33
#Light Gray  0;37     White         1;37


#------------------------------------------////
# System Information:
#------------------------------------------////
# Inserts a flag with the specified content
# Usage: flag "comment"
# If no comment, inserts the date.
function flag(){
    if [ "$1" == "" ];
    then
        echo -e  "\e[0;31m[====== " `date +"%A %e %B %Y"`, `date +"%H"`h`date +"%M"` " ======]\e[0m"
    else
        echo -e  "\e[0;31m[====== " $@ " ======]\e[0m"
    fi
}
#------------------------------------------////
# Aliases:
#------------------------------------------////

# Informacije o Kernelu, Uptime, Particije i verziji OS
alias stat="echo ' ' && lsb_release -a && echo ' ' && uname -a && echo ' '&& uptime &&echo ' '&& df && echo ' '"
## Največi file-ovi
alias findbig='find . -type f -exec ls -s {} \; | sort -n -r | head -5'

# Ovo mi je fora alias pokazuje sve otvorene portove, vrste, adrese, programe koji ih koriste i pid. Sve pregledno.
alias port='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94'


alias debianathome='ssh -p XXXX hbserv1 -l XXXXXX'
alias ping='ping -c 4'
alias search='aptitude search'
alias show='aptitude show'
alias l.='ls -d .[[:alnum:]]* 2> /dev/null || echo "No hidden file here..."' # list only hidden files
alias lm='ls -al |more'
alias ll='ls -l';
alias dir='ls --color=auto --format=vertical';
alias vdir='ls --color=auto --format=long';
alias ols='/bin/ls';
alias e='exit'
alias c='clear'
alias swap='swapoff -a && swapon -a'

#############################################################################################
###############       A L I A S  - I       ##################################################
#############################################################################################

## Dir shortcuts
# Pamti dva direktorija + i _
alias +='pushd .'
alias _='popd' 
alias r='cd /root'
alias m='cd /home/madone'
alias d='cd /home/madone/Desktop'
alias dokumenti='cd /home/madone/Documents'
alias net='cd /home/madone/Downloads'
alias muzika='cd /home/madone/Music'
alias slike='cd /home/madone/Pictures'
alias www='cd /home/madone/www'
alias video='cd /home/madone/Videos'
alias bashrc='gedit /root/.bashrc'

# Ne radi mi zvuk
#alias record="ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -r 30 -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -i :0.0 -acodec pcm_s16le -vcodec libx264 -#vpre lossless_ultrafast -threads 0 -y /home/madone/Desktop/output.mkv"

# Ovo trebam doraditi da mi samo aliase izbaci 
#alias alias= "'echo  ' && cat /root/.bashrc | grep alias' '"


# za smxi
alias s='cd /usr/local/bin'



#alias down='sudo aptitude'
### Aptitude skida paket u direktorij iz kojeg je pokrenut to se nemože sa apt-get 
alias down='sudo aptitude download'
alias install='sudo aptitude install'
alias remove='sudo aptitude remove'
alias autoremove='sudo aptitude autoremove'
alias clean='sudo aptitude clean'
alias purge='sudo aptitude purge'
alias update='sudo aptitude update'
alias upgrade='sudo aptitude upgrade'

alias repo='sudo add-apt-repository'
alias key='sudo apt-key adv --keyserver wwwkeys.eu.pgp.net --recv-keys'

#------------------------------------------////
# Functions and Scripts:
#------------------------------------------////
encrypt ()
{
gpg -ac --no-options "$1"
}

decrypt ()
{
gpg --no-options "$1"
}

# Tries to unarchive anything thrown at it
extract() {
    ##### Probably done more robustly with file(1) but not as easily
    local FILENAME="${1}"
    local FILEEXTENSION=`echo ${1} | cut -d. -f2-`
    case "$FILEEXTENSION" in
        tar)
            tar xvf "$FILENAME";;
        tar.gz)
            tar xzvf "$FILENAME";;
        tgz)
            tar xzvf "$FILENAME";;
        gz)
            gunzip "$FILENAME";;
        tbz)
            tar xjvf "$FILENAME";;
        tbz2)
            tar xjvf "$FILENAME";;
        tar.bz2)
            tar xjvf "$FILENAME";;
        tar.bz)
            tar xjvf "$FILENAME";;
        bz2)
            bunzip2 "$FILENAME";;
        tar.Z)
            tar xZvf "$FILENAME";;
         Z)
            uncompress "$FILENAME";;
         zip)
            unzip "$FILENAME";;
         ZIP)
            unzip "$FILENAME";;
         rar)
            unrar x "$FILENAME";;
    esac
}
# Compress
compress () {
   FILE=$1
   case $FILE in
      *.tar.bz2) shift && tar cjf $FILE $* ;;
      *.tar.gz) shift && tar czf $FILE $* ;;
      *.tgz) shift && tar czf $FILE $* ;;
      *.zip) shift && zip $FILE $* ;;
      *.rar) shift && rar $FILE $* ;;
   esac
}
# Find a file with a pattern in name in the local directory
function ff()
{
    find . -type f -iname '*'$*'*' -ls ;
}
# Creates a backup of the file passed as parameter with the date and time
function backup ()
{
  cp $1 $1_`date +%H:%M:%S_%d-%m-%Y`
}
# Swap 2 filenames around
function swap()
{
    local TMPFILE=tmp.$$
    mv "$1" $TMPFILE
    mv "$2" "$1"
    mv $TMPFILE "$2"
}
# Advanced ls function
# Counts files, subdirectories and directory size and displays details
# about files depending on the available space
function lls () {
	# count files
	echo -n "<`find . -maxdepth 1 -mindepth 1 -type f | wc -l | tr -d '[:space:]'` files>"
	# count sub-directories
	echo -n " <`find . -maxdepth 1 -mindepth 1 -type d | wc -l | tr -d '[:space:]'` dirs/>"
	# count links
	echo -n " <`find . -maxdepth 1 -mindepth 1 -type l | wc -l | tr -d '[:space:]'` links@>"
	# total disk space used by this directory and all subdirectories
	echo " <~`du -sh . 2> /dev/null | cut -f1`>"
	ROWS=`stty size | cut -d' ' -f1`
	FILES=`find . -maxdepth 1 -mindepth 1 |
	wc -l | tr -d '[:space:]'`
	# if the terminal has enough lines, do a long listing
	if [ `expr "${ROWS}" - 6` -lt "${FILES}" ]; then
		ls
	else
		ls -hlAF --full-time
	fi
}
Lutherus

Re: bashrc

Post Postao/la Lutherus »

ja svojega uspjel srezati na 3145 reda :mrgreen: više 60 % ga izbacil van
Lutherus

Re: bashrc

Post Postao/la Lutherus »

Kod: Označi sve

alias ls='ls -hF --color'    # add colors for filetype recognition
alias lx='ls -lXB'        # sort by extension
alias lk='ls -lSr'        # sort by size
alias la='ls -Al'        # show hidden files
alias lr='ls -lR'        # recursice ls
alias lt='ls -ltr'        # sort by date
alias lm='ls -al |more'        # pipe through 'more'
alias tree='tree -Cs'        # nice alternative to 'ls'
alias ll='ls -l'        # long listing
alias l='ls -hF --color'    # quick listing
alias lsize='ls --sort=size -lhr' # list by size
alias l?='cat /home/will/technical/tips/ls'
alias lsd='ls -l | grep "^d"'   #list only directories

Command substiution
alias ff='sudo find / -name $1'
alias df='df -h -x tmpfs -x usbfs'
alias psg='ps -ef | grep $1'
alias h='history | grep $1'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias which='type -all'
alias ..='cd ..'
alias vi='vim'

# Set some colors
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m'       

extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.Z) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.jar) unzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is not a file."
fi
}

#------------------------------------------////
# System Information:
#------------------------------------------////
clear


echo -e "${red}Kernel Information: \t${cyan}" `uname -smr`
echo -e "${cyan}"; cal -3
echo -ne "${cyan}";fortune""  
malo srezan
devil
Postovi: 536
Pridružen/a: 13 ruj 2008, 17:35

Re: bashrc

Post Postao/la devil »

posto vec godinama ne koristm bash - moj .zshrc
http://pastie.org/1654484
prompt:
http://pastie.org/1654490
i kako to izgleda
http://ompldr.org/vN3FweA
Odgovori