Change directory without typing cd?
8,610
In bash there is also autocd
option. You can enable it by using shopt -s autocd
:
pbm@tauri ~ $ shopt -s autocd
pbm@tauri ~ $ django # Now just type this
cd ./django <- it's done automatically
pbm@tauri ~/django $
Related videos on Youtube
Author by
Vladimir
Updated on September 17, 2022Comments
-
Vladimir over 1 year
Is it possible to make bash change directory in command line simply by typing that directory without any commands like
cd
?For example is it possible instead of writing this:
$ cd /tmp
I just want to write only this:
$ /tmp
In other words if I call directory as an application then I want to set that directory as a working one.
-
Thomas Themel over 13 yearsYes, that's what one would naïvely expect - however, bash is smarter than us and doesn't even call command_not_found_handle for directories :(
-
Vladimir over 13 yearsAfter some research I've found a small patch ( mail-archive.com/[email protected]/msg06761.html ) that could fix it. Unfortunately this patch is unofficial so it could not be used with a stock version of bash provided with ubuntu.
-
Gilles 'SO- stop being evil' over 13 yearsMy favorite new feature in bash 4 for interactive use. (For scripting, it's
**
.) Unfortunately, it's not in older versions.