-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image: enable basic tab completion for bash
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# This file is derived from completion fragments at | ||
# https://github.com/OpenIndiana/openindiana-completions | ||
# | ||
# Portions Copyright 2006 Yann Rouillard <[email protected]> | ||
# Portions Copyright (c) 2013, Jonathan Perkin <[email protected]> | ||
# Portions copyright 2013, Nexenta Systems, Inc. | ||
# Portions Copyright (c) 2018, Michal Nowak <[email protected]> | ||
# Portions Copyright 2024 Oxide Computer Company | ||
|
||
shopt -s extglob progcomp | ||
|
||
_zlogin() | ||
{ | ||
local cur prev line | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
line="${COMP_LINE}" | ||
|
||
# zlogin [-dCEQ] [-e c] [-l username] zonename | ||
# zlogin [-nEQS] [-e c] [-l username] zonename utility [argument]... | ||
local opts="-E -Q -e -l" | ||
local opts_interactive="-d -C" | ||
local opts_util="-n -S" | ||
|
||
if [[ "${cur}" == -* ]] | ||
then | ||
case "${line}" in | ||
*\ -n\ *|*\ -S\ *) | ||
COMPREPLY=( $(compgen -W "${opts} ${opts_util}" -- "${cur}") ) | ||
;; | ||
*\ -d\ *|*\ -C\ *) | ||
COMPREPLY=( $(compgen -W "${opts} ${opts_interactive}" -- "${cur}") ) | ||
;; | ||
*) | ||
COMPREPLY=( $(compgen -W "${opts} ${opts_util} ${opts_interactive}" -- "${cur}") ) | ||
;; | ||
esac | ||
else | ||
# Provide running zone names | ||
local zones=$(zoneadm list -n) | ||
COMPREPLY=( $(compgen -W "${zones}" -- ${cur}) ) | ||
fi | ||
} | ||
|
||
_dash_z_zone() | ||
{ | ||
local cur prev | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
|
||
if [[ ${prev} =~ "-z" ]]; then | ||
local zones="$(zoneadm list -n $*)" | ||
COMPREPLY=( $(compgen -W "${zones}" -- ${cur}) ) | ||
fi | ||
} | ||
|
||
_dash_z_zone_running() { _dash_z_zone; } | ||
_dash_z_zone_configured() { _dash_z_zone -c; } | ||
|
||
complete -F _zlogin zlogin | ||
|
||
# Many illumos utilities are zone-aware through the -z option | ||
# | ||
complete -F _dash_z_zone_running allocate | ||
complete -F _dash_z_zone_running deallocate | ||
complete -F _dash_z_zone_running ipfs | ||
complete -F _dash_z_zone_running ipfstat | ||
complete -F _dash_z_zone_running ipmon | ||
complete -F _dash_z_zone_running ipnat | ||
complete -F _dash_z_zone_running ippool | ||
complete -F _dash_z_zone_running pgrep | ||
complete -F _dash_z_zone_running pkill | ||
complete -F _dash_z_zone_running ps | ||
complete -F _dash_z_zone_running psrset | ||
complete -F _dash_z_zone_running ptree | ||
complete -F _dash_z_zone_running svccfg | ||
complete -F _dash_z_zone_running svcprop | ||
complete -F _dash_z_zone_running wall | ||
|
||
complete -F _dash_z_zone_configured auditreduce | ||
complete -F _dash_z_zone_configured zoneadm | ||
complete -F _dash_z_zone_configured zonecfg | ||
|
||
# ex: filetype=sh | ||
# vim: tabstop=2 shiftwidth=2 expandtab |
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