From 8dd52c3b04b9a5f32596dc8ab745e61ab5c0987a Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sat, 25 Nov 2006 00:52:18 +0100 Subject: [PATCH] The 'preparation to a zsh workshop improves code quality' release. :) * /etc/zsh/zshrc: - run "limit core 0" only in live-cd mode - support Force-Reload for /etc/init.d/*-action as well - move upgrade-function from /etc/skel/.zshrc to this file * /etc/skel/.zshrc: some cosmetic cleanups --- debian/changelog | 12 ++++++++++++ etc/skel/.zshrc | 34 ++++++++++------------------------ etc/zsh/zshrc | 26 ++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0cea8db..b4f29d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +grml-etc-core (0.1-37) unstable; urgency=low + + The 'a zsh workshop improves code quality' release. :) + + * /etc/zsh/zshrc: + - run "limit core 0" only in live-cd mode + - support Force-Reload for /etc/init.d/*-action as well + - move upgrade-function from /etc/skel/.zshrc to this file + * /etc/skel/.zshrc: some cosmetic cleanups + + -- Michael Prokop Sat, 25 Nov 2006 00:06:16 +0100 + grml-etc-core (0.1-36) unstable; urgency=low * /etc/skel/.zshrc: diff --git a/etc/skel/.zshrc b/etc/skel/.zshrc index ea9f6bd..c3dbaf8 100644 --- a/etc/skel/.zshrc +++ b/etc/skel/.zshrc @@ -238,7 +238,6 @@ # console stuff alias cmplayer='mplayer -vo fbdev' -# alias fbmplayer='mplayer -vo fbdev' alias fbmplayer='mplayer -vo fbdev -fs -zoom' alias fblinks='links2 -driver fb' @@ -267,7 +266,7 @@ cvsr() { rcs2log $* | $PAGER } cvss() { cvs status -v $* } debbug() { ${=BROWSER} "http://bugs.debian.org/$*" } - debbugm() { bts show --mbox $1 } # provide bugnummer as $1 + debbugm() { bts show --mbox $1 } # provide bugnummer as "$1" disassemble(){ gcc -pipe -S -o - -O -g $* | as -aldh -o /dev/null } dmoz() { ${=BROWSER} http://search.dmoz.org/cgi-bin/search\?search=${1// /_} } dwicti() { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} } @@ -298,24 +297,6 @@ _doc() { _files -W /usr/share/doc -/ } compdef _doc doc -# debian upgrade - upgrade () { - if [ -z $1 ] ; then - $SUDO apt-get update - $SUDO apt-get -u upgrade - else - ssh $1 $SUDO apt-get update - # ask before the upgrade - local dummy - ssh $1 $SUDO apt-get --no-act upgrade - echo -n "Process the upgrade ?" - read -q dummy - if [[ $dummy == "y" ]] ; then - ssh $1 $SUDO apt-get -u upgrade --yes - fi - fi - } - # make screenshot of current desktop (use 'import' from ImageMagic) sshot() { [[ ! -d ~/shots ]] && mkdir ~/shots @@ -323,7 +304,6 @@ cd ~/shots ; sleep 5; import -window root shot_`date --iso-8601=m`.jpg } - # list images only limg() { local -a images @@ -335,7 +315,6 @@ fi } - # create pdf file from source code makereadable() { output=$1 @@ -351,6 +330,7 @@ pcre_compile $1 && \ pcre_match $2 && echo "regex matches" || echo "regex does not match" } + # list files which have been modified within the last x days new() { print -l *(m-$1) } @@ -595,6 +575,7 @@ fi } +# follow symlinks folsym() { if [[ -e $1 || -h $1 ]]; then file=$1 @@ -674,7 +655,7 @@ done } -# $ show_print `cat /etc/passwd` +# % slow_print `cat /etc/passwd` slow_print() { for argument in "${@}" do @@ -687,6 +668,7 @@ print "" } +# display system state status() { print "" print "Date..: "$(date "+%Y-%m-%d %H:%M:%S")"" @@ -698,6 +680,7 @@ print "" } +# Rip an audio CD audiorip() { mkdir -p ~/ripps cd ~/ripps @@ -715,6 +698,7 @@ fi } +# and burn it audioburn() { cd ~/ripps cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc @@ -730,6 +714,7 @@ fi } +# Make an audio CD from all mp3 files mkaudiocd() { cd ~/ripps for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done @@ -739,6 +724,7 @@ for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done } +# Create an ISO image. You are prompted for volume name, filename and directory mkiso() { echo " * Volume name " read volume @@ -749,7 +735,7 @@ mkisofs -o ~/$iso -A $volume -allow-multidot -J -R -iso-level 3 -V $volume -R $files } -# generate thumbnails ;) +# simple thumbnails generator genthumbs () { rm -rf thumb-* index.html echo " diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index ff2fe2c..32c2860 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -176,7 +176,7 @@ fi zle -N edit-command-line && \ bindkey '\ee' edit-command-line -## menu selection: pick item but stay in the menu (press esc-return) +# menu selection: pick item but stay in the menu (press esc-return) is4 && bindkey -M menuselect '\e^M' accept-and-menu-complete # press "ctrl-e d" to insert the actual date in the form yyyy-mm-dd @@ -501,6 +501,24 @@ Enjoy your grml system with the zsh!$reset_color" alias dbp='dpkg-buildpackage' alias ge='grep-excuses' + # debian upgrade + upgrade () { + if [ -z "$1" ] ; then + $SUDO apt-get update + $SUDO apt-get -u upgrade + else + ssh $1 $SUDO apt-get update + # ask before the upgrade + local dummy + ssh $1 $SUDO apt-get --no-act upgrade + echo -n 'Process the upgrade?' + read -q dummy + if [[ $dummy == "y" ]] ; then + ssh $1 $SUDO apt-get -u upgrade --yes + fi + fi + } + isgrmlcd && alias su="sudo su" # change to user root alias tlog="tail -f /var/log/syslog" # take a look at the syslog alias zshskel="source /etc/skel/.zshrc" # source skeleton zshrc @@ -521,7 +539,7 @@ Please use the wodim binary instead' ; return 1" # {{{ Use hard limits, except for a smaller stack and no core dumps unlimit limit stack 8192 - limit core 0 # important for a live-cd-system + isgrmlcd && limit core 0 # important for a live-cd-system limit -s # }}} @@ -750,11 +768,11 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." # use it e.g. via 'Restart apache2' if [ -d /etc/init.d ] ; then - for i in Start Restart Stop Reload ; do + for i in Start Restart Stop Force-Reload Reload ; do eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} \$2 ; }" done # now the completion for this: - compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Reload + compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Force-Reload Reload fi # }}} -- 2.1.4