summary refs log tree commit diff
path: root/pkgs/os-specific/linux/upstart
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2009-09-20 17:01:24 +0000
committerMarc Weber <marco-oweber@gmx.de>2009-09-20 17:01:24 +0000
commit295c76b1c1a0caffcf53127c289b19d9b71e72cd (patch)
treece02063f8900ef24a43b9d6460d3ad6021b37477 /pkgs/os-specific/linux/upstart
parent34be37b51e33761b2de5941e67cd0dcb88aaa5c5 (diff)
downloadnixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar.gz
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar.bz2
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar.lz
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar.xz
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.tar.zst
nixpkgs-295c76b1c1a0caffcf53127c289b19d9b71e72cd.zip
adding bash completion script for upstart
svn path=/nixpkgs/trunk/; revision=17304
Diffstat (limited to 'pkgs/os-specific/linux/upstart')
-rw-r--r--pkgs/os-specific/linux/upstart/default.nix8
-rw-r--r--pkgs/os-specific/linux/upstart/upstart-bash-completion18
2 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/upstart/default.nix b/pkgs/os-specific/linux/upstart/default.nix
index 07bc3e6fe75..cb18679dfe5 100644
--- a/pkgs/os-specific/linux/upstart/default.nix
+++ b/pkgs/os-specific/linux/upstart/default.nix
@@ -1,5 +1,8 @@
 {stdenv, fetchurl}:
 
+let bashCompletion = ./upstart-bash-completion;
+in
+
 stdenv.mkDerivation {
   name = "upstart-0.3.0";
   
@@ -26,6 +29,11 @@ stdenv.mkDerivation {
     interfaceVersion = 1;
   };
 
+  postInstall = ''
+    t=$out/etc/bash_completion.d
+    ensureDir $t; cp ${bashCompletion} $t/upstart
+  '';
+
   meta = {
     homepage = "http://upstart.ubuntu.com/";
     description = "An event-based replacement for the /sbin/init daemon";
diff --git a/pkgs/os-specific/linux/upstart/upstart-bash-completion b/pkgs/os-specific/linux/upstart/upstart-bash-completion
new file mode 100644
index 00000000000..f47d38c90ad
--- /dev/null
+++ b/pkgs/os-specific/linux/upstart/upstart-bash-completion
@@ -0,0 +1,18 @@
+_upstart_comp_list(){
+  COMPREPLY=()
+  cur=${COMP_WORDS[COMP_CWORD]}
+  if [ $COMP_CWORD -eq 1 ]; then
+      COMPREPLY=( $(compgen -o filenames -W "$@" $cur) )
+  fi
+}
+
+_upstart_complete() { _upstart_comp_list "$(initctl list 2>&1 | grep -E "$1" | cut -f2 -d ' ')"; }
+
+_waiting(){ _upstart_complete "(waiting|instance)"; }
+_running(){ _upstart_complete "(running|instance)"; }
+_jobs(){ _upstart_comp_list "$(ls -1 /etc/event.d 2> /dev/null)"; }
+
+complete -F _jobs status
+complete -F _waiting start
+complete -F _running stop
+complete -F _running restart