aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--share/completions/ssh.fish8
-rw-r--r--share/functions/__fish_print_ssh_aliases.fish7
2 files changed, 15 insertions, 0 deletions
diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish
index 637f8e49..4af4c2e5 100644
--- a/share/completions/ssh.fish
+++ b/share/completions/ssh.fish
@@ -4,6 +4,11 @@
__fish_complete_ssh ssh
+complete -x -c ssh -d Alias -a "
+
+(__fish_print_ssh_aliases)
+"
+
complete -x -c ssh -d Hostname -a "
(__fish_print_hostnames)
@@ -12,6 +17,9 @@ complete -x -c ssh -d Hostname -a "
#Prepend any username specified in the completion to the hostname
echo (commandline -ct)|sed -ne 's/\(.*@\).*/\1/p'
)(__fish_print_hostnames)
+"
+
+complete -x -c ssh -d User -a "
(__fish_print_users)@
"
diff --git a/share/functions/__fish_print_ssh_aliases.fish b/share/functions/__fish_print_ssh_aliases.fish
new file mode 100644
index 00000000..719c991e
--- /dev/null
+++ b/share/functions/__fish_print_ssh_aliases.fish
@@ -0,0 +1,7 @@
+
+function __fish_print_ssh_aliases -d "Print a list of known ssh aliases"
+ # Print ssh aliases
+ if test -f ~/.ssh/config
+ awk '/^[[:space:]]*Host\>/ {print $2}' ~/.ssh/config
+ end
+end