From 58cc14e1aa912cd55dd2067a43a6ce329023a192 Mon Sep 17 00:00:00 2001 From: "Alexander Gehrke (crater2150)" Date: Tue, 5 Jan 2016 03:55:24 +0100 Subject: [PATCH] new compdefs --- compdef/_mediathek | 8 +++ compdef/_xdg-utils | 149 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 compdef/_mediathek create mode 100644 compdef/_xdg-utils diff --git a/compdef/_mediathek b/compdef/_mediathek new file mode 100644 index 0000000..f6084b2 --- /dev/null +++ b/compdef/_mediathek @@ -0,0 +1,8 @@ +#compdef mediathek + +function _mediathek { + typeset -a targets + targets=("${(@f)$(mediathek -l)}") + _describe target targets +} + diff --git a/compdef/_xdg-utils b/compdef/_xdg-utils new file mode 100644 index 0000000..3b488b0 --- /dev/null +++ b/compdef/_xdg-utils @@ -0,0 +1,149 @@ +#compdef xdg-mime xdg-desktop-icon +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for xdg-utils (http://portland.freedesktop.org/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Alexander Gehrke +# +# ------------------------------------------------------------------------------ + +zmodload zsh/mapfile + +_xdg-mime() { + local context curcontext="$curcontext" state line + typeset -A opt_args + + _arguments \ + '1: :_xdg-mime_cmds' \ + '*::arg:->args' \ + '--help[show short help]' \ + '--manual[show manual page]' \ + '--version[show version info]' \ + + case $state in + (args) + case "${words[1]}" in + (query) + _arguments \ + '1: :_xdg-mime_query_commands' \ + '2: :_xdg-mime_query_params' + ;; + (default) + _arguments \ + '1: :_path_files -g "*.desktop" -W"(/usr/share/applications/ $HOME/.local/applications/)"' \ + '2: :_xdg-mime_types' + ;; + (install) + _arguments \ + '1: :_files -g "*.xml"' \ + '--mode[operate on system or user]: :_values "operation mode" system user' \ + '--novendor[do not check for vendor prefix]' + ;; + (uninstall) + _arguments \ + '1: :_files -g "*.xml"' \ + '--mode[operate on system or user]: :_values "operation mode" system user' \ + ;; + esac + ;; + esac +} + +_xdg-mime_cmds() { + local commands; commands=( + 'query:get information related to filetypes' + 'default:change default application' + 'install:add filetype descriptions' + 'uninstall:remove filetype descriptions' + ) + _describe -t xdg-mime-commands "commands" commands +} + +_xdg-mime_query_commands() { + local commands; commands=( + 'filetype:get type of a file' + 'default:get default application for a type' + ) + _describe -t xdg-mime-queries "query type" commands +} + +_xdg-mime_query_params() { + case $words[2] in + (filetype) + _files + ;; + (default) + _xdg-mime_types + ;; + esac + +} + +_xdg-mime_types() { + _values "mime type" ${(f)mapfile[$HOME/.local/mime/types]} ${(f)mapfile[/usr/share/mime/types]} +} + +_xdg-desktop-icon() { + _arguments \ + '1: :_xdg-desktop-icon_cmds' \ + '*::arg:->args' \ + '--help[show short help]' \ + '--manual[show manual page]' \ + '--version[show version info]' + + case $state in + (args) + case "${words[1]}" in + (install) + _arguments \ + ': :_files' \ + '--novendor[do not check for vendor prefix]' + ;; + (uninstall) + _files -W "$HOME/Desktop" + ;; + esac + ;; + esac +} + +_xdg-desktop-icon_cmds() { + local commands; commands=( + 'install:add file to the desktop' + 'uninstall:remove file from the desktop' + ) + _describe -t xdg-mime-commands "commands" commands +} + +# vim:ft=zsh ts=2 sw=2 et