Changing my login directory
Ruben de Groot
mail25 at bzerk.org
Mon Jun 22 09:12:28 UTC 2009
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 at 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
More information about the freebsd-questions
mailing list