mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
bash completion: Complete file names after '-p' and '-C'.
* etc/completion/bash/guix (_guix_is_dash_C, _guix_is_dash_p): New functions. (_guix_complete): Honor them for "install", "remove", "upgrade", "pull", and "time-machine".
This commit is contained in:
parent
e6d9e055ec
commit
b7bb381ba3
1 changed files with 49 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
# GNU Guix --- Functional package management for GNU
|
||||
# Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
||||
# Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Guix.
|
||||
#
|
||||
|
@ -115,6 +115,24 @@ _guix_is_dash_m ()
|
|||
esac }
|
||||
}
|
||||
|
||||
_guix_is_dash_C ()
|
||||
{
|
||||
[ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-C" ] \
|
||||
|| { case "${COMP_WORDS[$COMP_CWORD]}" in
|
||||
--channels=*) true;;
|
||||
*) false;;
|
||||
esac }
|
||||
}
|
||||
|
||||
_guix_is_dash_p ()
|
||||
{
|
||||
[ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-p" ] \
|
||||
|| { case "${COMP_WORDS[$COMP_CWORD]}" in
|
||||
--profile=*) true;;
|
||||
*) false;;
|
||||
esac }
|
||||
}
|
||||
|
||||
_guix_complete_file ()
|
||||
{
|
||||
# Let Readline complete file names.
|
||||
|
@ -169,13 +187,28 @@ _guix_complete ()
|
|||
fi
|
||||
elif _guix_is_command "install"
|
||||
then
|
||||
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
|
||||
then
|
||||
_guix_complete_file
|
||||
else
|
||||
_guix_complete_available_package "$word_at_point"
|
||||
fi
|
||||
elif _guix_is_command "remove"
|
||||
then
|
||||
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
|
||||
then
|
||||
_guix_complete_file
|
||||
else
|
||||
_guix_complete_installed_package "$word_at_point"
|
||||
fi
|
||||
elif _guix_is_command "upgrade"
|
||||
then
|
||||
if _guix_is_dash_L || _guix_is_dash_m || _guix_is_dash_p
|
||||
then
|
||||
_guix_complete_file
|
||||
else
|
||||
_guix_complete_installed_package "$word_at_point"
|
||||
fi
|
||||
elif _guix_is_command "build"
|
||||
then
|
||||
if _guix_is_dash_L || _guix_is_dash_m
|
||||
|
@ -193,6 +226,18 @@ _guix_complete ()
|
|||
2) _guix_complete_subcommand;;
|
||||
*) _guix_complete_file;; # TODO: restrict to *.scm
|
||||
esac
|
||||
elif _guix_is_command "pull"
|
||||
then
|
||||
if _guix_is_dash_C || _guix_is_dash_p
|
||||
then
|
||||
_guix_complete_file
|
||||
fi
|
||||
elif _guix_is_command "time-machine"
|
||||
then
|
||||
if _guix_is_dash_C
|
||||
then
|
||||
_guix_complete_file
|
||||
fi
|
||||
elif _guix_is_command "container"
|
||||
then
|
||||
case $COMP_CWORD in
|
||||
|
|
Loading…
Reference in a new issue