[Bash-completion-commits] [bash-completion] 01/01: hostname: New completion

Ville Skyttä scop-guest at moszumanska.debian.org
Sat May 3 20:13:53 UTC 2014


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit c924d32b4c127bc9cc46cb71d3148c8bdbfdd6cf
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat May 3 23:13:33 2014 +0300

    hostname: New completion
---
 completions/Makefile.am           |  1 +
 completions/hostname              | 23 +++++++++++++++++++++++
 test/completion/hostname.exp      |  1 +
 test/lib/completions/hostname.exp | 18 ++++++++++++++++++
 4 files changed, 43 insertions(+)

diff --git a/completions/Makefile.am b/completions/Makefile.am
index 90b8ebc..624e5aa 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -129,6 +129,7 @@ bashcomp_DATA = 2to3 \
 		hddtemp \
 		_hexdump \
 		hid2hci \
+		hostname \
 		hping2 \
 		htop \
 		htpasswd \
diff --git a/completions/hostname b/completions/hostname
new file mode 100644
index 0000000..6a602dc
--- /dev/null
+++ b/completions/hostname
@@ -0,0 +1,23 @@
+# hostname(1) completion                                   -*- shell-script -*-
+
+_hostname()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    case $prev in
+        -h|--help|-V|--version)
+            return
+            ;;
+        -F|--file)
+            _filedir
+            return
+            ;;
+    esac
+
+    [[ $cur == -* ]] && \
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+} &&
+complete -F _hostname hostname
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/completion/hostname.exp b/test/completion/hostname.exp
new file mode 100644
index 0000000..3c6983e
--- /dev/null
+++ b/test/completion/hostname.exp
@@ -0,0 +1 @@
+assert_source_completions hostname
diff --git a/test/lib/completions/hostname.exp b/test/lib/completions/hostname.exp
new file mode 100644
index 0000000..9d9e496
--- /dev/null
+++ b/test/lib/completions/hostname.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+    save_env
+}
+
+
+proc teardown {} {
+    assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "hostname -"
+sync_after_int
+
+
+teardown

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list