From owner-freebsd-questions@FreeBSD.ORG Mon Jun 22 09:12:27 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECF6D1065677 for ; Mon, 22 Jun 2009 09:12:27 +0000 (UTC) (envelope-from mail25@bzerk.org) Received: from ei.bzerk.org (tunnel490.ipv6.xs4all.nl [IPv6:2001:888:10:1ea::2]) by mx1.freebsd.org (Postfix) with ESMTP id 5B66D8FC17 for ; Mon, 22 Jun 2009 09:12:27 +0000 (UTC) (envelope-from mail25@bzerk.org) Received: from ei.bzerk.org (BOFH@localhost [127.0.0.1]) by ei.bzerk.org (8.14.2/8.14.2) with ESMTP id n5M9CKWO079498; Mon, 22 Jun 2009 11:12:20 +0200 (CEST) (envelope-from mail25@bzerk.org) Received: (from bulk@localhost) by ei.bzerk.org (8.14.2/8.14.2/Submit) id n5M9CK9P079497; Mon, 22 Jun 2009 11:12:20 +0200 (CEST) (envelope-from mail25@bzerk.org) Date: Mon, 22 Jun 2009 11:12:20 +0200 From: Ruben de Groot To: Karl Vogel Message-ID: <20090622091220.GA79438@ei.bzerk.org> Mail-Followup-To: Ruben de Groot , Karl Vogel , freebsd-questions@freebsd.org References: <4A3994BC.1000600@ibctech.ca> <20090619190555.2F839BEE7@kev.msw.wpafb.af.mil> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090619190555.2F839BEE7@kev.msw.wpafb.af.mil> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on ei.bzerk.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (ei.bzerk.org [127.0.0.1]); Mon, 22 Jun 2009 11:12:25 +0200 (CEST) Cc: freebsd-questions@freebsd.org Subject: Re: Changing my login directory X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2009 09:12:28 -0000 On Fri, Jun 19, 2009 at 03:05:55PM -0400, Karl Vogel typed: > >> On Wed, 17 Jun 2009 21:13:32 -0400, > >> Steve Bertrand 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