From 23ae6c15796a61a86a4df612dbb1990c19585eda Mon Sep 17 00:00:00 2001 From: Alexander Kapshuna Date: Sat, 12 Sep 2020 18:08:31 +0300 Subject: [PATCH] Add zsh completion support Both bash and zsh completions could be supported using single file. --- data/rpm/flameshot.spec | 9 +++++---- docs/{bash-completion => shell-completion}/flameshot | 11 ++++++++++- src/CMakeLists.txt | 7 +++++-- 3 files changed, 20 insertions(+), 7 deletions(-) rename docs/{bash-completion => shell-completion}/flameshot (89%) diff --git a/data/rpm/flameshot.spec b/data/rpm/flameshot.spec index e657187b..655de46f 100644 --- a/data/rpm/flameshot.spec +++ b/data/rpm/flameshot.spec @@ -17,7 +17,7 @@ Source0: https://github.com/flameshot-org/%{sourcename}/archive/v%{version}.tar. %if 0%{?is_opensuse} %if 0%{?suse_version} >= 1500 BuildRequires: gcc-c++ >= 4.9.2 -BuildRequires: update-desktop-files +BuildRequires: update-desktop-files %else BuildRequires: gcc7 BuildRequires: gcc7-c++ @@ -25,8 +25,8 @@ BuildRequires: gcc7-c++ BuildRequires: libqt5-qttools-devel BuildRequires: libqt5-linguist %else -BuildRequires: gcc-c++ >= 4.9.2 -%endif +BuildRequires: gcc-c++ >= 4.9.2 +%endif %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} BuildRequires: qt5-qttools-devel @@ -90,7 +90,8 @@ make %{?_smp_mflags} %{_datadir}/metainfo/flameshot.metainfo.xml %{_datadir}/flameshot/translations %{_datadir}/applications/%{name}.desktop -%{_datadir}/bash-completions/completions/%{name} +%{_datadir}/bash-completion/completions/%{name} +%{_datadir}/zsh/site-functions/_%{name} %{_datadir}/icons/hicolor %changelog diff --git a/docs/bash-completion/flameshot b/docs/shell-completion/flameshot similarity index 89% rename from docs/bash-completion/flameshot rename to docs/shell-completion/flameshot index 58f5233d..60c197e3 100644 --- a/docs/bash-completion/flameshot +++ b/docs/shell-completion/flameshot @@ -1,5 +1,8 @@ -# bash-completion for flameshot command +#compdef flameshot + +# Shell completion for flameshot command # To be installed in "/usr/share/bash-completion/completions/flameshot" +# and "/usr/share/zsh/site-functions/" _flameshot() { local prev cur cmd gui_opts full_opts config_opts @@ -64,4 +67,10 @@ _flameshot() { ;; esac } + +if [[ -n ${ZSH_VERSION} ]]; then + autoload -U bashcompinit + bashcompinit +fi + complete -F _flameshot flameshot diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc616d8e..96928ac6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,8 +149,11 @@ configure_file(${CMAKE_SOURCE_DIR}/docs/desktopEntry/package/flameshot.desktop configure_file(${CMAKE_SOURCE_DIR}/docs/appdata/flameshot.metainfo.xml ${CMAKE_CURRENT_BINARY_DIR}/share/metainfo/flameshot.metainfo.xml COPYONLY) -configure_file(${CMAKE_SOURCE_DIR}/docs/bash-completion/flameshot - ${CMAKE_CURRENT_BINARY_DIR}/share/bash-completions/completions/flameshot COPYONLY) +configure_file(${CMAKE_SOURCE_DIR}/docs/shell-completion/flameshot + ${CMAKE_CURRENT_BINARY_DIR}/share/bash-completion/completions/flameshot COPYONLY) + +configure_file(${CMAKE_SOURCE_DIR}/docs/shell-completion/flameshot + ${CMAKE_CURRENT_BINARY_DIR}/share/zsh/site-functions/_flameshot COPYONLY) configure_file(${CMAKE_SOURCE_DIR}/data/dbus/org.flameshot.Flameshot.xml ${CMAKE_CURRENT_BINARY_DIR}/share/dbus-1/interfaces/org.flameshot.Flameshot.xml COPYONLY)