All pastes #1876153 Raw Edit

loomsen

public shellscript v1 · immutable
#1876153 ·published 2010-06-02 18:47 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 grep='grep -i --color=auto'		alias fgrep='fgrep --color=auto'		alias egrep='egrep -i --color=auto'		alias lll='ls -alF'		alias ll='ls -lF'		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 ..='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'		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# 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 "`cut -d ' ' -f1 <(head -n1 /etc/issue)`" in		Fedora )						_PKGMNGR="$_PKGMNGR `which yum` "						;;		openSUSE )						_PKGMNGR="$_PKGMNGR `which zypper`"						;;		Debian|debian|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 MY_DIST# 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 modulesmoduleinfo(){	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 -    elif [ ${1##*.} = rpm ]    then	echo "(rpm archive file)"	rpmdev-extract -C /tmp $1; rm -rf /tmp/${1//.rpm}    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"; }## find the last/deepest subdirs in a given tree####deepest-subdirs() { find $PWD -type d -exec bash -c 'shopt -s nullglob; d=("$1"/*/); ((!${#d[@]}))' _ {} \; -print;}alias ompload='ompload.rb'alias terminator='terminator --working-dir=$HOME'# alias ich='echo $(grep uid <(gpg --list-keys loomsen)) | awk "{ print $2 " " $3 " " $4 }" 'alias date='date +"%a %b %d %Y"'alias ich='echo -e "* $(date) Norbert Varzariu <loomsen@googlemail.com>"'alias yul='sudo yum localinstall'