From: culliton@srg.srg.af.mil (Tom Culliton x2278)
To: rc@hawkwind.utcs.toronto.edu
Subject: A Xmas toy
Date: Wed, 22 Dec 1993 17:03:01 -0500 [thread overview]
Message-ID: <9312221703.aa18393@ceres.srg.af.mil> (raw)
# This is my Xmas present to the mailing list. It's a version of cd that
# keeps track of all the directories that you've visited and lets you easily
# return to any of them. I wrote it because I often find myself bouncing
# back and forth between 3 or 4 different places, cd - just didn't cut it,
# and pushd/popd/swapd were inconvenient. Hopefully you'll find this
# useful or at least entertaining.
#
# Tom
# The variable dirs holds the MRU directory queue
fn dirs { echo $dirs }
fn cd {
if (! ~ $#* [01])
{
echo too many arguments
return 1
}
switch ($1)
{
case - # shorthand for -1
cd $dirs(1) # recursion
case -[1-9] -[1-9][0-9] # 1 -> 99 are valid
cd $dirs(`{echo $1 | cut -c2-}) # recursion
case -[0-9]* # catch dumb stuff
echo bad numeric argument
return 1
case * # also handles no args case
d = $1 { # save arg (if any)
'*' = $dirs # shift only works on *
dirs = `{/bin/pwd} # MRU moves to front
while (! ~ $* ()) # and eliminate duplicates
{
if (! ~ $dirs $1) dirs = ($dirs $1)
shift
}
builtin cd $d # actually go there
# and possibly fix your prompt, etc.
}
}
}
reply other threads:[~1993-12-22 22:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=9312221703.aa18393@ceres.srg.af.mil \
--to=culliton@srg.srg.af.mil \
--cc=rc@hawkwind.utcs.toronto.edu \
/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.
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).