LoginSignup
0
1

More than 5 years have passed since last update.

.ssh/config を分割管理している場合のcool-peco-ssh

Posted at

.ssh/conf.d/*をincludeする形で管理している
そのため、cool-pecoを入れたがcool-peco-sshが空振りしてしまうorz

構成

.
└── .ssh
   ├── config
   └── conf.d
      ├── .gitkeep
      ├── myProject.config
      └── sourceTree.conf

.ssh/config

Host *
  UseKeychain yes

Include conf.d/*conf*

.zshrcにfunctionを追加する

    # select ssh hosts from ~/.ssh/conf.d
    function getSshHosts () {
        echo $(cat ~/.ssh/conf.d/*.config | grep "Host " | grep -v '*' | cut -b 6- | peco)
    }

    function pssh () {
        local res

        res=$(getSshHosts)
        if [ -n "$res" ]; then
            _cool-peco-insert-command-line "ssh $res"
        fi
    }

key bindに追加

zle -N pssh
bindkey '^o' pssh

cool-peco-sshのデフォルトキーバインドは^sだが、なぜか効かないので^oに変更した
conf.dに .conf と .configの2種類があるのは、ssh接続するものだけを表示するため

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