浏览代码

Created bash-completion file for mssh

Héctor García 11 年之前
父节点
当前提交
a686cefe12
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      mssh.bash-completion

+ 38 - 0
mssh.bash-completion

@@ -0,0 +1,38 @@
+# bash completion for mssh
+# Written by Héctor García <[email protected]>
+
+_mssh_alias()
+{
+  if [ -f ~/.mssh_clusters ]; then
+    COMPREPLY=( $( compgen -W '$( command cat ~/.mssh_clusters 2>/dev/null \
+       | grep -v "^\s*$" | grep -v "^#" | sed -e "s/:.*$//" )' -- $cur ) )
+  fi
+
+  return 0
+}  
+
+_mssh()
+{
+  local cur=${COMP_WORDS[COMP_CWORD]} 
+  local prev=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMPREPLY=()
+
+  case "$prev" in
+   -a)
+     _mssh_alias
+     return 0
+     ;;
+  esac
+
+  # completing -a option
+  if [[ "$cur" == -* ]]; then
+    COMPREPLY=( $( compgen -W "-a" -- $cur ) )
+    return 0
+  fi
+
+  _known_hosts_real "$cur"
+
+}
+
+complete -F _mssh mssh