#!/bin/bash # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # my personal aliases file if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi if [ -f ~/.bash_lib ]; then . ~/.bash_lib fi ##################################################################### # # # NOTE: Dont export the stuff you put here! # # only stuff put in .bash_profile needs to be exported # # # ##################################################################### # Shell behavior and env variables # allow smart cd'ing PATH="$HOME"/local/bin:"$HOME"/local/dropbox:"$HOME"/bin:"$HOME"/android-sdk/tools:$HOME/local/opt/gauss:"$PATH" CDPATH="$PWD":"$HOME":"$HOME/rpmbuild" # pref text editor EDITOR=/usr/bin/nano # dont calculate possibilities on empty completion # shopt -s no_empty_cmd_completion # allow wildcards like: Music/**/*mp3 shopt -s globstar # giving a directory only, the shell assumes cd shopt -s autocd # no '$' required, enabled: cd HOME instead of cd $HOME shopt -s cdable_vars # shell history behavior shopt -s histappend #shopt -s histreedit #shopt -s histverify # History behavior and custom configs # general HISTFILESIZE=20M HISTSIZE=30000 HISTTIMEFORMAT="%d.%m.%y %H:%M @> " # how should we handle consecutive commands which are equal? # cd; cd; cd; will only add one occurence to history HISTCONTROL=ignoredups # above only applies to consecutive commands, here's # how to erase dups across the whole history HISTCONTROL=erasedups # skip inserting command to history by prepending a space character # HISTCONTROL=ignorespace # Default bash-completion insists on expanding ~/ __expand_tilde_by_ref() { true; } #!/bin/bash ## 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 ## 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" alias yue="echo $_PKGMNGR" fi unset _PKGMNGR MY_DIST gm_i() { dbus-send --print-reply --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong | \ sed -ne '/"\(artist\|title\|album\)"/ { s/string//p ;n; s/string//;p}' } foostack() { [[ -d "$HOME/tmp" ]] && TEMPDIR="$HOME/tmp" || TEMPDIR="/tmp" for ((i=1;i<10;i++)); do mkdir -p "$TEMPDIR/testdir/dir-$i" && touch $TEMPDIR/testdir/{dir-$i,.}/file-{1..9} done echo "Done, look into $TEMPDIR/testdir" } goog() { lynx -hiddenlinks=ignore -dump http://www.google.com/search?q="$1" } # check if a domain is registered isreg() { dig soa "$1" | grep -q ^$1 && echo "Yes" || echo "No" } yum_repolist() { echo "showing available packages in repo $1:" echo "======================================" repoquery -a --repoid="$1" } # make dir and change into it mkcd() { mkdir -p "$@" && cd "$@"; } get_my_pubkey() { gpg --recv-keys --keyserver pgp.mit.edu E7B20A8E } get_my_rpm_key() { rpm --import http://omploader.org/vMmwyZA/loomsen-pub.asc } # tarview tarview() { 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)" tar tvjf "$1" elif [ "${1##*.}" = "rpm" ] then echo "(rpm archive file)" # rpmdev-extract -C /tmp $1; rm -rf /tmp/${1//.rpm} rpm2cpio "$1" | cpio -t fi } createarchive() { if (( $# != 1 )); then tput bold echo -e "Usage:\t $FUNCNAME /path/to/folder" >&2 echo -e "resulting file will be created as folder.tar.bz2" >&2 tput sgr0 else local FOO="$(basename $1)" # use pbzip2 if available [[ -x /usr/bin/pbzip2 ]] && tar cvf "${FOO}.tar.bz2" --use-compress-prog=pbzip2 "${1}" \ || tar cvjf "${FOO}.tar.bz2" "${1}" (( $? == 0 )) && (tput bold; echo "$FUNCNAME: SUCCESS, created: ${FOO}.tar.bz2";tput sgr0) >&2 \ || (tput bold; echo "$FUNCNAME: ERROR: archive creation failed!";tput sgr0) >&2 fi } # add a new alias to curr shell and the ~/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_aliases eval alias "$name"=\'$value\' alias "$name" fi } # wiki from cli wiki() { dig +short txt ${1}.wp.dg.cx; } # cmdlinefu search cmdfu() { 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 } # modinfo - info of all loaded modules moduleinfo() { modinfo $(cut -d" " -f1 /proc/modules) | sed '/^dep/s/$/\n/; /^file\|^desc\|^dep/!d'; } ## 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;} ## browse() { perl -e 'use LWP::Simple; print for get(@ARGV)'; } gputemp() { nvidia-smi -q -a | awk '/Temperature/ {print $(NF-1)"°"$NF}'; } random_string() { head -n1 <( tr -dc 'a-zA-Z0-9' \n" >&2 printf "Example: $FUNCNAME 2 'echo hello'\n" >&2 tput sgr0 else for ((i=1; i<="$1"; i++)); do eval $2; done fi } fail() { printf " ▄██████████████▄▐█▄▄▄▄█▌\n" printf "██████▌▄▌▄▐▐▌███▌▀▀██▀▀ \n" printf "████▄█▌▄▌▄▐▐▌▀███▄▄█▌ \n" printf "▄▄▄▄▄██████████████ \n" } dice() { for ((i=1;i<=${1:-1};i++)); do head -n10 /dev/urandom | tr -dc '1-6' | cut -c1 done } toss() { for ((i=1;i<=${1:-1};i++)); do if (( $(head -n10 /dev/urandom | tr -dc '10' | cut -c1) == 0 )); then printf "heads\n" else printf "tails\n" fi done } #!/bin/bash ######################################## MEINE EINSTELLUNGEN # enable color support of ls and also add handy aliases if [ -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 --color=auto' alias ll='ls -lF --color=auto' 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='pygist' alias gmnext='gmusicbrowser -launch_or_cmd NextSong' alias lh='ls -d .*' 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 alias ich='echo -e "* $(\date +"%a %b %d %Y") Norbert Varzariu "' alias yul='sudo yum localinstall' alias copyright='echo -e "Copyright © $(\date +%Y) Norbert Varzariu "' alias net_open_ports='lsof -iTCP -sTCP\:LISTEN -P' alias ös='ls' alias gm_info='dbus-send --print-reply --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong' alias gm_play='dbus-send --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.RunCommand string:PlayPause' alias gm_time='dbus-send --print-reply --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.GetPosition' alias gm_next='dbus-send --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.RunCommand string:NextSong' ################################################# # COLORS # [\033[0;31m determines the text color—just change the numbers. # [\033[m turns off the colors, so that your commands and command output will return to the normal shell colors #black="\033[0;30m" #darkgrey="\033[1;30m" #blue="\033[0;34m" #lightblue="\033[1;34m" #green="\033[0;32m" #lightgreen="\033[1;32m" #cyan="\033[0;36m" #lightcyan="\033[1;3#6m" #red="\033[0;31m" #lightred="\033[1;31m" #purple="\033[0;35m" #lightpurple="\033[1;35m" #brown="\033[0;33m" #yellow="\033[1;33m" #lightgrey="\033[0;37m" #white="\033[1;37m" ##orange="\033[1;31m" #r_color="\033[0m" # Reset color #clr="\033[K" #clear to the end of the line ################################################## # ################################################## alias denied='tail -f -s3 /etc/hosts.deny' alias check_host='nmap -sT -PN -p 22 loomsen.kicks-ass.net' alias local_repo='createrepo -u $HOME/rpmbuild/RPMS $HOME/rpmbuild/RPMS' # Default bash-completion insists on expanding ~/ __expand_tilde_by_ref() { true; } alias wetter='curl http://weather.noaa.gov/pub/data/observations/metar/decoded/EDDH.TXT 2>/dev/null'