From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: Re: [PATCH v2]xl:Add basic bash completion for xl command
Date: Tue, 27 Apr 2010 15:24:45 +0800 [thread overview]
Message-ID: <4BD6913D.7010408@cn.fujitsu.com> (raw)
In-Reply-To: <4BD65C74.6050306@cn.fujitsu.com>
Add basic bash completion for xl command.
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
diff -r c87ec146229a Config.mk
--- a/Config.mk Fri Apr 23 15:04:26 2010 +0100
+++ b/Config.mk Tue Apr 27 23:24:23 2010 +0800
@@ -19,6 +19,7 @@
DISTDIR ?= $(XEN_ROOT)/dist
DESTDIR ?= /
+BASH_COMPLETION_DIR ?= /etc/profile.d
# Allow phony attribute to be listed as dependency rather than fake target
.PHONY: .phony
diff -r c87ec146229a tools/libxl/Makefile
--- a/tools/libxl/Makefile Fri Apr 23 15:04:26 2010 +0100
+++ b/tools/libxl/Makefile Tue Apr 27 23:24:23 2010 +0800
@@ -85,6 +85,7 @@
ln -sf libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(LIBDIR)/libxlutil.so
$(INSTALL_DATA) libxlutil.a $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) libxl.h $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_DATA) bash-completion $(BASH_COMPLETION_DIR)/xl.sh
.PHONY: clean
clean:
diff -r c87ec146229a tools/libxl/bash-completion
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/bash-completion Tue Apr 27 23:24:23 2010 +0800
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Copy this file to /etc/profile.d/xl.sh
+
+_xl()
+{
+ local IFS=$'\n,'
+
+ local cur opts xl
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ xl=xl
+
+ if [[ $COMP_CWORD == 1 ]] ; then
+ opts=`${xl} help 2>/dev/null | sed 'n;d' | sed '1,2d' | awk '{print $1}' | sed 's/$/ ,/g'` && COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ fi
+}
+
+complete -F _xl -o nospace xl
--
Regards
Yang Hongyang
next prev parent reply other threads:[~2010-04-27 7:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-27 3:39 [PATCH]xl:Add basic bash completion for xl command Yang Hongyang
2010-04-27 7:24 ` Yang Hongyang [this message]
2010-04-27 8:41 ` [PATCH v3]xl:Add " Yang Hongyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BD6913D.7010408@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).