Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 2009 11:12:20 +0200
From:      Ruben de Groot <mail25@bzerk.org>
To:        Karl Vogel <vogelke+unix@pobox.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Changing my login directory
Message-ID:  <20090622091220.GA79438@ei.bzerk.org>
In-Reply-To: <20090619190555.2F839BEE7@kev.msw.wpafb.af.mil>
References:  <4A3994BC.1000600@ibctech.ca> <20090619190555.2F839BEE7@kev.msw.wpafb.af.mil>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jun 19, 2009 at 03:05:55PM -0400, Karl Vogel typed:
> >> On Wed, 17 Jun 2009 21:13:32 -0400, 
> >> Steve Bertrand <steve@ibctech.ca> said:
> 
> S> I've got a couple of jails now that I use exclusively for Perl
> S> development.  As soon as I log into the box via SSH, my first command is
> S> _always_ "cd devel/something".  I'd like to make it so that '~' remains
> S> /home/steve, but when I log in, I would prefer to be dropped immediately
> S> into /home/steve/devel.
> 
>    This reminded me of how I deal with lots of directories.  If you
>    have a project with files spread all over the place, here's a way to
>    navigate between 20-25 directories with no more than 3-4 keystrokes.
>    First, install the "grabchars" program:
>      http://examples.oreilly.com/upt3/split/grabchars/grabchars/
> 
>    It's very useful for capturing and validating keystrokes from within
>    a shell script.  For example:
>      ans=`grabchars -q'Answer y or n: '`
> 
>    will print "Answer y or n: ", and it will store your reply after
>    pressing just one key, no need to hit return.  Combine this with a
>    function to change your current directory and you're in business;
>    it has to be done in a shell function rather than a separate script
>    because it modifies your current shell working directory.

No need for any external programs. The following shell script does the same:

> more readkey.sh 
 echo -n "Press any key: "
 stty cbreak -echo
 KEY=$(dd bs=1 count=1 2>/dev/null)
 stty -cbreak echo
 echo
 echo "You pressed the \"$KEY\" key."


Ruben




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090622091220.GA79438>