From 5045b55bb9a9040db953034a6cd517c16ef7e2db Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 11 Jan 2007 00:27:59 +0100 Subject: [PATCH] /etc/zsh/zshrc: added functions deswap, hex and peval --- debian/changelog | 2 ++ etc/zsh/zshrc | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b354f5b..1988bc4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ grml-etc-core (0.2.15) unstable; urgency=low want to miss the feature itself, so just press 0 and that's it :)) - added alias debs-by-size + - added function deswap (useful after suspending), function hex + (print hex value of a number) and function peval (perl-eval) -- Michael Prokop Fri, 5 Jan 2007 00:00:54 +0100 diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 7cf2087..fbefb58 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -797,7 +797,7 @@ grmlcomp() { [ -d $ZSHDIR/cache ] && zstyle ':completion:*' use-cache yes && \ zstyle ':completion::complete:*' cache-path $ZSHDIR/cache/ -# host completion +# host completion /* add brackets as vim can't parse zsh's complex cmdlines 8-) {{{ */ if is42 ; then [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$( /dev/null + print 'Finished, running "swapoff -a; swapon -a" may also be useful.' + } + + # print hex value of a number + hex() { + [ -n "$1" ] && printf "%x\n" $1 || { print 'Usage: hex ' ; return 1 } + } + + # calculate (or eval at all ;-)) with perl => p[erl-]eval + # hint: also take a look at zcalc -> 'autoload zcalc' -> 'man zshmodules | less -p MATHFUNC' + peval() { + [ -n "$1" ] && CALC="$*" || print "Usage: calc [expression]" + perl -e "print eval($CALC),\"\n\";" + } + functions peval &>/dev/null && alias calc=peval + # Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html # bash() { # NO_SWITCH="yes" command bash "$@" -- 2.1.4