LoginSignup
2
0

More than 5 years have passed since last update.

SSH するときにホスト名を自動補完する

Last updated at Posted at 2013-02-28

bash-completion を使うと ssh コマンドで(ログインしたことのある)ホスト名を補完してくれたりします。

$ brew install bash-completion
(snip)
Add the following lines to your ~/.bash_profile:
  if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
  fi

なので ~/.bash_profile に追記。

~/.bash_profile
  if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
  fi

設定を再読み込み。

$ source ~/.bash_profile

あとはいい感じに補完してくれます。

$ ssh  <TAB>
192.168.1.10
192.168.1.101
192.168.1.11
192.168.1.2
192.168.1.202
192.168.1.213
(snip)

これでいろいろ捗る。

Debian ぽいディストリビューションなら標準でインストール済みらしいので、設定の追加だけで使えるぽい。

2
0
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
2
0