-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zsh completions reworked. fixed not completing container names.
- Loading branch information
1 parent
18053c2
commit 3848ac9
Showing
16 changed files
with
279 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,3 @@ case $state in | |
;; | ||
esac | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,46 @@ | ||
#compdef distrobox-create | ||
|
||
_arguments -s \ | ||
'(--image -i)'{-i,--image}'[image to use for the container]:image:_files' \ | ||
'(--name -n)'{-n,--name}'[name for the distrobox]:name:' \ | ||
'(--pull -p)'{-p,--pull}'[pull the image even if it exists locally (implies --yes)]' \ | ||
'(--yes -Y)'{-Y,--yes}'[non-interactive, pull images without asking]' \ | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' \ | ||
'(--clone -c)'{-c,--clone}'[name of the distrobox container to use as base for a new container]:clone container name:' \ | ||
'(--home -H)'{-H,--home}'[select a custom HOME directory for the container]:path:_files -/' \ | ||
'--volume[additional volumes to add to the container]:volume:_files' \ | ||
'(--additional-flags -a)'{-a,--additional-flags}'[additional flags to pass to the container manager command]:flags:' \ | ||
'(--additional-packages -ap)'{-ap,--additional-packages}'[additional packages to install during initial container setup]:package:' \ | ||
'--init-hooks[additional commands to execute during container initialization]:command:' \ | ||
'--pre-init-hooks[additional commands to execute prior to container initialization]:command:' \ | ||
'(--init -I)'{-I,--init}'[use init system inside the container]' \ | ||
'--nvidia[try to integrate host nVidia drivers in the guest]' \ | ||
'--unshare-devsys[do not share host devices and sysfs dirs from host]' \ | ||
'--unshare-ipc[do not share ipc namespace with host]' \ | ||
'--unshare-netns[do not share the net namespace with host]' \ | ||
'--unshare-process[do not share process namespace with host]' \ | ||
'--unshare-all[activate all the unshare flags]' \ | ||
'(--compatibility -C)'{-C,--compatibility}'[show list of compatible images]' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'--no-entry[do not generate a container entry in the application list]' \ | ||
'(--dry-run -d)'{-d,--dry-run}'[only print the container manager command generated]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' \ | ||
'--absolutely-disable-root-password-i-am-really-positively-sure[skip user password setup, leaving it blank]' | ||
_distrobox-create() { | ||
local -a options | ||
local expl | ||
local state | ||
# Array of optargs to pass to _arguments for matching and completion | ||
options=( | ||
'(-i --image)'{-i,--image}'[Specify image to use for the container]:image:_distrobox_images' | ||
'(-n --name)'{-n,--name}'[Specify name for the distrobox]:distrobox name:' | ||
'--hostname[Specify hostname for the distrobox]:hostname:' | ||
'(-p --pull)'{-p,--pull}'[Pull the image even if it exists locally (implies --yes)]' | ||
'(-Y --yes)'{-Y,--yes}'[Non-interactive, pull images without asking]' | ||
'(-r --root)'{-r,--root}'[Launch with root privileges using podman/docker/lilipod]' | ||
'(-c --clone)'{-c,--clone}'[Name of the distrobox container to use as base for a new container]:clone container name:' | ||
'(-H --home)'{-H,--home}'[Select a custom HOME directory for the container]:path:_files -/' | ||
'--volume[Add additional volumes to the container]:volume:_files' | ||
'(-a --additional-flags)'{-a,--additional-flags}'[Additional flags to pass to the container manager command]:flags:' | ||
'(-ap --additional-packages)'{-ap,--additional-packages}'[Additional packages to install during setup]:package:' | ||
'--init-hooks[Commands to execute during container initialization]:command:' | ||
'--pre-init-hooks[Commands to execute prior to container initialization]:command:' | ||
'(-I --init)'{-I,--init}'[Use an init system inside the container]' | ||
'--nvidia[Try to integrate host nVidia drivers into the guest]' | ||
'--unshare-devsys[Do not share host devices and sysfs dirs from host]' | ||
'--unshare-groups[Do not forward users additional groups into the container]' | ||
'--unshare-ipc[Do not share ipc namespace with host]' | ||
'--unshare-netns[Do not share the net namespace with host]' | ||
'--unshare-process[Do not share process namespace with host]' | ||
'--unshare-all[Activate all the unshare flags]' | ||
'(-C --compatibility)'{-C,--compatibility}'[Show list of compatible images]' | ||
'(-h --help)'{-h,--help}'[Show this message]' | ||
'--no-entry[Do not generate a container entry in the application list]' | ||
'(-d --dry-run)'{-d,--dry-run}'[Only print the container manager command generated]' | ||
'(-v --verbose)'{-v,--verbose}'[Show more verbosity]' | ||
'(-V --version)'{-V,--version}'[Show version]' | ||
'--absolutely-disable-root-password-i-am-really-positively-sure[Skip user password setup, leaving it blank]' | ||
) | ||
# Simple logic | ||
_message -r "Create new distroboxes." | ||
_arguments \ | ||
'1:containers:->container' \ | ||
'*:options:->options' \ | ||
$options[@] | ||
} | ||
|
||
_distrobox-create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
#compdef distrobox-enter | ||
|
||
_arguments -s \ | ||
'(--name -n)'{-n,--name}'[name for the distrobox]:distrobox name:' \ | ||
'--[end arguments and execute the rest as command to execute at login]:command:_command_names' \ | ||
'(--no-tty -T)'{-T,--no-tty}'[do not instantiate a tty]' \ | ||
'(--no-workdir -nw)'{-nw,--no-workdir}'[always start the container from container home directory]' \ | ||
'(--additional-flags -a)'{-a,--additional-flags}'[additional flags to pass to the container manager command]:flags:' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' \ | ||
'(--dry-run -d)'{-d,--dry-run}'[only print the container manager command generated]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' | ||
_distrobox-enter() { | ||
local -a options | ||
local expl | ||
local state | ||
local _db_cc | ||
|
||
_db_cc=("${(@f)$(distrobox list | sed 1d | awk -F'|' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')}") | ||
|
||
options=( | ||
'(--name -n)'{-n,--name}'[name for the distrobox]:container:_distrobox_containers' | ||
'--[end arguments and execute the rest as command to execute at login]:command:_command_names' | ||
'(--no-tty -T)'{-T,--no-tty}'[do not instantiate a tty]' | ||
'(--no-workdir -nw)'{-nw,--no-workdir}'[always start the container from container home directory]' | ||
'(--additional-flags -a)'{-a,--additional-flags}'[additional flags to pass to the container manager command]:flags:' | ||
'(--help -h)'{-h,--help}'[show this message]' | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' | ||
'(--dry-run -d)'{-d,--dry-run}'[only print the container manager command generated]' | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' | ||
'(--version -V)'{-V,--version}'[show version]' | ||
) | ||
_message -r "Start and enter a distrobox." | ||
if [[ -n "$_db_cc" ]]; then | ||
_arguments -C \ | ||
'1:containers:_distrobox_containers' \ | ||
$options[@] | ||
else | ||
_message -r "No containers exist." | ||
_arguments $options[@] | ||
fi | ||
|
||
} | ||
|
||
_distrobox-enter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
#compdef distrobox-ephemeral | ||
|
||
_arguments -s \ | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'--[end arguments and execute the rest as command to execute at login]:command:_command_names' \ | ||
'(--version -V)'{-V,--version}'[show version]' \ | ||
'(--image -i)'{-i,--image}'[image to use for the container]:image:_files' \ | ||
'(--name -n)'{-n,--name}'[name for the distrobox]:name:' \ | ||
'(--pull -p)'{-p,--pull}'[pull the image even if it exists locally (implies --yes)]' \ | ||
'(--yes -Y)'{-Y,--yes}'[non-interactive, pull images without asking]' \ | ||
'(--clone -c)'{-c,--clone}'[name of the distrobox container to use as base for a new container]:clone container name:' \ | ||
'(--home -H)'{-H,--home}'[select a custom HOME directory for the container]:path:_files -/' \ | ||
'--volume[additional volumes to add to the container]:volume:_files' \ | ||
'(--additional-flags -a)'{-a,--additional-flags}'[additional flags to pass to the container manager command]:flags:' \ | ||
'(--additional-packages -ap)'{-ap,--additional-packages}'[additional packages to install during initial container setup]:package:' \ | ||
'--init-hooks[additional commands to execute during container initialization]:command:' \ | ||
'--pre-init-hooks[additional commands to execute prior to container initialization]:command:' \ | ||
'(--init -I)'{-I,--init}'[use init system inside the container]' \ | ||
'--nvidia[try to integrate hosts nVidia drivers in the guest]' \ | ||
'--unshare-devsys[do not share host devices and sysfs dirs from host]' \ | ||
'--unshare-ipc[do not share ipc namespace with host]' \ | ||
'--unshare-netns[do not share the net namespace with host]' \ | ||
'--unshare-process[do not share process namespace with host]' \ | ||
'--unshare-all[activate all the unshare flags]' \ | ||
'(--compatibility -C)'{-C,--compatibility}'[show list of compatible images]' \ | ||
'--no-entry[do not generate a container entry in the application list]' \ | ||
'(--dry-run -d)'{-d,--dry-run}'[only print the container manager command generated]' \ | ||
'--absolutely-disable-root-password-i-am-really-positively-sure[skip user password setup, leaving it blank]' | ||
_distrobox-ephemeral() { | ||
local -a options | ||
local expl | ||
local state | ||
# Array of optargs to pass to _arguments for matching and completion | ||
options=( | ||
'(-i --image)'{-i,--image}'[Specify image to use for the container]:image:_distrobox_images' | ||
'(-n --name)'{-n,--name}'[Specify name for the distrobox]:distrobox name:' | ||
'--hostname[Specify hostname for the distrobox]:hostname:' | ||
'(-p --pull)'{-p,--pull}'[Pull the image even if it exists locally (implies --yes)]' | ||
'(-Y --yes)'{-Y,--yes}'[Non-interactive, pull images without asking]' | ||
'(-r --root)'{-r,--root}'[Launch with root privileges using podman/docker/lilipod]' | ||
'(-c --clone)'{-c,--clone}'[Name of the distrobox container to use as base for a new container]:clone container name:' | ||
'(-H --home)'{-H,--home}'[Select a custom HOME directory for the container]:path:_files -/' | ||
'--volume[Add additional volumes to the container]:volume:_files' | ||
'(-a --additional-flags)'{-a,--additional-flags}'[Additional flags to pass to the container manager command]:flags:' | ||
'(-ap --additional-packages)'{-ap,--additional-packages}'[Additional packages to install during setup]:package:' | ||
'--init-hooks[Commands to execute during container initialization]:command:' | ||
'--pre-init-hooks[Commands to execute prior to container initialization]:command:' | ||
'(-I --init)'{-I,--init}'[Use an init system inside the container]' | ||
'--nvidia[Try to integrate host nVidia drivers into the guest]' | ||
'--unshare-devsys[Do not share host devices and sysfs dirs from host]' | ||
'--unshare-groups[Do not forward users additional groups into the container]' | ||
'--unshare-ipc[Do not share ipc namespace with host]' | ||
'--unshare-netns[Do not share the net namespace with host]' | ||
'--unshare-process[Do not share process namespace with host]' | ||
'--unshare-all[Activate all the unshare flags]' | ||
'(-C --compatibility)'{-C,--compatibility}'[Show list of compatible images]' | ||
'(-h --help)'{-h,--help}'[Show this message]' | ||
'--no-entry[Do not generate a container entry in the application list]' | ||
'(-d --dry-run)'{-d,--dry-run}'[Only print the container manager command generated]' | ||
'(-v --verbose)'{-v,--verbose}'[Show more verbosity]' | ||
'(-V --version)'{-V,--version}'[Show version]' | ||
'--absolutely-disable-root-password-i-am-really-positively-sure[Skip user password setup, leaving it blank]' | ||
) | ||
# Simple logic | ||
_message -r "Create temporary distroboxes that are auto destroyed." | ||
_arguments \ | ||
'1:containers:->container' \ | ||
'*:options:->options' \ | ||
$options[@] | ||
} | ||
|
||
_distrobox-ephemeral |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
#compdef distrobox-generate-entry | ||
|
||
_arguments -s \ | ||
':container name:_files' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'(--all -a)'{-a,--all}'[perform for all distroboxes]' \ | ||
'(--delete -d)'{-d,--delete}'[delete the entry]' \ | ||
'(--icon -i)'{-i,--icon}'[specify a custom icon (default auto)]:icon path:_files' \ | ||
'(--root -r)'{-r,--root}'[perform on rootful distroboxes]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' | ||
_distrobox-generate-entry() { | ||
# expl is an internal zsh array that gets passed to _arguments bts | ||
local expl | ||
local -a options | ||
local _db_cc | ||
# Check for existing containers and store the result into var _db_cc | ||
_db_cc=("${(@f)$(distrobox list | sed 1d | awk -F'|' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')}") | ||
# Array of optargs to pass to _arguments for matching and completion | ||
options=( | ||
'(-h --help)'{-h,--help}'[show this message]' | ||
'(-a --all)'{-a,--all}'[perform for all distroboxes]' | ||
'(-d --delete)'{-d,--delete}'[delete the entry]' | ||
'(-i --icon)'{-i,--icon}'[specify a custom icon (default auto)]:icon path:(auto _files)' | ||
'(-r --root)'{-r,--root}'[perform on rootful distroboxes]' | ||
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' | ||
'(-V --version)'{-V,--version}'[show version]' | ||
) | ||
_message -r "Create a desktop icon for a distrobox" | ||
# If containers exist then do an action | ||
if [[ -n "$_db_cc" ]]; then | ||
# Match both container names and optargs | ||
_arguments \ | ||
'*:containers:_distrobox_containers' \ | ||
$options[@] | ||
# If no containers exist then do an action | ||
else | ||
# Display message to user and match optargs only | ||
_message -r "No containers exist." | ||
_arguments $options[@] | ||
fi | ||
} | ||
|
||
_distrobox-generate-entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
#compdef distrobox-host-exec | ||
|
||
_message -r "Execute a command on the host while in a container" | ||
_arguments \ | ||
'*:command:_command' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' \ | ||
'(--yes -Y)'{-Y,--yes}'[Automatically answer yes to prompt host-spawn will be installed on the guest system if not detected]' \ | ||
'*:command:->command' | ||
|
||
case $state in | ||
command) | ||
_command | ||
;; | ||
esac | ||
'(--yes -Y)'{-Y,--yes}'[Automatically answer yes to prompt host-spawn will be installed on the guest system if not detected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
#compdef distrobox-rm | ||
|
||
_arguments \ | ||
'(--all -a)'{-a,--all}'[delete all distroboxes]' \ | ||
'(--force -f)'{-f,--force}'[force deletion]' \ | ||
'--rm-home[remove the mounted home if it differs from the host users one]' \ | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' \ | ||
'*:container name:_files' | ||
_distrobox-rm() { | ||
# expl is an internal zsh array that gets passed to _arguments bts | ||
local expl | ||
local -a options | ||
local _db_cc | ||
# Check for existing containers and store the result into var _db_cc | ||
_db_cc=("${(@f)$(distrobox list | sed 1d | awk -F'|' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')}") | ||
# Array of optargs to pass to _arguments for matching and completion | ||
options=( | ||
'(-a --all)'{-a,--all}'[delete all distroboxes]' | ||
'(-f --force)'{-f,--force}'[force deletion]' | ||
'--rm-home[remove the mounted home if it differs from the host users one]' | ||
'(-r --root)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' | ||
'(-h --help)'{-h,--help}'[show this message]' | ||
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' | ||
'(-V --version)'{-V,--version}'[show version]' | ||
) | ||
_message -r "Delete one or more distroboxes." | ||
# If containers exist then do an action | ||
if [[ -n "$_db_cc" ]]; then | ||
# Match both container names and optargs | ||
_arguments \ | ||
'*:containers:_distrobox_containers' \ | ||
$options[@] | ||
# If no containers exist then do an action | ||
else | ||
# Display message to user and match optargs only | ||
_message -r "No containers exist." | ||
_arguments $options[@] | ||
fi | ||
|
||
} | ||
|
||
_distrobox-rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
#compdef distrobox-stop | ||
|
||
_arguments \ | ||
'--name[specify container name]:container name:' \ | ||
'(--all -a)'{-a,--all}'[stop all distroboxes]' \ | ||
'(--yes -Y)'{-Y,--yes}'[non-interactive, stop without asking]' \ | ||
'(--help -h)'{-h,--help}'[show this message]' \ | ||
'(--root -r)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' \ | ||
'(--verbose -v)'{-v,--verbose}'[show more verbosity]' \ | ||
'(--version -V)'{-V,--version}'[show version]' \ | ||
':container name:_files' | ||
_distrobox-stop() { | ||
local expl | ||
local -a options | ||
local _db_rcc | ||
|
||
_db_rcc=($(distrobox list | awk -F'|' '$3 ~ /Up/ { gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2 }')) | ||
|
||
options=( | ||
'(-a --all)'{-a,--all}'[stop all distroboxes]' | ||
'(-Y --yes)'{-Y,--yes}'[non-interactive, stop without asking]' | ||
'(-r --root)'{-r,--root}'[launch podman/docker/lilipod with root privileges]' | ||
'(-h --help)'{-h,--help}'[show this message]' | ||
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' | ||
'(-V --version)'{-V,--version}'[show version]' | ||
) | ||
|
||
_message -r "Stop running distrobox containers." | ||
if [[ -n "$_db_rcc" ]]; then | ||
_arguments -C \ | ||
'*:containers:_distrobox_running_containers' \ | ||
$options[@] | ||
else | ||
_message -r "No running containers." | ||
_arguments $options[@] | ||
fi | ||
|
||
} | ||
|
||
_distrobox-stop |
Oops, something went wrong.