LoginSignup
1
2

More than 5 years have passed since last update.

pecoでsshするやつ in fish shell

Posted at

元ネタ: pecoでsshするやつ

fish-shellでsが使えなくて焦ったので、
備忘録として公開しておきます。

作り方

元ネタの記事から$()()にするだけ。

~> alias s='ssh (grep -iE "^host[[:space:]]+[^*]" ~/.ssh/config|peco|awk "{print \$2}")'

~> functions s
# Defined in /Users/miyabi/.config/fish/functions/s.fish @ line 2
function s --description alias\ s=ssh\ \(grep\ -iE\ \"\^host\[\[:space:\]\]+\[\^\*\]\"\ \~/.ssh/config\|peco\|awk\ \"\{print\ \\\$2\}\"\)
    ssh (grep -iE "^host[[:space:]]+[^*]" ~/.ssh/config|peco|awk "{print \$2}") $argv;
end

~> s
# pecoが立ち上がってSSH接続出来る

~> funcsave s
# これでsコマンドが保存されて常に使えるようになった

おまけ: moshも登録

mでいいかな?
moshはmosh hostで接続できるのでsshのほぼ丸コピーで使える

~> m
fish: Unknown command 'm'

~> alias m='mosh (grep -iE "^host[[:space:]]+[^*]" ~/.ssh/config|peco|awk "{print \$2}")'

~> functions m
# Defined in - @ line 0
function m --description alias\ m=mosh\ \(grep\ -iE\ \"\^host\[\[:space:\]\]+\[\^\*\]\"\ \~/.ssh/config\|peco\|awk\ \"\{print\ \\\$2\}\"\)
    mosh (grep -iE "^host[[:space:]]+[^*]" ~/.ssh/config|peco|awk "{print \$2}") $argv;
end

~> funcsave m
1
2
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
1
2