author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 10 Dec 2023 22:23:26 +0200 | |
changeset 1035 | 1c38c02cfe9e |
permissions | -rw-r--r-- |
1035
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
# -*- mode: sh; sh-shell-file: bash -*- |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
_wsl() { |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
local tasks='--help (Display usage information) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
--debug-shell (Open a WSL2 debug shell for diagnostics purposes) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
--event-viewer (Opens the application view of the Windows Event Viewer) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
--unregister (deletes the root filesystem) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
--terminate (Terminates the specified distribution) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
--set-default (Sets the distribution as the default) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
--shutdown (Immediately terminates all running distributions) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
--release-notes (Opens a web browser to view the WSL release notes page) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
--manage (Changes distro specific options) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
--install (Install a Windows Subsystem for Linux distribution) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
--set-default-version (Changes the default install version for new distributions) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
--status (Show the status of Windows Subsystem for Linux) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
--update (Update the Windows Subsystem for Linux package) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
--version (Display version information) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
--list (Lists distributions) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
--export (Exports the distribution to a tar file) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
--import (Imports the specified tar file as a new distribution) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
--import-in-place (Imports the specified .vhdx file as a new distribution)' |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
|
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
local cur prev |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
cur=${COMP_WORDS[COMP_CWORD]} |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
[[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
26 |
|
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
27 |
if [[ $COMP_CWORD = 1 ]]; then |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
local OIFS="$IFS" |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
local IFS=$'\n' |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
30 |
COMPREPLY=( $(compgen -W '$tasks' -- "$cur") ) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
if [[ ${#COMPREPLY[@]} -le 1 ]]; then |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
COMPREPLY=( ${COMPREPLY[0]%% *} ) |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
fi |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
IFS=$OIFS |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
return |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
fi |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
return 0 |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
38 |
} && |
1c38c02cfe9e
Basic wsl Bash completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
complete -F _wsl wsl |