aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2009-02-02 09:18:05 +1000
committerGravatar axel <axel@liljencrantz.se>2009-02-02 09:18:05 +1000
commit9d7224d756e3521dd0f3115874066d386154b438 (patch)
tree96bd63c0e238e66912718efb21eae81f1bdb67e3
parent33ec8b45a074810ef985d9abe11551d5d55f3aee (diff)
Add support for completing aliases in ssh. Written by David Bronke.
darcs-hash:20090201231805-ac50b-196d4c81981efe681677fe8ca7f1cc833a4734da.gz
-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