All pastes #1844168 Raw Edit

Something

public shellscript v1 · immutable
#1844168 ·published 2010-03-18 00:26 UTC
rendered paste body
#!/bin/bash######################################## MEINE EINSTELLUNGEN# enable color support of ls and also add handy aliasesif[ -x /usr/bin/dircolors ]; then	eval "`dircolors -b`"		alias ls='ls -h --color=auto'		alias dir='dir --color=auto'		alias vdir='vdir --color=auto'		alias grep='grep -i --color=auto'		alias fgrep='fgrep --color=auto'		alias egrep='egrep -i --color=auto'		#alias today=date +"%A, %B %-d, %Y"		# some more ls aliases		alias lll='ls -alF'		alias ll='ls -lF'		#alias ll='stat -c "%A  %a   %U:%G  %n" ?*'		alias lsd='ls -d */'		alias la='ls -ACF'		alias l='ls -CF'		alias ks='ls'		## Misc		alias logout='gnome-session-save --kill'		alias beedit='beesu gedit'		alias TV='DISPLAY=:0.1'		## Xorg		alias xcat='cat /etc/X11/xorg.conf'		alias xnano='sudo nano /etc/X11/xorg.conf'		alias xtree='nvidia-xconfig -c'		alias Xlog='cat /var/log/Xorg.0.log'		## Custom Misc,BU-/-RE		alias backup-deskmenu='cp ~/.config/compiz/deskmenu/menu.xml /opt/backups/Configurations/deskmenu/menu.xml'		alias restore-deskmenu='mkdir ~/.config/compiz/deskmenu && cp /opt/backups/Configurations/deskmenu/menu.xml ~/.config/compiz/deskmenu/menu.xml'		alias ..='cd ..'		alias ...='cd ../..'		alias cd..='cd ..'		alias du='du -h'		alias df='df -h'		alias pu='pushd'		alias po='popd'		alias srcbshrc='. "$HOME"/.bashrc'		##		alias mount='mount | column -t'		alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"'		alias pbin='paste2pastebin.pl'		alias gmnext='gmusicbrowser -launch_or_cmd NextSong'		alias lh='ls -a | egrep "^\."'		alias p='pstree -p'		alias -- +w='chmod a+w'		alias -- -w='chmod a-w'		alias -- +r='chmod a+r'		alias -- -r='chmod a-r'		alias -- +x='chmod a+x'		alias -- -x='chmod a-x'		# WAN IP		alias myip='curl icanhazip.com'fi## Packageprocessing_distissue="`cat /etc/issue`"# FIXME: this should probably be somewhere else as root doesn't read this file. somewhere inside the global bash definitions,## FIXME: make sure this is sourced by a shell	_PKGMNGR=	if [ $UID != "0" ];then 		_PKGMNGR="`which sudo` " 	fi	case "$_distissue" in		*Fedora*|*fedora*|*FEDORA* )						_PKGMNGR="$_PKGMNGR `which yum` "						;;		*suse*|*Suse*|*SuSE*|*SUSE* )						_PKGMNGR="$_PKGMNGR `which zypper`"						;;		*debian*|*Debian*|*ubuntu*|*Ubuntu* )						_PKGMNGR="$_PKGMNGR `which aptitude`"						;;		* )						_PKGMNGR=						;;	esac	# ====== DEBUG ============#	alias yue="echo $_PKGMNGR"	# =============================	## Define aliases for common commands if a package-manager exists	if [ "$_PKGMNGR" != "" ]; then		    alias yumi="$_PKGMNGR install"		    alias yup="$_PKGMNGR update"		    alias yurp="$_PKGMNGR remove"		    alias yus="$_PKGMNGR search"		    alias yusi="$_PKGMNGR info"	fi	unset _PKGMNGR _distissue# wiki from cliwiki() {	dig +short txt ${1}.wp.dg.cx}# cmdlinefu searchcmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }### duplicate file finder, based on size, then md5, can take long#dupesfind()#{#	find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | \#	xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-		repeated=separate#}# modinfo - info of all loaded modulesfunction moduleinfo {	modinfo $(cut -d" " -f1 /proc/modules) | sed '/^dep/s/$/\n/; /^file\|^desc\|^dep/!d'}## =============SSH================= 	##					##tar cXpf - /some/important/data | ssh user@destination-machine "tar xpf - -C /some/directory/"#rsync -a -e ssh source/ username@remotemachine.com:/path/to/destination/#					### =================================	## make dir and change into itmkcd () { mkdir -p "$@" && cd "$@"; }function get-my-pubkey {	gpg --recv-keys --keyserver pgp.mit.edu E7B20A8E}function get-my-rpm-key {	rpm --import http://omploader.org/vMmwyZA/loomsen-pub.asc}# tarviewtarview() {    echo -n "Displaying contents of $1 "    if [ ${1##*.} = tar ]    then        echo "(uncompressed tar)"         tar tvf $1    elif [ ${1##*.} = tgz ]    then	echo "(gzip-compressed tar)"	tar tvf $1    elif [ ${1##*.} = gz ]    then        echo "(gzip-compressed tar)"        tar tzvf $1    elif [ ${1##*.} = bz2 ]    then        echo "(bzip2-compressed tar)"        cat $1 | bzip2 -d | tar tvf -    fi}createarchive() {	if [ $# -lt 2 ]; then		echo -e "\nUSAGE:#=> \t "$FUNCNAME" foobar  folder/ \ndefaults to -cvjf (bz2 compressed archive) => foo.tar.bz2"	else		tar cvjf "$1.tar.bz2" "$2"	fi}# add a new alias to curr shell and the ~/bash.bash_aliases file.add_alias () {	if [ $# -lt 2 ]; then		echo -e "\nUSAGE:#=> \t add_alias  mynewalias  \"some very long command\""	else		local name=$1 value="$2"		echo alias $name=\'$value\' >>~/bash.bash_aliases		eval alias $name=\'$value\'		alias $name	fi}myDebugFkt () { echo -e "i'm a function in $_ and my name is $FUNCNAME";}#function repo_update {	REPO="/var/www/mrepo/fc12-x86_64"	SUBD[1]="$REPO/SRPMS"	SUBD[2]="$REPO/RPMS/x86_64"	SUBD[3]="$REPO/RPMS/noarch"	i=1		while [ "$i" -le 3 ]; do 		createrepo --database --unique-md-filenames --update "${SUBD[i]}"		 i=`expr "$i" + 1 `	done}### find the last/deepest subdirs in a given tree## example:#	loom@desktop […tmp/foo] tree#		├── bar#		│   └── 1st#		│       └── 2nd			#=> match#		├── baz#		│   ├── ist			#=> match#		│   └── jid				#		│       ├── d-1			#		│       │   └── bla			#=> match#		│       └── d-2			#=> match#		└── foosen		#=> match####deepest-subdirs() { find $PWD -type d -exec bash -c 'shopt -s nullglob; d=("$1"/*/); ((!${#d[@]}))' _ {} \; -print;}