Wenn zum Beispiel ein Verzeichnis „blob“ existiert und ich einfach „blob[return]“ eintippe, wechselt das System cd
für mich in das blob-Verzeichnis.
Unter Linux (Ubuntu) kann ich shopt -s autocd
meiner .bashrc
Datei etwas hinzufügen, aber unter OS X gibt dies einen Fehler aus:-bash: shopt: autocd: invalid shell option name
autocd
wurde in Bash 4.0 hinzugefügt. Sie können eine neuere Version von bash mit Homebrew installieren und dann die Standard-Login-Shell mit ändern chsh
:
brew install bash;echo /usr/local/bin/bash|sudo tee -a /etc/shells;chsh -s /usr/local/bin/bash
Nachdem Sie eine neue Anmelde-Shell (oder standardmäßig eine Registerkarte in Terminal oder iTerm 2) geöffnet haben, echo $BASH_VERSION
sollte so etwas wie 4.2.45(2)-release
.
Terminal und iTerm 2 öffnen standardmäßig neue Shells als Anmelde-Shells, sodass bash liest ~/.bash_profile
, aber nicht ~/.bashrc
. Wenn Sie nicht ~/.bashrc
von ~/.bash_profile
oder irgendetwas beziehen, fügen Sie shopt -s autocd
zu ~/.bash_profile
anstelle von hinzu ~/.bashrc
.
Die Ausgabe von shopt -p
kann hier hilfreich sein. Es druckt eine Liste der einstellbaren Optionen. Leider gehört Lion autocd
nicht dazu (siehe Auszug unten).
Bearbeiten Lauris Antwort oben enthält eine Lösung zum Aktualisieren Ihrer Shellautocd
$ shopt -p
shopt -u cdable_vars
shopt -u cdspell
shopt -u checkhash
shopt -s checkwinsize
shopt -s cmdhist
shopt -u compat31
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -u extglob
shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u gnu_errfmt
shopt -u histappend
shopt -u histreedit
shopt -u histverify
shopt -s hostcomplete
shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo
ephschmied
sudo port install bash
in Ihren Schritt 1 funktioniert auch.Michael Durrant
Lri
bash -version
wäre die erste Version auf $PATH. Hast du es versuchtecho $BASH_VERSION
?Michael Durrant
Lri
/usr/bin/login
oderlogin -fp $USER
in den Einstellungen geöffnet wird?Michael Durrant
Michael Durrant
Lri
/usr/bin/local/bash
ohne ist--login
,.bash_profile
wird nicht geladen.Michael Durrant
Michael Durrant
bash --version
gesagt3.2.51(1)
brew install bash
4.2.45 already installed
Lri
/bin
vorher/usr/local/bin
auf dem Weg ist,bash --version
ist wie/bin/bash --version
. Versuchen Sie esecho $BASH_VERSION
stattdessen. Hast dushopt -s autocd
zu~/.bash_profile
oder hinzugefügt~/.bashrc
?Michael Durrant