From 3ac8e0f994839f3c972033bcb12421081ebeb683 Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 28 Sep 2021 22:50:56 +0200 Subject: zsh: move includes to XDG compliant locations .config/zsh/{functions,includes}/*: Move functions and includes to XDG compliant locations. .zshrc: Include functions and other includes from XDG compliant locations. Remove use of prepend-sudo function. --- .config/zsh/includes/aliases.zsh | 276 +++++++++++++++++++++++ .config/zsh/includes/apt | 37 ++++ .config/zsh/includes/export.zsh | 102 +++++++++ .config/zsh/includes/frqrec | 0 .config/zsh/includes/functions.zsh | 398 ++++++++++++++++++++++++++++++++++ .config/zsh/includes/hostspecific.zsh | 6 + .config/zsh/includes/key-bindings.zsh | 22 ++ .config/zsh/includes/path.zsh | 19 ++ .config/zsh/includes/udisks.zsh | 245 +++++++++++++++++++++ .config/zsh/includes/unixpool | 125 +++++++++++ 10 files changed, 1230 insertions(+) create mode 100644 .config/zsh/includes/aliases.zsh create mode 100644 .config/zsh/includes/apt create mode 100644 .config/zsh/includes/export.zsh create mode 100644 .config/zsh/includes/frqrec create mode 100644 .config/zsh/includes/functions.zsh create mode 100644 .config/zsh/includes/hostspecific.zsh create mode 100644 .config/zsh/includes/key-bindings.zsh create mode 100644 .config/zsh/includes/path.zsh create mode 100644 .config/zsh/includes/udisks.zsh create mode 100644 .config/zsh/includes/unixpool (limited to '.config/zsh/includes') diff --git a/.config/zsh/includes/aliases.zsh b/.config/zsh/includes/aliases.zsh new file mode 100644 index 0000000..20a055f --- /dev/null +++ b/.config/zsh/includes/aliases.zsh @@ -0,0 +1,276 @@ +# < ZSH ALIASES +# suffix aliases +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' + +# global aliases +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' +alias -g C='| wc -l' +alias -g H='| head' +alias -g L="| less" +alias -g N="| /dev/null" +alias -g S='| sort' +alias -g G='| grep' + +# ls +alias ls='ls --group-directories-first --color=auto' +alias ll="ls -lh" +alias la="ls -a" +alias lal="ls -alhv" +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' + +#zsh + +# Lists the ten most used commands. +alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head" + +alias d='dirs -v' +for index ({1..9}) alias "$index"="cd +${index}"; unset index + +#MPLAYER +alias mplayer='mplayer -ao jack,pulse,alsa' +if pgrep Xwayland > /dev/null; then + alias mpv='mpv --audio-channels=stereo --gpu-context=wayland -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' +else + alias mpv='mpv --audio-channels=stereo -ao=jack,pulse,alsa --sub-auto=fuzzy --jack-port="minimixer:in1_*"' +fi +if [[ "$VENDOR" == "apple" ]]; then + alias mpv='mpv --sub-auto=fuzzy' +fi +##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 sdsj='sudo journalctl --system -a' #show the entire system journal +alias sdsjf='sudo journalctl --system -af' #follow all system messages +alias sdsjb='sudo journalctl --system -ab' #Show system messages from specific boot +alias sdsjbf='sudo journalctl --system -ab -f' #follow only messages from this boot +alias sdsju='sudo journalctl --system -af -u' #follow messages of only the specified unit +alias sdsjk='journalctl -k' #show dmesg +alias sdsjkb='journalctl -kb' #show dmesg from specific boot +alias sdsjkf='journalctl -kf' #follow current dmesg +alias sdsjlb='journalctl --list-boots' #list all boots +alias sdsjp='sudo journalctl --system _PID=' #show all messages of specified system process (PID) +alias sdjgrep='sudo journalctl -an1000 |grep ' #Use a grep command to search through journal +alias sduj='journalctl --user -a' +alias sdujf='journalctl --user -af' +alias sdujb='journalctl --user -ab' +alias sdujbf='journalctl --user -afb' +alias sdujb='journalctl --user -ab' +alias sdujp='journalctl --user _PID=' #show all messages of specified user process (PID) +#systemd system services +alias sdsedit='sudo systemctl edit' +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 -a -l' +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 --system list-timers' +alias sdss='sudo systemctl --system list-sockets' +alias sdsu='sudo systemctl --system list-units' +alias sdsuf='sudo systemctl --system list-unit-files' +alias sdsdep='sudo systemctl --system list-dependencies' +alias sdscat='systemctl --system cat' +alias sdsreload='sudo systemctl daemon-reload' +alias sds='sudo systemctl -a' +alias sdsfail='sudo systemctl -a -l --no-legend --state=failed' +alias sdsmask='sudo systemctl mask' +alias sdsunmask='sudo systemctl unmask' +#systemd user services +alias sduedit='systemctl --user edit' +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 -a -l' +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 sdus='systemctl --user list-sockets' +alias sduu='systemctl --user list-units' +alias sdudep='systemctl --user list-dependencies' +alias sducat='systemctl --user cat' +alias sdureload='systemctl --user daemon-reload' +#alias sdu='systemctl --user' +alias sdufail='systemctl --user -a -l --no-legend --state=failed' +alias sdumask='systemctl --user mask' +alias sduunmask='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/cloud/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 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='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 -type f \( -name "*.pacsave" -o -name "*.pacnew" \)' #Search for .pacnew and .pacsave files +alias pacown='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 ssh.add="ssh-add $HOME/.ssh/id_{rsa{,_tu},ed25519{,_aur,_github,_holoplot}}" +alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date -I)"' +if [ $VENDOR = "apple" ]; then + # apple's date is broken + alias ssh.new='ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)-$(date +%Y-%m-%d)"' +fi +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/.config/zsh/includes/apt b/.config/zsh/includes/apt new file mode 100644 index 0000000..e1942cf --- /dev/null +++ b/.config/zsh/includes/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/.config/zsh/includes/export.zsh b/.config/zsh/includes/export.zsh new file mode 100644 index 0000000..59eb186 --- /dev/null +++ b/.config/zsh/includes/export.zsh @@ -0,0 +1,102 @@ +if [[ -n $TMUX ]] && [[ $VENDOR != "apple" ]] && [[ ! -e /etc/debian_version ]]; then + export TERM="screen-256color" +elif [[ -n $STY ]];then + export TERM="screen-256color" +else + export TERM="xterm-256color" +fi + + +available_locale=$(locale -a|tr '\n' ' ') +if [ "${available_locale#*en_DK.utf8}" != "$available_locale" ]; then + export LC_TIME="en_DK.UTF-8" +elif [ "${available_locale#*en_DK.UTF-8}" != "$available_locale" ]; then + export LC_TIME="en_DK.UTF-8" +fi +if [ "${available_locale#*de_DE.utf8}" != "$available_locale" ]; then + export LC_MONETARY="de_DE.UTF-8" +elif [ "${available_locale#*de_DE.UTF-8}" != "$available_locale" ]; then + export LC_MONETARY="de_DE.UTF-8" +fi +if [ "${available_locale#*en_US.utf8}" != "$available_locale" ]; then + export LANG="en_US.UTF-8" +elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then + export LANG="en_US.UTF-8" +fi +if [ "${available_locale#*en_US.utf8}" != "$available_locale" ] ; then + export LC_CTYPE="en_US.UTF-8" +elif [ "${available_locale#*en_US.UTF-8}" != "$available_locale" ]; then + export LC_CTYPE="en_US.UTF-8" +fi + +# keyboard exports for sway +export XKB_DEFAULT_LAYOUT=de + +# browser +export BROWSER=firefox +export REPORTTIME=5 + +# systemd +export SYSTEMD_EDITOR=vim + +# editor +export EDITOR=vim +export VISUAL=vim + +# 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 + +# pipenv environment variables: +# - disabling fancy shell stuff +# - creating virtualenv within each project +# - moving cache dir to build volume +export PIPENV_NOSPIN="true" +export PIPENV_COLORBLIND="true" +export PIPENV_HIDE_EMOJIS="true" +export PIPENV_VENV_IN_PROJECT="true" +#export PIPENV_CACHE_DIR="$HOME/.cache/pipenv" + +# brew +if command -v brew > /dev/null; then + export HOMEBREW_NO_ANALYTICS="true" + export HOMEBREW_NO_AUTO_UPDATE="true" + export HOMEBREW_NO_EMOJI="true" +fi + +# GnuPG +export GPG_TTY=$TTY +export GPG_AGENT_INFO="" + +# ssh-agent +if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]];then + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" +fi + +# tmux +if [[ $UID -ne 0 ]] && [[ $VENDOR != "apple" ]]; then + export TMUX_TMPDIR="$XDG_RUNTIME_DIR/" +else + export TMUX_TMPDIR="/tmp" +fi + +# zsh +if [[ $UID -eq 0 ]]; then + export TMOUT=360 + readonly TMOUT + export TMOUT +fi diff --git a/.config/zsh/includes/frqrec b/.config/zsh/includes/frqrec new file mode 100644 index 0000000..e69de29 diff --git a/.config/zsh/includes/functions.zsh b/.config/zsh/includes/functions.zsh new file mode 100644 index 0000000..7a87bee --- /dev/null +++ b/.config/zsh/includes/functions.zsh @@ -0,0 +1,398 @@ +# < FUNCTIONS + +## 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 incognichrome { + chromium --incognito +} + +function inproxychrome { + chromium --incognito --proxy-server=apu-serve:8123 --user-data-dir="$HOME/.config/chromium-proxy" +} + +## 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 + ;; + *.tar.lz) + tar xvf $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 + ;; + *.asc) + gpg -o ${1%".asc"} -d $1 + ;; + *.gz) + gunzip $1 + ;; + *.tar) + tar xvf $1 + ;; + *.tbz2) + tar xvjf $1 + ;; + *.tgz) + tar xvzf $1 + ;; + *.whl) + unzip "$1" + ;; + *.xz) + tar xvJf $1 + ;; + *.zip) + unzip $1 + ;; + *.zst) + tar --zstd -xvf $1 --force-local + ;; + *.Z) + uncompress $1 + ;; + *.7z) + 7z x $1 + ;; + *) + echo "Don't know how to extract '$1'..." + ;; + esac + else + echo "'$1' is not a valid file to extract!" + 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 +} + +lstar() { + if [ -f "$1" ] ; then + case "$1" in + *.deb) + ar -tv "$1" + ;; + *.bz2) + tar -tvf "$1" --force-local + ;; + *.gz) + tar -tvf "$1" --force-local + ;; + *.lz) + tar -tvf "$1" --force-local + ;; + *.rar) + unrar lb "$1" + ;; + *.tar) + tar -tvf "$1" --force-local + ;; + *.tbz2) + tar -tvf "$1" --force-local + ;; + *.tgz) + tar -tvf "$1" --force-local + ;; + *.whl) + unzip -l "$1" + ;; + *.xz) + tar -Jtvf "$1" --force-local + ;; + *.zip) + unzip -l "$1" + ;; + *.Z) + uncompress $1 + ;; + *.7z) + 7z l "$1" + ;; + *.zst) + tar --zstd -tvf "$1" --force-local + ;; + *) + echo "Don't know how to look into $1" + exit 1 + ;; + esac + else + echo "'$1' is not a file!" + exit 1 + fi +} + +## RSYNC + +backupinfo() { + rsync\ + -r\ + -n\ + -t\ + -p\ + -o\ + -h\ + -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\ + -h\ + -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 +} + +# journalctl + +# show messages of specified system units +function sdsjfu(){ + local journal_cmd="sudo journalctl --system -a" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified system units +function sdsjfu(){ + local journal_cmd="sudo journalctl --system -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified system units for this boot +function sdsjbfu(){ + local journal_cmd="sudo journalctl --system -b -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# follow messages of specified user units +function sdujfu(){ + local journal_cmd="journalctl --user -af" + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# follow messages of specified user units for this boot +function sdujbu(){ + local journal_cmd="journalctl --user -a -b" + #TODO: Check if first argument is a number, then use it for -b + eval ${journal_cmd} $(echo $@ | sed 's/\ /\ --user-unit\ /g') +} + +# show messages of specified system units since and until a specified time +function sdsjSUu(){ + local journal_cmd="sudo journalctl --system -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + args=(${args:2}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# show messages of specified system units since a specified time +function sdsjSu(){ + local journal_cmd="sudo journalctl --system -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + args=(${args:1}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ -u\ /g; s/^/\ -u\ /') +} + +# show messages of specified user units since and until a specified time +function sdujSUu(){ + local journal_cmd="journalctl --user -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + args=(${args:2}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# show messages of specified user units since a specified time +function sdujSu(){ + local journal_cmd="journalctl --user -a -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + args=(${args:1}) + eval ${journal_cmd} $(echo $args | sed 's/\ /\ --user-unit\ /g; s/^/\ --user-unit\ /') +} + +# show kernel messages since and until a specified time +function sdsjkSU(){ + local journal_cmd="sudo journalctl --system -a -k -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1] -U $args[2]" + eval ${journal_cmd} +} + +# show kernel messages since a specified time +function sdsjkS(){ + local journal_cmd="sudo journalctl --system -a -k -S" + local args=(${@}) + journal_cmd="$journal_cmd $args[1]" + eval ${journal_cmd} +} + + +function pasters() { + local file="${1:-/dev/stdin}" + curl --data-binary @"${file}" https://paste.rs +} + +# FUNCTIONS > diff --git a/.config/zsh/includes/hostspecific.zsh b/.config/zsh/includes/hostspecific.zsh new file mode 100644 index 0000000..20d569b --- /dev/null +++ b/.config/zsh/includes/hostspecific.zsh @@ -0,0 +1,6 @@ +case "${HOST}" in + s4|s5|c{1,2}*) + . $HOME/.zsh.after/apt + . $HOME/.zsh.after/unixpool + ;; +esac diff --git a/.config/zsh/includes/key-bindings.zsh b/.config/zsh/includes/key-bindings.zsh new file mode 100644 index 0000000..300b3c7 --- /dev/null +++ b/.config/zsh/includes/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/.config/zsh/includes/path.zsh b/.config/zsh/includes/path.zsh new file mode 100644 index 0000000..21e36e6 --- /dev/null +++ b/.config/zsh/includes/path.zsh @@ -0,0 +1,19 @@ +# cargo +[ -d "${HOME}/.cargo/bin" ] && PATH="${HOME}/.cargo/bin:${PATH}" +# pyenv +[ -d "${HOME}/.local/bin" ] && PATH="${HOME}/.local/bin:${PATH}" +[ -d "${HOME}/.pyenv/shims" ] && PATH="${HOME}/.pyenv/shims:${PATH}" +# RPi +[ -d "/opt/vc/bin" ] && PATH="${PATH}:/opt/vc/bin" +[ -d "/opt/vc/sbin" ] && PATH="${PATH}:/opt/vc/sbin" +# user bin +[ -d "${HOME}/bin" ] && PATH="${HOME}/bin:${PATH}" +# Debilian +[ -d "/usr/sbin" ] && [ ! -L "/usr/sbin" ] && PATH="${PATH}:/usr/sbin" +# whackOS +[ -d "/usr/local/opt/coreutils/libexec/gnubin" ] && PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-sed/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-tar/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/gnu-which/libexec/gnubin" ] && PATH="/usr/local/opt/gnu-which/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/findutils/libexec/gnubin" ] && PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" +[ -d "/usr/local/opt/grep/libexec/gnubin" ] && PATH="/usr/local/opt/grep/libexec/gnubin:$PATH" diff --git a/.config/zsh/includes/udisks.zsh b/.config/zsh/includes/udisks.zsh new file mode 100644 index 0000000..3478aea --- /dev/null +++ b/.config/zsh/includes/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/.config/zsh/includes/unixpool b/.config/zsh/includes/unixpool new file mode 100644 index 0000000..e2edade --- /dev/null +++ b/.config/zsh/includes/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 +} -- cgit v1.2.3-70-g09d2