diff options
Diffstat (limited to '.zsh.after')
-rw-r--r-- | .zsh.after/aliases.zsh | 228 | ||||
-rw-r--r-- | .zsh.after/apt | 37 | ||||
-rw-r--r-- | .zsh.after/export.zsh | 49 | ||||
-rw-r--r-- | .zsh.after/frqrec | 0 | ||||
-rw-r--r-- | .zsh.after/functions.zsh | 414 | ||||
-rw-r--r-- | .zsh.after/hostspecific.zsh | 6 | ||||
-rw-r--r-- | .zsh.after/key-bindings.zsh | 22 | ||||
-rw-r--r-- | .zsh.after/prompt.zsh | 2 | ||||
-rw-r--r-- | .zsh.after/sources.zsh | 6 | ||||
-rw-r--r-- | .zsh.after/udisks.zsh | 245 | ||||
-rw-r--r-- | .zsh.after/unixpool | 125 |
11 files changed, 1134 insertions, 0 deletions
diff --git a/.zsh.after/aliases.zsh b/.zsh.after/aliases.zsh new file mode 100644 index 0000000..6c0395f --- /dev/null +++ b/.zsh.after/aliases.zsh @@ -0,0 +1,228 @@ +# < ZSH ALIASES +## EXTENSIONS +alias -s pdf='mupdf' +alias -s ps='mupdf' +alias -s jpg='feh' +alias -s png='feh' +alias -s gif='viewnior' +alias -s gz='tar xvfz' +alias -s tgz='tar xvfz' +alias -s bz2='tar xvfj' +alias -s tbz='tar xvfj' +alias -s tlz='tar --lzma -xvf' +alias -s rar='unrar x' +alias -s tex='mkpdf' + +##LS +alias ls='ls --group-directories-first --color=auto' +alias ll="ls -lh" +alias la="ls -a" +alias lal="ls -alh" +alias ls='ls --group-directories-first --color=auto' +alias l='ls' +alias lt='ls -tr' +alias ll='ls -l' +alias llh='ls -lh' +alias llt='ls -ltr' +alias la='ls -A' +alias lla='ls -lA' +alias lsfw='ls -lah /dev|grep fw' +alias lsvid='ls -lah /dev|grep video' + +#MPLAYER +alias mplayer='mplayer -ao jack,pulse,alsa' + +##DU +alias du1='du -hd1' + +##FEH +alias feh='feh -Z -g 1920x1200 -b "black" -S "filename"' + +##GIT +alias gsi='git submodule update --init --recursive' +alias gsu='git submodule update --recursive' + +##TREE +alias tree='tree -aC' +#grep aliases (with excluded directories) +alias grepdot='grep -rI --exclude-dir=".steam" --exclude-dir=".local" --exclude-dir=".thunderbird" --exclude-dir=".mozilla" --exclude-dir="git" --exclude-dir=".rvm" --exclude-dir=".log" --exclude-dir=".dropbox-dist" --exclude-dir=".config" ' + + +##SYSTEMD +#tree +alias psc='ps xawf -eo pid,user,cgroup,args' +alias treeg='tree -d /cgroup/systemd/' +alias sdptree='tree -aC /usr/lib/systemd/' +alias sdstree='tree -aC /etc/systemd/' +alias sdutree='tree -aC $HOME/.config/systemd/' +#journalctl +alias sdj='sudo journalctl' +alias sdjf='sudo journalctl -f' #Follow the messages +alias sdjb='sudo journalctl -b' #Show only messages from this boot +alias sdju='sudo journalctl -u' #Show messages of only the specified unit +alias sdjk='journalctl _TRANSPORT=kernel' #Show kernel ring buffer +alias sdjp='sudo journalctl _PID=' #Show all messages of specified process (PID) +alias sdjgrep='sudo journalctl -an1000 |grep ' #Use a grep command to search through journal +#systemd system services +alias sdsstart='sudo systemctl start' +alias sdsstop='sudo systemctl stop' +alias sdsrestart='sudo systemctl restart' +alias sdsreload='sudo systemctl reload' +alias sdsenable='sudo systemctl enable' +alias sdsdisable='sudo systemctl disable' +alias sdsreenable='sudo systemctl reenable' +alias sdsisactive='sudo systemctl is-active' +alias sdsisenabled='sudo systemctl is-enabled' +alias sdsstat='sudo systemctl status --all --full' +alias sdswants='sudo systemctl show -p "Wants"' +alias sdswantedby='sudo systemctl show -p "WantedBy"' +alias sdsrequires='sudo systemctl show -p "Requires"' +alias sdsrequiredby='sudo systemctl show -p "RequiredBy"' +alias sdsconflicts='sudo systemctl show -p "Conflicts"' +alias sdsconflictedby='sudo systemctl show -p "ConflictedBy"' +alias sdsbefore='sudo systemctl show -p "Before"' +alias sdsafter='sudo systemctl show -p "After"' +alias sdst='sudo systemctl list-timers' +alias sdsreload='sudo systemctl daemon-reload' +alias sds='sudo systemctl --all' +alias sdserr='sudo systemctl --all --full |grep error' +alias sdsfail='sudo systemctl --all --full |grep failed' +alias sdsmask='sudo systemctl mask' +alias sdsunmask='sudo systemctl unmask' +#systemd user services +alias sdustart='systemctl --user start' +alias sdustop='systemctl --user stop' +alias sdurestart='systemctl --user restart' +alias sdureload='systemctl --user reload' +alias sduenable='systemctl --user enable' +alias sdudisable='systemctl --user disable' +alias sdureenable='systemctl --user reenable' +alias sduisactive='systemctl --user is-active' +alias sduisenabled='systemctl --user is-enabled' +alias sdustat='systemctl --user status --all --full' +alias sduwants='systemctl --user show -p "Wants"' +alias sduwantedby='systemctl --user show -p "WantedBy"' +alias sdurequires='systemctl --user show -p "Requires"' +alias sdurequiredby='systemctl --user show -p "RequiredBy"' +alias sduconflicts='systemctl --user show -p "Conflicts"' +alias sduconflictedby='systemctl --user show -p "ConflictedBy"' +alias sdubefore='systemctl --user show -p "Before"' +alias sduafter='systemctl --user show -p "After"' +alias sdut='systemctl --user list-timers' +alias sdureload='systemctl --user daemon-reload' +#alias sdu='systemctl --user' +alias sduerr='systemctl --user --all --full |grep error' +alias sdufail='systemctl --user --all --full |grep failed' +alias sdumask='sudo systemctl --user mask' +alias sduunmask='sudo systemctl --user unmask' +#poweroff/reboot/isolate +alias sdiso='sudo systemctl isolate ' +alias sdreboot='sudo systemctl reboot' +alias sdpoweroff='sudo systemctl poweroff' +alias sdsuspend='sudo systemctl suspend' +#systemd bootchart +alias sda='systemd-analyze' +alias sdab='systemd-analyze blame' +if [ -x /usr/bin/xsvg ]; then + alias sdap='xsvg $HOME/ownCloud/photos/systemd/sdap-$HOST.svg' +fi + +##PACMAN +alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" +alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #Show all packages by size +alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size +alias pacup='sudo pacman -Syu' #Synchronize with repositories before upgrading packages that are out of date on the local system. +alias pac='sudo pacman -S' #Install specific package(s) from the repositories +alias pacu='sudo pacman -U' #Install specific package not from the repositories but from a file +alias pacre='sudo pacman -R' #Remove the specified package(s), retaining its configuration(s) and required dependencies +alias pacrem='sudo pacman -Rns' #Remove specified package(s), its configuration(s) and unneeded depends +alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep " #Search through all available packages in repo +alias pacname="sudo pacman -Qi|grep Name|grep " #Search through names of packages by string +alias pacri='pacman -Si' #Display information about a given package in the repositories +alias pacrs='pacman -Ss' #Search for package(s) in the repositories +alias pacli='pacman -Qi' #Display information about a given package in the local database +alias pacls='pacman -Qs' #Search for package(s) in the local database +alias pacorph='sudo pacman -Qdt' #Search for orphan packages +alias paclal='sudo pacman -Ql' #List installed files of a given package +alias pacg='pacman -Sg' #List all groups or all packages in specified group +alias pacclean='sudo pacman -Sc' #Remove all packages from local repository, not installed atm, remove all unused repos +alias pacconf='sudo find /etc -name "*.pac*" -type f -print' #Search for .pacnew and .pacsave files +alias pacfile='sudo pacman -Qo' # Find out what package a give file belongs to +alias pacupd='sudo pacman -Sy && sudo abs' #Update and refresh the local package and ABS databases against repositories +alias pacdep='sudo pacman -S --asdeps' #Install given package(s) as dependencies of another package +alias pacmir='sudo pacman -Syy' #Force refresh of all package lists after updating /etc/pacman.d/mirrorlist +alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' #Backup the current list of non-local packages +alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' #Install from the backup list +alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' #Redownload all installed packages (minus AUR) +alias pacdis='sudo pacman-disowned > /tmp/$USERNAME/non-pkg-$HOST' #Getting a list of files not owned by any package +alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring +alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring +alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys + +##YAOURT +alias yaup='yaourt -Syu --devel --aur' #Updates all locally installed repository, AUR and git packages +alias yadb='yaourt -B $HOME/ownCloud/backup/settings/' #Backs up the yaourt database + +##XCLIP +alias cpx="xclip -selection clipboard -display :0" + +##CD +alias cd.sds="cd /etc/systemd/system" +alias cd.sdp="cd /usr/lib/systemd/system" +alias cd.courses="cd $HOME/ownCloud/documents/university/tu-berlin/courses" +alias cd.backup="cd $HOME/ownCloud/backup" +alias cd.scpref="cd $HOME/.config/SuperCollider" + +##OCTAVE +#alias octave="octave --silent --braindead --force-gui" +alias octave="octave --force-gui" + +##MATLAB +alias matlabc="matlab -nodesktop -nosplash" + +##NMCLI +alias nmup="sudo nmcli con up id" +alias nmdown="sudo nmcli con down id" +alias nmstat="sudo nmcli con show --active" +alias nmlist="sudo nmcli con list" +alias nmdev="sudo nmcli dev" + +#SSH +alias pool='ssh pool -Y' +alias sshtunnel="ssh -ND 44350 -v -p 46399 dave@frqb.zapto.org" # tunnel through home +alias frqtun="ssh -ND 44350 -v frq" +alias scp=scp + +#KEYCHAIN +alias keyflush="keychain --clear && keychain -k mine" + +#PULSEAUDIO +alias pak='pulseaudio --kill' +alias pas='pulseaudio --start' +alias paflush='pax11publish -r' +alias bthp="pactl load-module module-bluetooth-device address='00:1B:66:01:6C:D1'" #load bluetooth headphone module for pulseaudio + +#PYTHON +alias pyserv='python -m http.server' # start a python http server + +# VDIRSYNCER +alias vsync="vdirsyncer sync" + +#WOL +alias woldave_in='wol -i homey 00:15:f2:e0:e0:c6' #wake up homey +alias woldave_ex='wol -p X -i frqb.zapto.org 00:15:f2:e0:e0:c6' #wake up homey via + +## OVERRIDES +# Colorize grep output +alias grep='grep --color=auto --exclude-dir=.git' +alias psgrep='ps aux | grep -v "grep"| grep $1' +alias greptodo='grep -R "TODO" .' +alias exit="clear; exit" +alias du='du -h' +alias .='source' + + +## HELP +alias helpdd='echo dd if=bla | pv -s 10M | dd of=blob' + +# ZSH ALIASES > diff --git a/.zsh.after/apt b/.zsh.after/apt new file mode 100644 index 0000000..e1942cf --- /dev/null +++ b/.zsh.after/apt @@ -0,0 +1,37 @@ +#TODO: add pacman to apt-get conversion for all pacman aliases +alias paclid="sudo pacman -Qi | sed '/^Depends On/,/^Required By/{ s/^Required By.*$//; H; d }; /^Name/!d; /^Name/{ n;x;}'| sed '/^$/s//==================================================================================/'" +alias pacsize="pacman -Qi | awk '/^Name/ {pkg=\$3} /Size/ {print \$4\$5,pkg}' | sort -n" #All packages by size +alias pacall="sudo pacman -Qi | awk '/^Name/ {pkg=\$3} /Version/ {ver=\$3} /Size/ {size=\$4\$5} {print pkg,ver,size}' | uniq" #All packages uniquely with name, version, size +#alias pacremorph='sudo pacman -Rs $(pacman -Qtdq)' #Remove all orphaned packages +alias pacup='sudo apt-get update && sudo apt-get upgrade' #'sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system. +alias pac='sudo apt-get install ' #'sudo pacman -S' # Install specific package(s) from the repositories +alias pacu='sudo pacman -U' # Install specific package not from the repositories but from a file +alias pacre='sudo apt-get remove ' #'sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required ##dependencies +alias pacrem='sudo apt-get purge ' #'sudo pacman -Rns' # Remove specified package(s), its configuration(s) and unneeded depends +alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep " # Search through all available packages in repo +#alias pacname='dpkg -l|grep Name|grep ' #'sudo pacman -Qi|grep Name|grep ' #Search through names of packages by string +alias pacri='sudo apt-get update && sudo apt-cache show ' #'pacman -Si' # Display information about a given package in the repositories +alias pacrs='sudo apt-get update && sudo apt-cache search ' #'pacman -Ss' # Search for package(s) in the repositories +alias pacli='dpkg -l ' #'pacman -Qi' # Display information about a given package in the local database +alias pacls='dpkg -l|grep ' #'pacman -Qs' # Search for package(s) in the local database +alias pacorph='sudo pacman -Qdt' # Search for orphan packages +alias paclal='dpkg -L' #'sudo pacman -Ql' # List installed files of a given package +alias pacg='pacman -Sg' #List all groups or all packages in specified group +alias pacclean='sudo pacman -Sc' # Remove all packages from local repository, not installed atm, remove all unused repos +alias pacconf='sudo find /etc -name "*.pac*" -type f -print' # Search for .pacnew and .pacsave files +alias pacfile='dpkg -S ' #'sudo pacman -Qo' # Find out what package a give file belongs to +alias pacupd='sudo apt-get update' #'sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories +alias pacdep='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package +alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist +alias packup='comm -23 <(pacman -Qeq|sort) <(pacman -Qmq|sort) > $HOME/Dropbox/sync/archlinux/pkglist-$HOST' # Backup the current list of non-local packages +alias pacret='sudo pacman -S $(< $HOME/Dropbox/sync/archlinux/pkglist-$HOST)' # Install from the backup list +alias pacredown='sudo pacman -S $(comm -23 <(pacman -Qeq) <(pacman -Qmq))' # Redownload all installed packages (minus AUR) +alias pacdis='rm -f $HOME/Dropbox/sync/archlinux/non-pkg-$HOST; sudo pacman-disowned > $HOME/Dropbox/sync/archlinux/non-pkg-$HOST' # Getting a list of files not owned by any package +alias packimp='sudo pacman-key -r ' #Import a key ID to the pacman keyring +alias packsign='sudo pacman-key --lsign-key ' #Sign a key ID after importing it to the keyring +alias packref='sudo pacman-key --refresh-keys' #Refresh the list of master keys + +##Yaourt aliases +alias yaup='yaourt -Syu --devel --aur' # Updates all locally installed repository, AUR and git packages +alias yadb='yaourt -B $HOME/Dropbox/sync/archlinux' # Backs up the yaourt database +alias ya='sudo apt-get -t testing install ' # Install packages from AUR/Testing diff --git a/.zsh.after/export.zsh b/.zsh.after/export.zsh new file mode 100644 index 0000000..866f20d --- /dev/null +++ b/.zsh.after/export.zsh @@ -0,0 +1,49 @@ +# use xterm-color anywhere. Sane default for color and termite +if [[ -n $TMUX ]];then + export TERM="screen-256color" +else + export TERM="xterm-color" +fi +# use de_DE.UTF-8 to get 24h format +export LC_TIME=de_DE.UTF-8 + +# browser +export BROWSER=firefox +export REPORTTIME=5 + +# if vimpager is installed, use it instead of less +if [[ -x /usr/bin/vimpager ]];then + export PAGER="vimpager" +else + export PAGER="less -j4" +fi + +export GREP_COLOR="1;33" + +# let RVM ignore global ruby +export rvm_ignore_gemrc_issues=1 + +# Java +# font settings/ renderings +export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true' +# non-reparenting windows +export _JAVA_AWT_WM_NONREPARENTING=1 + +# GnuPG +export GPG_TTY=$(tty) +export GPG_AGENT_INFO="" + +# ssh-agent +export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" + +# tmux +if [[ $UID -ne 0 ]]; then + export TMUX_TMPDIR="$XDG_RUNTIME_DIR/tmux/" +fi + +# zsh +if [[ $UID -eq 0 ]]; then + export TMOUT=360 + readonly TMOUT + export TMOUT +fi diff --git a/.zsh.after/frqrec b/.zsh.after/frqrec new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.zsh.after/frqrec diff --git a/.zsh.after/functions.zsh b/.zsh.after/functions.zsh new file mode 100644 index 0000000..deb47ed --- /dev/null +++ b/.zsh.after/functions.zsh @@ -0,0 +1,414 @@ +# < FUNCTIONS + +## BACKUP + function etcbackup() { + BACKUPDIR=$HOME/dropbox/backup + HOSTNAME=$(hostname) + FILE=$1 + + if [ -f $FILE ] + then + FILENAME=$(echo $FILE | sed 's/\///' | sed 's/\//_/g') + cp -v $FILE $BACKUPDIR/$HOSTNAME/$FILENAME + else + echo $FILE does not exist + fi + } + +## DOTFILES + function update_dot() { + for i in $HOME/dropbox/dot/[a-zA-Z]*; + do + if [ -f $i ]; + then + echo file $i + base=`basename $i` + dst=$HOME/.$base + bak=$HOME/.${base}_bak + + case $base in + vimrc|zshrc|*tgz) + echo nothing $i + ;; + *) + if [ -L $dst ]; + then + rm $dst + else + mv $dst $bak + fi + ln -s $i $dst + ;; + esac + + else + if [ -d $i ]; + then + echo dir $i + base=`basename $i | sed 's/_/\//'` + dst=$HOME/.$base + bak=$HOME/.${base}_bak + + case $base in + "vim") + echo nothing $i + ;; + *) + if [ -e $dst ]; + then + if [ -L $dst ]; + then + rm $dst + else + mv $dst $bak + fi + fi + ln -s $i $dst + ;; + esac + else + echo unknown $i + fi + fi + done + } + +## PDF/LATEX + function mkpdf() + { + pdflatex -shell-escape $1 + # latex --output-format=pdf $1 + name=`echo $1 | sed 's/.tex//'` + EXT=(aux log) + for i in $EXT; + do + rm -v $name.$i + done + } + + function gsmerge() + { + target=$1 + echo "target: $target" + sleep 1 + shift + + /usr/bin/gs \ + -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dNOPAUSE \ + -dBATCH \ + -sPAPERSIZE=a4 \ + -sOUTPUTFILE=$target $* + } + + function gsmerge_medium() + { + target=$1 + echo "target: $target" + sleep 1 + shift + + /usr/bin/gs \ + -sDEVICE=pdfwrite \ + -dPDFSETTINGS=/ebook \ + -dCompatibilityLevel=1.4 \ + -dNOPAUSE \ + -dBATCH \ + -sPAPERSIZE=a4 \ + -sOutputFile=$target $* + } + +## USABILITY + function lvim() + { + noglob vim $(echo $1 | awk -F":" '{ print $1" +"$2 }' ) + } + + function mkcd() + { + mkdir $1 + cd $1 + } + + function cpwd() + { + pwd >! /tmp/pwd + } + + function ppwd() + { + cd "`cat /tmp/pwd`" + } + + function cp2wd() + { + cp $@ "`cat /tmp/pwd`" + } + function cpmk() { + DIR=${*: -1} + [ ! -d $DIR ] && mkdir -p $DIR + cp $* + + } + + cpmd5(){ + md5sum $1|cut -d ' ' -f 1|cpx + } + + +function publish() { + [ -f $1 ] || return + + DIR=`dirname $1` + FILE=`basename $1` + mute pushd $DIR + scp $FILE pool:public_html/ + echo "http://www-pool.math.tu-berlin.de/~runge/$FILE" + echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|cpx + mute popd +} + +function securium { + port=44350 + chromium --proxy-server="socks://localhost:$port" & + exit +} + +## ZSH +refresh() { + source $HOME/.zshrc +} + + +## compress stuff +tar_tgz() { + tar cvfz $1.tgz $1 +} +tar_tbz() { + tar cvfj $1.tbz $1 +} +tar_tlz() { + tar --lzma -cvf $1.tlz $1 +} +tar_xz() { + tar cvfJ $1.tar.xz $1 +} + +#Decompress any given compressed file +ex() { +if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.deb) ar vx $1 + ;; + *.rar) unrar x $1 ;; + *.pgp) gpg -o ${1%".pgp"} -d $1 ;; + *.gpg) gpg -o ${1%".gpg"} -d $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; + *.xz) tar xvJf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "don't know how to extract '$1'..." ;; + esac +else + echo "'$1' is not a valid file!" +fi +} + +ex2() { + if [ -f $2 ] ;then + echo "Extracting to '$2'" + local out = $2 + else + echo "Extracting to '$( pwd )'" + local out = $( pwd ) + fi + if [ -f $1 ] ;then + echo "'$1'" + else + echo "'$1' is not a valid file!" + fi +} + + + + +##CRYPTSETUP AND LUKS +#TODO: Add possibility of opening/closing multiple devices at once +lopen() { + case $HOST in + "homey") + case $1 in + "video-backup") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400797" $1 + ;; + "video") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400798" $1 + ;; + "photos") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FQ104574" $1 + ;; + "music") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FPB87663" $1 + ;; + "music-external") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" $1 + ;; + "photos-external") + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE457TN" $1 + ;; + esac + ;; + "dvzrv" | "trvlr") + case $1 in + "music") + if [ -L "/dev/disk/by-uuid/e0b19c7d-9e90-4117-aea1-7e4b321d9d5a" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-uuid/e0b19c7d-9e90-4117-aea1-7e4b321d9d5a" $1 + elif [ -L "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" $1 + elif [ -L "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE36KXD-0:0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE36KXD-0:0" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + "photos") + if [ -L "/dev/disk/by-uuid/b3c5a842-474b-4c2f-a246-abebe1da3450" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-uuid/b3c5a842-474b-4c2f-a246-abebe1da3450" $1 + elif [ -L "/dev/disk/by-id/ata-ST9500325AS_6VE457TN " ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE457TN" $1 + elif [ -L "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE4LCR0-0:0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE4LCR0-0:0" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + "backup-audio") + if [ -L "/dev/disk/by-id/usb-HGST_HTS_725050A7E630_801130168383-0:0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-HGST_HTS_725050A7E630_801130168383-0:0" $1 + elif [ -L "/dev/disk/by-id/ata-HGST_HTS725050A7E630_TF755AWHHS9S1M" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-HGST_HTS725050A7E630_TF755AWHHS9S1M" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + "backup") + if [ -L "/dev/disk/by-id/usb-ST950042_0ASG_55DFFFFFFFFF-0:0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-ST950042_0ASG_55DFFFFFFFFF-0:0" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + "media") + if [ -L "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80088G0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80088G0" $1 + elif [ -L "/dev/disk/by-uuid/e5adbc14-732e-43e8-b6e1-febdfe6d1d3c" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-uuid/e5adbc14-732e-43e8-b6e1-febdfe6d1d3c" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + "video") + if [ -L "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80092WW" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80092WW" $1 + elif [ -L "/dev/disk/by-uuid/5ac700be-e168-495b-b133-42064fa101e4" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-uuid/5ac700be-e168-495b-b133-42064fa101e4" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi + ;; + *) + echo "Error! Device $1 is not available" + exit 1 + ;; + esac + esac + if [[ -e "/dev/mapper/$1" ]]; then + sudo mount /dev/mapper/$1 /mnt/$1 + if [ $1 = "media" ]; then + sudo mount --bind /mnt/media/music /mnt/music + sudo mount --bind /mnt/media/photos /mnt/photos + if [ ! -h ~/.cache/shotwell ]; then + ln -s /mnt/photos/shotwell/ ~/.cache/shotwell + fi + fi + else + echo "Error: Device /dev/mapper/$1 is not available." + exit 1 + fi +} + +lclose() { + notmounted=$(mountpoint /mnt/$1) + if [ "$?" -eq 0 ]; then + #stop services blocking the umount + if [[ $HOST == "homey" ]]; then + sudo systemctl stop rpc-{idmapd,mountd} rpcbind + fi + if [ $1 = "media" ]; then + sudo umount /mnt/{music,photos} + fi + sudo umount /mnt/$1 + sudo cryptsetup luksClose $1 + #restart services that blocked the umount + if [[ $HOST == "homey" ]]; then + sudo systemctl start rpc-{idmapd,mountd} rpcbind + fi + else + echo "/mnt/$1 is not a mountpoint or not mounted." + fi +} + +## RSYNC + +backupinfo() { + log_cyan "INFO" + rsync\ + -r\ + -n\ + -t\ + -p\ + -o\ + -g\ + -v\ + --progress\ + --delete\ + --ignore-existing\ + --size-only\ + -s\ + --exclude 'lost+found'\ + --exclude '.Trash-1000'\ + --exclude '$RECYCLEBIN'\ + --exclude 'System Volume Information'\ + --exclude '.thumbs'\ + $1 $2 + echo "backupfolder path/to/folder/ /path/to/other/folder" +} + +backupfolder() { + rsync \ + -r\ + -t\ + -p\ + -o\ + -g\ + -v\ + --progress\ + --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' $1 $2 +} + + +# FUNCTIONS > diff --git a/.zsh.after/hostspecific.zsh b/.zsh.after/hostspecific.zsh new file mode 100644 index 0000000..e088543 --- /dev/null +++ b/.zsh.after/hostspecific.zsh @@ -0,0 +1,6 @@ +case $(hostname) in + s4|s5|c*) + . $HOME/.zsh.after/apt + . $HOME/.zsh.after/unixpool + ;; +esac diff --git a/.zsh.after/key-bindings.zsh b/.zsh.after/key-bindings.zsh new file mode 100644 index 0000000..300b3c7 --- /dev/null +++ b/.zsh.after/key-bindings.zsh @@ -0,0 +1,22 @@ +## OVERRIDE KEY-BINDINGS +bindkey -s '\e,' '..\n' # [Esc-,] - run command: .. (up directory) +bindkey '\e.' insert-last-word # [Esc-.] - insert last word +#bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word +#bindkey '^[OC' forward-word # [Ctrl-RightArrow] - move forward one word +#bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word +#bindkey '^[OD' backward-word # [Ctrl-LeftArrow] - move backward one word + +## URXVT & TMUX +case $TERM in + rxvt-unicode-256color) + bindkey '^[Oc' forward-word # [Ctrl-RightArrow] - move forward one word + bindkey '^[Od' backward-word # [Ctrl-LeftArrow] - move backward one word + ;; + screen-256color) + bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - tmux: move forward one word + bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - tmux: move backward one word + ;; +esac + +## NEW KEY-BINDINGS +bindkey '^K' kill-line diff --git a/.zsh.after/prompt.zsh b/.zsh.after/prompt.zsh new file mode 100644 index 0000000..46c9f36 --- /dev/null +++ b/.zsh.after/prompt.zsh @@ -0,0 +1,2 @@ +prompt dvzrv + diff --git a/.zsh.after/sources.zsh b/.zsh.after/sources.zsh new file mode 100644 index 0000000..7140d78 --- /dev/null +++ b/.zsh.after/sources.zsh @@ -0,0 +1,6 @@ +# Source RVM +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" + +# RVM bash completion +[[ -r "$HOME/.rvm/scripts/completion" ]] && source "$HOME/.rvm/scripts/completion" + diff --git a/.zsh.after/udisks.zsh b/.zsh.after/udisks.zsh new file mode 100644 index 0000000..3478aea --- /dev/null +++ b/.zsh.after/udisks.zsh @@ -0,0 +1,245 @@ +# EXAMPLES: +# - mounting devices +# sdm sdb1 // mount first partition on sdb +# sdm sdb 1 // mount first partition on sdb +# sdm sdb // mount all available partitions on sdb +# sdm // mount all available devices +# mcm mmcblk0p1 // mount first partition on mmcblk0 +# mcm mmcblk0 1 // mount first partition on mmcblk0 +# mcm mmcblk0 // mount all partitions on mmcblk0 +# mcm // mount all partitions on all mmcblk devices +# srm 0 // mount first optical drive +# srm // mount all optical drives +# +# - unmounting devices +# sdu sdb1 // unmount first partition on sdb +# sdu sdb 1 // unmount first partition on sdb +# sdu sdb // unmount all available partitions on sdb +# sdu // unmount all available devices +# mcu mmcblk0p1 // unmount first partition on mmcblk0 +# mcu mmcblk0 1 // unmount first partition on mmcblk0 +# mcu mmcblk0 // unmount all partitions on mmcblk0 +# mcu // unmount all partitions on all mmcblk devices +# sru 0 // unmount first optical drive +# sru // unmount all optical drives +# + +# mount commands: +mount="udisksctl mount -b" +unmount="udisksctl unmount -b" + +# Path to all devices +folder="/dev/" + +# Devices of the form /dev/sd{b,c,d,e,f,g,h,i,j,k,l,m,n} +# path +dev="/dev/sd" +# Device numbers/names +devices=( b c d e f g h i j k l m n ) +# Partition numbers +device_partitions=( 1 2 3 4 5 6 7 8 9 ) + +# Devices of the form /dev/mmcblk{0,1,2,3,4,5,6,7,8,9}p{1,2,3,4,5,6,7,8,9} +# path +mmc="/dev/mmcblk" +# Device numbers/names +mmc_devices=( 0 ) +# Partition numbers +mmc_partitions=( p1 p2 p3 p4 p5 p6 p7 p8 p9 ) + +# Devices of the form /dev/sr{0,1,2} +# path +optical="/dev/sr" +# Device numbers/names +optical_devices=( 0 1 2 ) + +# device functions: +sdm() { + if [[ -n "$2" ]]; then # if 2nd argument is set + if [[ "$1" = ?d* ]]; then # check if 1st argument features the letter d + if [[ -b $folder$1$2 ]]; then # check if block device $1$2 is available + $=mount $folder$1$2 + fi + fi + elif [[ -n "$1" ]]; then # if 1st argument is set + if [[ "$1" = ?d* ]]; then # check if 1st argument featurs a letter d + if [[ -b $folder$1"1" ]]; then #check if first device is available + for a in $device_partitions; do # loop through device partitions of first argument + echo "$folder$1$a" + if [[ -b $folder$1$a ]]; then # checking for each device if available and block device + $=mount "$folder$1$a" + fi + done + else + echo "Trying to mount: $folder$1" + if [[ -b $folder$1 ]]; then # check if 1st argument already is the block device to mount + $=mount $folder$1 + fi + fi + fi + else # here we loop all available block devices and mount them + # TODO: check with df if the device is already mounted + for a in $devices; do # loop through the list of all devices + if [[ -b $dev$a ]]; then # check if first partition of block device is available + for b in $device_partitions; do # loop through the list of all partitions + if [[ -b $dev$a$b ]]; then # if it's a block device + echo "Trying to mount: $dev$a$b" + $=mount "$dev$a$b" + fi + done + fi + done + fi +} + +sdu() { + if [[ -n "$2" ]]; then + if [[ "$1" = ?d* ]]; then + if [[ -b $folder$1$2 ]]; then + echo "Trying to unmount: $folder$1$2" + $=unmount $folder$1$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = ?d* ]]; then + if [[ -b $folder$1"1" ]]; then + for a in $device_partitions; do + if [[ -b $folder$1$a ]]; then # checking for each device if available and block device + echo "Trying to unmount: $folder$1$a" + $=unmount $folder$1$a + fi + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to unmount: $folder$1" + $=unmount $folder$1 + fi + fi + fi + else # unmount all devices mounted + for a in $devices; do + if [[ -b $dev$a ]]; then + for b in $device_partitions; do + if [[ -b $dev$a$b ]]; then # if it's a block device + echo "Trying to unmount: $dev$a$b" + $=unmount $dev$a$b + fi + done + fi + done + fi +} + +# mmc functions: +mcm() { + if [[ -n "$2" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p"$2 ]]; then + echo "Trying to mount: $folder$1"p"$2" + $=mount $folder$1"p"$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p1" ]]; then + for a in $mmc_partitions; do + if [[ -b $folder$1$a ]]; then + echo "Trying to mount: $folder$1$a" + $=mount $folder$1$a + fi + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to mount: $folder$1" + $=mount $folder$1 + fi + fi + fi + else + for a in $mmc_devices; do + if [[ -b $mmc$a"p1" ]]; then + for b in $mmc_partitions; do + if [[ -b $mmc$a$b ]]; then # if it's a block device + echo "Trying to mount: $mmc$a$b" + $=mount $mmc$a$b + fi + done + fi + done + fi +} + +mcu() { + if [[ -n "$2" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p"$2 ]]; then + echo "Trying to unmount: $folder$1"p"$2" + $=unmount $folder$1"p"$2 + fi + fi + elif [[ -n "$1" ]]; then + if [[ "$1" = mmcblk* ]]; then + if [[ -b $folder$1"p1" ]]; then + for a in $mmc_partitions; do + echo "Trying to unmount: $folder$1$a" + $=unmount $folder$1$a + done + else + if [[ -b $folder$1 ]]; then + echo "Trying to unmount: $folder$1" + $=unmount $folder$1 + fi + fi + fi + else + for a in $mmc_devices; do + if [[ -b "$mmc$a${mmc_partitions[0]}" ]]; then + echo $mmc$a${mmc_partitions[0]} + for b in $mmc_partitions; do + if [[ -b $mmc$a$b ]]; then # if it's a block device + echo "Trying to unmount: $mmc$a$b" + $=unmount $mmc$a$b + fi + done + fi + done + fi +} + +# sr functions: +srm() { + if [[ -n "$1" ]]; then + if [[ "$1" = ? ]]; then + if [[ -b $optical$1 ]]; then + echo "Trying to mount: $optical$1" + $=mount $optical$1 + fi + fi + else + for a in $optical_devices; do + if [[ -b $optical$a ]]; then + echo "Trying to mount: $optical$a" + $=mount $optical$a + fi + done + fi +} + +sru() { + if [[ -n "$1" ]]; then + if [[ "$1" = ? ]]; then + if [[ -b $optical$1 ]]; then + echo "Trying to unmount: $optical$1" + $=unmount $optical$1 + fi + fi + else + for a in $optical_devices; do + if [[ -b $optical$a ]]; then + echo "Trying to unmount: $optical$a" + $=unmount $optical$a + fi + done + fi +} + diff --git a/.zsh.after/unixpool b/.zsh.after/unixpool new file mode 100644 index 0000000..e2edade --- /dev/null +++ b/.zsh.after/unixpool @@ -0,0 +1,125 @@ +# host based zshrc +# unixpool + +HISTFILE=$HOME/.zhistory +unset MAILCHECK + +## PATH and exports +PATH=${PATH}:/net/local64/bin +PATH=${PATH}:/net/adm/bin +PATH=${PATH}:/net/adm/scripts +PATH=${PATH}:/net/adm/xadm +PATH=${PATH}:/homes/wheel/wheel/bin +PATH=${PATH}:/sbin +PATH=${PATH}:/usr/sbin +#PATH=/store/s4/android/android-sdk-linux_86/tools:$PATH +#PATH=/store/s4/android/android-sdk-linux_86/platform-tools:$PATH + +#Remove /usr/bin/X11: if it shows up in $PATH +autoload -U regexp-replace +regexp-replace PATH '/usr/bin/X11:' '' + +export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.26/jre + +## aliases +alias lp_ps1_100='lp -q 100 -d ps1' +alias lp_ps2_100='lp -q 100 -d ps2' +alias QW='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -fn 5x8 -e /homes/misc/lpviewer/lpdisp' +alias QWbig='xterm -geometry 84x41-0+0 -T '\''QWatch'\'' -e /homes/misc/lpviewer/lpdisp' +alias QWbighere='/homes/misc/lpviewer/lpdisp' +alias QWdisplay="watch 'for n in {1..3}; do scli -c \"show printer display\" ps\$n-pool; done'" +#alias pyadm="/net/adm/pyadm-64ready/start.py" +alias synergys='synergys -c .config/synergy-$HOST.conf' + +# set pulseaudio server to s4 +if [ -f "`which pax11publish`" ]; +then + if [ ! $SSH_CLIENT ]; + then + if [ `pax11publish | grep -c s4` -eq 0 ]; + then + echo pulseaudio server set + pax11publish -S s4 -e + else + echo pulseaudio active + fi + fi +fi + + +## FUNCTIONS +function music_update() { + echo "updating zip files" + for i in */*; + do + name=`echo $i | sed 's/\ /_/g' | sed 's/\//-/g'` + if [ ! -e $name.zip ]; + then + echo "packing $i as $name.zip" + zip -r $name.zip $i + fi + done + echo "done" +} + +function makantine() { + wget http://personalkantine.personalabteilung.tu-berlin.de/pdf/MA-aktuell.pdf -O /tmp/makantine.$$.pdf >&/dev/null + xpdf -cont -z page /tmp/makantine.$$.pdf + rm -f /tmp/makantine.$$.pdf +} + +function pxeln() { + local instmode host oldumask bopts="" isrc="" + while [ -n "$1" ]; do + if [[ "$1" == -o* ]]; then + [ -z "$bopts" ] && bopts="bootopts=${1:2}" || bopts="${bopts},${1:2}"; + else + if [ -z "$instmode" ]; then instmode="$1"; + elif [ -z "$host" ]; then host="$1"; + else echo "Ignoring superfluous argument \"$1\"."; + fi + fi + + shift + done + if [[ -z "$instmode" || -z "$host" ]]; then + echo -e "Missing argument!\nSyntax: pxeln {mode} {host}\n(use tab completion for available modes)" >/dev/stderr + return 1 + fi + local IP=$(egrep "^[^,]*,${host}," /net/adm/access/HWlist |cut -d, -f1|cut -d. -f4) + local M="01-$(egrep " $IP " /net/adm/access/MAClist 2>/dev/null|sed -e "s/^|[^|]*| \([0-9a-f:]*\) |/\1/" -e "y/:/-/")" + if [[ ${#M} -ne 20 ]]; then + echo "Unknown host." >/dev/stderr + return 1 + fi + shift 2 + oldumask=$(umask -p) + umask 0022 + local instmodetl=$(tr [:upper:] [:lower:]<<<$instmode) + if [ -s /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed ]; then + if [ -e /homes/ext15a/tftpboot/pxelinux.cfg/$M ]; then + rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo "$host: former PXE diversion removed." + fi + sed /homes/ext15a/tftpboot/pxelinux.cfg/_template \ + -f /homes/ext15a/tftpboot/pxelinux.cfg/${instmode}.sed \ + > /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo -n "$host: elected for ${instmode}" + if [ -n "$bopts" ]; then + sed -i -e "/bootmode=${instmodetl}/ s/$/ ${bopts}/" /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo -n " (with extra boot options: \"$bopts\")" + fi + echo "." + elif [ "$instmode" == "remove" ]; then + rm -f /homes/ext15a/tftpboot/pxelinux.cfg/$M + echo "$host: PXE diversion removed." + else + echo "Unknown PXE mode." >/dev/stderr + fi + $oldumask + return 0 +} + +function mailhighscore() { + for i in /homes/wheel/*; do n=`basename $i`; echo `grep $n /var/spool/mail/runge | grep -c From` $n; done | sort -nr +} |