From 72224ab03469bbb7705e39ace9c7f9cb26faeccc Mon Sep 17 00:00:00 2001 From: Bingzhang Dai Date: Sun, 16 Feb 2020 15:39:37 +0800 Subject: [PATCH 1/3] Create ~/.ssh and ~/.ssh/config if does not exits --- plugins/available/ssh.plugin.bash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/available/ssh.plugin.bash b/plugins/available/ssh.plugin.bash index 51587b29..bda4601e 100644 --- a/plugins/available/ssh.plugin.bash +++ b/plugins/available/ssh.plugin.bash @@ -7,14 +7,15 @@ function add_ssh() { param '2: hostname' param '3: user' group 'ssh' - + [[ $# -ne 3 ]] && echo "add_ssh host hostname user" && return 1 + [[ ! -d ~/.ssh ]] && mkdir -m 700 ~/.ssh + [[ ! -e ~/.ssh/config ]] && touch ~/.ssh/config && chmod 600 ~/.ssh/config echo -en "\n\nHost $1\n HostName $2\n User $3\n ServerAliveInterval 30\n ServerAliveCountMax 120" >> ~/.ssh/config } function sshlist() { about 'list hosts defined in ssh config' group 'ssh' - awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config } From bf7da247bf4570443a586c3e411500cd14ef6025 Mon Sep 17 00:00:00 2001 From: Bingzhang Dai Date: Sun, 16 Feb 2020 15:42:51 +0800 Subject: [PATCH 2/3] Revert changes --- plugins/available/ssh.plugin.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/available/ssh.plugin.bash b/plugins/available/ssh.plugin.bash index bda4601e..dd023ad2 100644 --- a/plugins/available/ssh.plugin.bash +++ b/plugins/available/ssh.plugin.bash @@ -7,6 +7,7 @@ function add_ssh() { param '2: hostname' param '3: user' group 'ssh' + [[ $# -ne 3 ]] && echo "add_ssh host hostname user" && return 1 [[ ! -d ~/.ssh ]] && mkdir -m 700 ~/.ssh [[ ! -e ~/.ssh/config ]] && touch ~/.ssh/config && chmod 600 ~/.ssh/config @@ -15,7 +16,8 @@ function add_ssh() { function sshlist() { about 'list hosts defined in ssh config' - group 'ssh' + group 'ssh + awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config } From f7cb2ef5c6275f9cc02cf28f6cde0a4e327eb123 Mon Sep 17 00:00:00 2001 From: Bingzhang Dai Date: Sun, 16 Feb 2020 15:44:50 +0800 Subject: [PATCH 3/3] Update ssh.plugin.bash --- plugins/available/ssh.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/ssh.plugin.bash b/plugins/available/ssh.plugin.bash index dd023ad2..6e082881 100644 --- a/plugins/available/ssh.plugin.bash +++ b/plugins/available/ssh.plugin.bash @@ -16,7 +16,7 @@ function add_ssh() { function sshlist() { about 'list hosts defined in ssh config' - group 'ssh + group 'ssh' awk '$1 ~ /Host$/ {for (i=2; i<=NF; i++) print $i}' ~/.ssh/config }