Compare commits

...

5 Commits

Author SHA1 Message Date
Segev Finer d048ec81cb
Merge ec601dd5bc into 81401f37f2 2024-11-20 10:10:05 +00:00
Sebastiaan van Stijn 81401f37f2
Merge pull request #5625 from Giedriusj1/master
Optimise `docker stats` to not require clearing the whole screen
2024-11-19 12:48:26 +01:00
Giedrius Jonikas cb2f95ceee Optimise `docker stats` to not require clearing the whole screen
Instead of clearing the whole screen and then writing the new stats,
we now write the new stats on top of the old text, and then clear
the remaining text.

This is a more efficient way to update the stats, as it avoids the
flickering that happens when the screen is cleared and rewritten.

Signed-off-by: Giedrius Jonikas <giedriusj1@gmail.com>
2024-11-16 15:29:57 +00:00
Segev Finer ec601dd5bc Fix docker container update completion in Zsh
A missing '$'

Signed-off-by: Segev Finer <segev208@gmail.com>
2018-01-06 10:35:09 +02:00
Segev Finer 9258d941b2 Complete running containers correctly after docker rm -vf in Zsh
When using option-stacking the -f flag that controls completing running
containers can be a part of another word of options, so use opt_args
that contains the parsed arguments from _arguments to check for it
instead.

Signed-off-by: Segev Finer <segev208@gmail.com>
2018-01-06 10:34:53 +02:00
2 changed files with 14 additions and 4 deletions

View File

@ -287,16 +287,26 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
cStats.mu.RUnlock()
if !options.NoStream {
// Start by clearing the screen and moving the cursor to the top-left
_, _ = fmt.Fprint(&statsTextBuffer, "\033[2J\033[H")
// Start by moving the cursor to the top-left
_, _ = fmt.Fprint(&statsTextBuffer, "\033[H")
}
if err = statsFormatWrite(statsCtx, ccStats, daemonOSType, !options.NoTrunc); err != nil {
break
}
_, _ = fmt.Fprint(dockerCLI.Out(), statsTextBuffer.String())
if !options.NoStream {
for _, line := range strings.Split(statsTextBuffer.String(), "\n") {
// In case the new text is shorter than the one we are writing over,
// we'll append the "erase line" escape sequence to clear the remaining text.
_, _ = fmt.Fprint(&statsTextBuffer, line, "\033[K\n")
}
// We might have fewer containers than before, so let's clear the remaining text
_, _ = fmt.Fprint(&statsTextBuffer, "\033[J")
}
_, _ = fmt.Fprint(dockerCLI.Out(), statsTextBuffer.String())
statsTextBuffer.Reset()
if len(cStats.cs) == 0 && !showAll {

View File

@ -849,7 +849,7 @@ __docker_container_subcommand() {
"($help -)*:containers:->values" && ret=0
case $state in
(values)
if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then
if [[ -n ${opt_args[(i)-f]} || -n ${opt_args[(i)--force]} ]]; then
__docker_complete_containers && ret=0
else
__docker_complete_stopped_containers && ret=0