WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH v3]xl:Add basic bash completion for xl command

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] [PATCH v3]xl:Add basic bash completion for xl command
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Tue, 27 Apr 2010 16:41:24 +0800
Delivery-date: Tue, 27 Apr 2010 01:41:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BD6913D.7010408@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4BD65C74.6050306@xxxxxxxxxxxxxx> <4BD6913D.7010408@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100415 Thunderbird/3.0.4
v2->v3
  If no matchs found,fallback to default completion.

====================================================================

Add basic bash completion for xl command.

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>

diff -r c87ec146229a Config.mk
--- a/Config.mk Fri Apr 23 15:04:26 2010 +0100
+++ b/Config.mk Wed Apr 28 00:37:02 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      Wed Apr 28 00:37:02 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       Wed Apr 28 00:37:02 2010 +0800
@@ -0,0 +1,21 @@
+#!/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
+
+       return 0
+}
+
+complete -F _xl -o nospace -o default xl

-- 
Regards
Yang Hongyang

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>