summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Pereira Neves2014-08-20 21:38:23 +0200
committerMichael Pereira Neves2014-08-20 21:55:26 +0200
commitfa97e926c3706799dbfb6e63f43c14de2146ef3a (patch)
tree492d3128a88579ea9cd84a718eb10e4471308063
parent[doc] add entry in boot_config_vars (diff)
downloadtm-scripts-fa97e926c3706799dbfb6e63f43c14de2146ef3a.tar.gz
tm-scripts-fa97e926c3706799dbfb6e63f43c14de2146ef3a.tar.xz
tm-scripts-fa97e926c3706799dbfb6e63f43c14de2146ef3a.zip
[useful] zsh completion plugin for mltk/openslx cmds
-rw-r--r--useful/zsh-completion/README30
-rw-r--r--useful/zsh-completion/openslx/_mltk42
-rw-r--r--useful/zsh-completion/openslx/_openslx45
-rw-r--r--useful/zsh-completion/openslx/openslx.plugin.zsh0
4 files changed, 117 insertions, 0 deletions
diff --git a/useful/zsh-completion/README b/useful/zsh-completion/README
new file mode 100644
index 00000000..690e9e6b
--- /dev/null
+++ b/useful/zsh-completion/README
@@ -0,0 +1,30 @@
+This is a Completion Plugin for Oh-My-ZSH.
+It faciliates the handling of the openslx and mltk command line tools by
+showing available options, targets, module, hosts and configs on tab press.
+
+#Install
+To use it, just place the folder 'openslx' under "~/.oh-my-zsh/plugins/",
+fire up a new zsh-session, switch to your tm-script directory and the
+completion should be working.
+
+#Optional
+The following lines can be added to your ~/.zshrc file
+They are not really necessary for the completion to work, but will make
+the completion functions more verbose.
+-------------------------------------------------------------
+zstyle ':completion:*' verbose yes
+zstyle ':completion:*:descriptions' format '%B%d%b'
+zstyle ':completion:*:messages' format '%d'
+zstyle ':completion:*:warnings' format 'No matches for: %d'
+zstyle ':completion:*' group-name ”
+-------------------------------------------------------------
+
+#Development
+With the following command you can quickly test changes you did to the
+completion functions without having to reopen a new session every time.
+For example to reload the completion function for _mltk:
+
+$ unfunction _mltk && autoload -U _mltk
+
+#Futher Information
+http://zsh.sourceforge.net/Doc/Release/Completion-System.html
diff --git a/useful/zsh-completion/openslx/_mltk b/useful/zsh-completion/openslx/_mltk
new file mode 100644
index 00000000..fccceb1b
--- /dev/null
+++ b/useful/zsh-completion/openslx/_mltk
@@ -0,0 +1,42 @@
+#compdef mltk
+#autoload
+
+typeset -A opt_args
+local context state state_descr line expl
+
+_mltk_target_modules() {
+ target_modules=(`ls remote/targets/$1`)
+}
+
+local -a targets target_modules
+_targets=(`ls remote/targets`)
+
+_arguments \
+ "--help[display help text]: :->help" \
+ "-n[-n \[name\] bind mount all the local builds (remote/builds) to /export/builds or /export/\[name\]]: :->bind" \
+ "*:: :->target" && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "mltk Targets" _targets
+ return
+fi
+
+case "$state" in
+ target)
+ _mltk_target_modules $words[1]
+ _arguments \
+ "-c[-c \[module\]* clean build directory of module(s) and target dir]:*: :->modules" \
+ "-b[-b \[module\]* build module(s) and copy them to the target build directory]:*: :->modules" \
+ "-d[activates debug output for the task (spamy)]" \
+ && return 0
+
+
+ if [[ "$state" == modules ]]; then
+ _arguments \
+ "-c[-c \[module\]* clean build directory of module(s) and target dir]" \
+ "-b[-b \[module\]* build module(s) and copy them to the target build directory]" \
+ "-d[activates debug output for the task (spamy)]: :->debug" \
+ "*:Modules in Target $words[1]:($target_modules)" && return 0
+ fi
+ ;;
+esac
diff --git a/useful/zsh-completion/openslx/_openslx b/useful/zsh-completion/openslx/_openslx
new file mode 100644
index 00000000..f19f4973
--- /dev/null
+++ b/useful/zsh-completion/openslx/_openslx
@@ -0,0 +1,45 @@
+#compdef openslx
+#autoload
+
+typeset -A opt_args
+local context state state_descr line expl
+
+_openslx_targets() {
+ targets=(`ls server/local_builds/$1`)
+}
+
+local -a targets _local_builds configs
+_local_builds=(`ls server/local_builds/`)
+configs=(`ls server/configs/`)
+
+_arguments \
+ "--help[display help text]: :->help" \
+ "*:: :->remotehost" && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "Existing Remote Hosts" _local_builds
+ return
+fi
+
+case "$state" in
+ remotehost)
+ _openslx_targets $words[1]
+ [[ "$targets" == "server/local_builds/local" ]] && unset targets
+
+ _arguments \
+ "(-k :)-s[sync 'builds' from remote host]" \
+ "(-s :)-k[-k <config> - generate config file server/boot/<remotehost>/configs/<configname>/config.tgz]:Available Configs:($configs)" \
+ "(:)-d[activates debug output for the task (spamy)]" \
+ "(-)*: :->target" \
+ && return 0
+
+ if [[ "$state" == target ]]; then
+ _arguments \
+ "-e[-e type - export target as 'type'. can be 'cpio' (simple initramfs) or 'sqfs' (squashfs)]:Export Type:(sqfs cpio)" \
+ "-s[sync 'builds' from remote host]" \
+ "-c[clean target in server/local_builds/ and corresponding files under boot/]" \
+ "-d[activates debug output for the task]" \
+ ":Targets on Host $words[1]:($targets)"
+ fi
+ ;;
+esac
diff --git a/useful/zsh-completion/openslx/openslx.plugin.zsh b/useful/zsh-completion/openslx/openslx.plugin.zsh
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/useful/zsh-completion/openslx/openslx.plugin.zsh