LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   [bash 3.0] avoid typing "cd" (https://www.linuxquestions.org/questions/linux-general-1/%5Bbash-3-0%5D-avoid-typing-cd-514252/)

noir911 12-28-2006 03:45 AM

[bash 3.0] avoid typing "cd"
 
I know in .cshrc if I type "set implicitcd" I can avoid typing
"cd /path/to/dir" and can go to any directory just by typing "/path/to/dir"

Is there any similar option I can set in my .bashrc file?

pljvaldez 12-29-2006 11:56 AM

http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=bash

Looks like you can use shopt -s implicitcd. You probably have to put this in your .bashrc or profile...

EDIT: At least I think it works for Bash 3.0. I tried it on my Debian sarge system which has Bash 2.0 and it doesn't have the implicitcd shell option...

johnson_steve 12-29-2006 12:26 PM

why would you even want this?

colucix 12-29-2006 12:49 PM

The only way is to patch the shell, but is it worth to waste time in shell programming only to avoid the 2 milliseconds required to type 'cd'?

hacker supreme 12-29-2006 01:32 PM

I would say that that depends on how many times a day you have to type 'CD'. If it's enough times then you might actually be making a saving in the time spent typing directories.
Just depends if your pedantic enough to want to save a total of 500milliseconds by the end of the day. :)

frob23 12-29-2006 01:58 PM

This is one feature of the csh (of many) that I don't think people appreciate until they use it a lot. But it really is a nice thing, especially since it is almost always the desired action. And if you're walking through a filesystem (with tabs) it just makes sense a lot of the time to not keep typing cd.

noir911 01-01-2007 12:41 AM

Quote:

Originally Posted by pljvaldez
Looks like you can use shopt -s implicitcd

doesn't work with Bash 3.1.17(1) on OpenBSD 4.0. It says

-bash: shopt: implicitcd: invalid shell option name

pljvaldez 01-02-2007 12:13 PM

Quote:

Originally Posted by noir911
doesn't work with Bash 3.1.17(1) on OpenBSD 4.0. It says

-bash: shopt: implicitcd: invalid shell option name

My bad, that man page was a FreeBSD page. I wonder if they do patch the shell and add that option... I guess read the man page on your machine and see if there's another option...

bigrigdriver 01-02-2007 01:15 PM

Or, if you are not restricted to using bash, you could try zsh. For my purposes, it is the same as bash, with options bash does not include, such as autocd.

If you enter something that cannot be interpreted as a command, such as a directory path, zsh will automatically cd to that directory.


All times are GMT -5. The time now is 05:33 AM.