Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
hg-misc-tools
Commits
e90c927f
Commit
e90c927f
authored
Feb 26, 2026
by
one
Browse files
Add hy-smi completion
parent
37b24a07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
shell/bash-completion/README.md
shell/bash-completion/README.md
+20
-0
shell/bash-completion/hy-smi
shell/bash-completion/hy-smi
+69
-0
No files found.
shell/bash-completion/README.md
0 → 100644
View file @
e90c927f
## Prerequisites
-
`bash-completion`
## Install
Download completion scripts and put them in the following directory.
```
bash
mkdir
-p
~/.local/share/bash-completion/completions
```
Enable bash-completion (if not globally enabled):
```
bash
# ~/.bashrc
if
[
-f
/etc/bash_completion
]
&&
!
shopt
-oq
posix
;
then
.
/etc/bash_completion
fi
```
\ No newline at end of file
shell/bash-completion/hy-smi
0 → 100644
View file @
e90c927f
#!/usr/bin/env bash
_hy_smi_completion
()
{
local
cur prev subcmds
COMPREPLY
=()
cur
=
"
${
COMP_WORDS
[COMP_CWORD]
}
"
prev
=
"
${
COMP_WORDS
[COMP_CWORD-1]
}
"
# Subcommands
subcmds
=
"virtual mig"
# If cache variable _HY_SMI_OPTS is empty, parse options from help output.
if
[[
-z
"
$_HY_SMI_OPTS
"
]]
;
then
# Extract only valid short/long options (e.g. -h, --help),
# avoiding punctuation-contaminated tokens like -h' or --foo.
export
_HY_SMI_OPTS
=
$(
hy-smi
-h
2>/dev/null |
awk
'{
for(i=1;i<=NF;i++) {
token=$i
while (match(token, /--[A-Za-z0-9][A-Za-z0-9-]*|-[A-Za-z0-9]/)) {
print substr(token, RSTART, RLENGTH)
token=substr(token, RSTART + RLENGTH)
}
}
}'
|
sort
-u
)
fi
# Provide intelligent suggestions for specific parameters (prev)
case
"
${
prev
}
"
in
--load
|
--save
|
--filename
|
-fdmon
)
COMPREPLY
=(
$(
compgen
-f
--
"
${
cur
}
"
)
)
return
0
;;
--loglevel
)
COMPREPLY
=(
$(
compgen
-W
"debug info warning error critical"
--
"
${
cur
}
"
)
)
return
0
;;
--setperflevel
)
COMPREPLY
=(
$(
compgen
-W
"auto low high manual"
--
"
${
cur
}
"
)
)
return
0
;;
--setecc
)
COMPREPLY
=(
$(
compgen
-W
"on off stable"
--
"
${
cur
}
"
)
)
return
0
;;
--direction
)
COMPREPLY
=(
$(
compgen
-W
"0 1"
--
"
${
cur
}
"
)
)
return
0
;;
--enablelowpower
|
--setautoloaddriver
|
--setautorunhyckptd
|
-mig
|
--multi-instance-gpu
)
COMPREPLY
=(
$(
compgen
-W
"0 1"
--
"
${
cur
}
"
)
)
return
0
;;
--setboost
)
COMPREPLY
=(
$(
compgen
-W
"0-AI(default), 1-HPC(default), 2-AI(typical), 3-HPC(typical)"
--
"
${
cur
}
"
)
)
return
0
;;
esac
if
[[
${
cur
}
==
-
*
]]
;
then
# Only complete the dynamically extracted flags
COMPREPLY
=(
$(
compgen
-W
"
${
_HY_SMI_OPTS
}
"
--
"
${
cur
}
"
)
)
return
0
fi
# Default complete all flags and subcommands
COMPREPLY
=(
$(
compgen
-W
"
${
_HY_SMI_OPTS
}
${
subcmds
}
"
--
"
${
cur
}
"
)
)
}
complete
-o
default
-F
_hy_smi_completion hy-smi
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment