LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-28-2006, 03:45 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
[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?
 
Old 12-29-2006, 11:56 AM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
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...

Last edited by pljvaldez; 12-29-2006 at 12:07 PM.
 
Old 12-29-2006, 12:26 PM   #3
johnson_steve
Senior Member
 
Registered: Apr 2005
Location: BrewCity, USA (Milwaukee, WI)
Distribution: Xubuntu 9.10, Gentoo 2.6.27 (AMD64), Darwin 9.0.0 (arm)
Posts: 1,152

Rep: Reputation: 46
why would you even want this?
 
Old 12-29-2006, 12:49 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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'?
 
Old 12-29-2006, 01:32 PM   #5
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 31
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.
 
Old 12-29-2006, 01:58 PM   #6
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
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.
 
Old 01-01-2007, 12:41 AM   #7
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-02-2007, 12:13 PM   #8
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
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...
 
Old 01-02-2007, 01:15 PM   #9
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
How to start KDE automaticlly without typing "startx" then "startkde" Jonescity Slackware 8 10-29-2004 09:32 PM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 10:43 AM
i just finished typing "./configure" and "make" in mplayer directory... kublador Linux - General 4 02-22-2003 03:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration