LoginSignup
6
4

More than 5 years have passed since last update.

Macのbashでautocdしたい

Last updated at Posted at 2015-12-10

初期インストールされているbashはバージョンが4.0以降ではないのでshopt -s autocdが設定できない。

プリインストールされているbash
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.

なので、brewから最新版をインストールする。

bash
$ brew update
$ brew install bash

インストールされた場所がどこかと、bashのバージョンが4.0以上であることを確認して、最後に/etc/shellsへパスを書き込む

bash
$ which bash
...
$ /usr/local/bin/bash --version
...
$ echo /usr/local/bin/bash | sudo tee -a /etc/shells
...

ここまで問題なければchshコマンドでシェルを変更して、shopt -pで一覧の中にautocdがあることをチェックしておわり。

bash
$ chsh -s /usr/local/bin/bash
...
$ shopt -p
...

byobuを使っている場合

macでbyobuを使っていると常に/bin/bashからシェルを起動しようとしてくるので、こいつを_bashか何かにリネームして/usr/local/bin/bashからここへbashとしてシンボリックリンクでも貼るとよい◯

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4