PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

CLI: Creating and Navigating the Dirextory Stack


Your Ad Here

Your Ad Here

CLI = Command Line Interface (bash in this case)

Creating and Navigating the Directory Stack -------------------------------------------

All of you know about changing directories with 'cd'. Here's a much more effective way of negotiating the directory tree on your linux box.

Create and navigate a directory stack (dirs) with a function that calls pushd, and displays it with dirs.

A mailserver distribution 4060
On Tue, 12 Jul 2005 14:45:57 -0400, Micah Raspail staggered into the Black Sun and...

Run these:

help pushd help dirs

To make this easy, put the following functions abd alias in your ~-.bashrc:

This one runs pushd and then ls -shF on the directory it takes you to. It supersedes your normal cd:

cd() { ls -shF }

This one makes using the directory stack (dirs) very easy. First hit "d" (see below) to bring up the directory stack, then enter "c" followed by a space, followed by the number of the dir you want to return to. (Read on, this will become clear.)

c () { eval cd +${1} }

alias d='dirs -v'

----------------------------------

Now have bash reread your ~-.bashrc with:

$ source ~-.bashrc # or '. ~-.bashrc' Same thing

Kensington 4button "Expert Mouse" trackball an apparent anomaly 4062
On Wed, 13 Jul 2005 12:34:46 UTC, Michael Heiming which tells me I have a 5-button mouse. Others...

Do:

d

Nothing there? That's because you haven't put any directories in the stack with the above function "cd" that calls the pushd command, which does a conventional cd and adds the new directory to the stack.

Try this, starting in your home directory, entering "d -c" first, to clear the stack:

cdetc cdbin cd cdusr

Now do

d

to display the directory stack. It will look like this:

0 usr 1 2 bin 3 etc 4 ~

That's your directory stack now. Suppose that you want to return tobin without typing 'cdbin and without losing track of where you've been? Do:

c 2

It doesn't seem like much with the above short stack, and short directory names and paths, but if you are 6 levels deep in a directory and you want to return to another directory you were at a while ago that is 5 levels deep in a different directory, and you can't quite remember where that file was, then it makes ALL the difference in the world.

Take the small amount of time it takes to set up and learn the above, and you will find yourself in much more control of your navigations around your directory tree. And you will begin to understand why the CLI makes the GUI look like the child's playpen it is.

AC

-- If you are posting through google for any purpose other than learning to use a real newsreader, many of us will not answer your questions. ---- news.software.readers ----



Your Ad Here

List | Previous | Next

A mailserver distribution 4060

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

poll: how many Linux users would rather use Mac OS