]> arthur.barton.de Git - ax-zsh.git/commitdiff
Add "ssh_macos“ plugin
authorAlexander Barton <alex@barton.de>
Mon, 26 Dec 2016 16:00:16 +0000 (17:00 +0100)
committerAlexander Barton <alex@barton.de>
Mon, 26 Dec 2016 16:00:16 +0000 (17:00 +0100)
Add SSH keys from the macOS Keychain automatically (macOS 10.12
"Sierra“ or newer).

plugins/ssh_macos/README.md [new file with mode: 0644]
plugins/ssh_macos/ssh_macos.zshrc [new file with mode: 0644]

diff --git a/plugins/ssh_macos/README.md b/plugins/ssh_macos/README.md
new file mode 100644 (file)
index 0000000..1b7f5ff
--- /dev/null
@@ -0,0 +1,5 @@
+## ssh_macos
+
+Additional configuration for SSH on Apple macOS X:
+
+* Add SSH keys from the macOS Keychain automatically.
diff --git a/plugins/ssh_macos/ssh_macos.zshrc b/plugins/ssh_macos/ssh_macos.zshrc
new file mode 100644 (file)
index 0000000..92639e8
--- /dev/null
@@ -0,0 +1,12 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# ssh_macos.zshrc: Additional configuration for SSH on Apple macOS X
+
+# Make sure that "ssh(1)" is installed.
+(( $+commands[ssh] )) || return 1
+
+# Test for macOS Sierra (10.12) or newer:
+[[ $(uname -s) = "Darwin" ]] || return 1
+[[ $(uname -r | cut -d'.' -f1) -ge 16 ]] || return 1
+
+# Load SSH keys from Keychain into SSH agent when the agent has no keys.
+ssh-add -l >/dev/null || ssh-add -A >/dev/null 2>&1