From: Phil Pennock <phil.pennock@globnix.org>
To: Clifford Caoile <piyokun@email.com>
Cc: zsh-users@sunsite.dk
Subject: Re: a calculator for zsh-4.x
Date: Wed, 29 Jan 2003 16:18:43 +0000 [thread overview]
Message-ID: <20030129161843.GA20920@globnix.org> (raw)
In-Reply-To: <BBEKIEKOHGEFJBFLEENGEEEKCGAA.piyokun@email.com>
On 2003-01-30 at 01:03 +0900, Clifford Caoile wrote:
> I don't know about you, but I reach for zsh when I want to calculate
> addition in hexadecimal
I also tend to do this; messing around with graphical calculators is a
pain.
> # -----------------------------------------------------------------begin
> # calculator - paste me into your .zshrc
> # ----------------------------------------------------------------------
>
> # Here are some quick calculators that output in integer
> # hexadecimal, decimal, and binary.
> zcalc () { print $(( ans = ${1:-ans} )) }
> zcalch () { print $(( [#16] ans = ${1:-ans} )) }
> zcalcd () { print $(( [#10] ans = ${1:-ans} )) }
> zcalco () { print $(( [#8] ans = ${1:-ans} )) }
> zcalcb () { print $(( [#2] ans = ${1:-ans} )) }
>
> # A key binding that will allow you to quickly get into zcalc
> bindkey -s '\C-xd' "zcalc \'"
>
> # this last one lets you calculate the ascii value of a single character
> zcalcasc () { print $(( [#16] ans = ##${1:-ans} )) }
> # -------------------------------------------------------------------end
I like it. :^) But with one modification: for the first five
functions, replace ${1:-ans} with ${@:-ans} so that the quotes are
unnecessary unless you're using characters interpreted by the shell.
> Call for advice:
> Actually, I'm most interested in enhancing the bindkey definition. Placing
> just one quotation mark on the command line seems to be sloppy.
I just bypass the need for the bindkey for most of the things I'd use
these functions for.
Thanks,
next prev parent reply other threads:[~2003-01-29 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-29 16:03 Clifford Caoile
2003-01-29 16:18 ` Phil Pennock [this message]
2003-01-29 19:43 ` kwong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030129161843.GA20920@globnix.org \
--to=phil.pennock@globnix.org \
--cc=piyokun@email.com \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).