Docs: Add support for bash-completion

This commit is contained in:
Gaël PORTAY 2020-04-21 08:44:14 -04:00 committed by Adriaan de Groot
parent 1f6752307d
commit ded923fb95
3 changed files with 47 additions and 2 deletions

View File

@ -6,10 +6,11 @@ website will have to do for older versions.
# 3.2.24 (unreleased) #
This release contains contributions from (alphabetically by first name):
- No external contributors yet
- Gaël PORTAY
## Core ##
- No core changes yet
- There is now a bash-completions script for Calamares; turn on
the (CMake-time) option INSTALL_COMPLETION to get it. (Thanks Gaël)
## Modules ##
- No module changes yet

View File

@ -49,6 +49,7 @@ set( CALAMARES_VERSION_RC 1 ) # Set to 0 during release cycle, 1 during develop
#
option( INSTALL_CONFIG "Install configuration files" OFF )
option( INSTALL_POLKIT "Install Polkit configuration" ON )
option( INSTALL_COMPLETION "Install shell completions" OFF )
option( BUILD_TESTING "Build the testing tree." ON )
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
@ -389,6 +390,13 @@ list( SORT CALAMARES_TRANSLATION_LANGUAGES )
add_subdirectory( lang ) # i18n tools
if ( INSTALL_COMPLETION )
if( NOT CMAKE_INSTALL_BASHCOMPLETIONDIR )
set( CMAKE_INSTALL_BASHCOMPLETIONDIR "${CMAKE_INSTALL_DATADIR}/bash-completion/completions" )
endif()
install( FILES ${CMAKE_SOURCE_DIR}/data/completion/bash/calamares DESTINATION "${CMAKE_INSTALL_BASHCOMPLETIONDIR}" )
endif()
### Example Distro
#

View File

@ -0,0 +1,36 @@
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Copyright 2020, Gaël PORTAY <gael.portay@gmail.com>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Calamares is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
_calamares()
{
local cur prev words cword
_init_completion || return
case "$prev" in
-D)
COMPREPLY=( $( compgen -W "$( seq 0 1 8 )" -- "$cur" ) )
return
;;
-c|--config)
_filedir
return
;;
esac
COMPREPLY=( $( compgen -W "-h --help -v --version -d --debug -D -c --config -X -xdg-config -T --debug-translation" -- "$cur" ) )
} &&
complete -F _calamares calamares