-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdocker.fzf
More file actions
executable file
·49 lines (46 loc) · 2.41 KB
/
docker.fzf
File metadata and controls
executable file
·49 lines (46 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# MIT License
#
# Copyright (c) 2026 Junegunn Choi
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
read -d '' -r list << 'SCRIPT'
{
echo $'ID\tNAMES\tIMAGE\tSTATUS\tMEM USAGE\tPORTS'
join -t $'\t' -j 1 -o '1.1 1.2 1.3 1.4 2.2 1.5' -a 1 \
<(docker ps --format $'{{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}' | sort) \
<(docker stats --no-stream --format $'{{.ID}}\t{{.MemUsage}}' | sort)
} | column -ts $'\t'
SCRIPT
fzf --ansi --info inline-right --reverse --header-lines 1 \
--style full --header-lines-border inline --no-input-border \
--border-label ' DOCKER ' --with-shell 'bash -c' \
--with-nth 2.. --color nth:regular,fg:dim \
--header 'Enter (exec) │ CTRL-O (logs in editor) │ CTRL-S (stop) │ CTRL-R (reload)
CTRL-T (top) │ CTRL-ALT-X (rm -f) │ CTRL-/ (toggle preview)' \
--bind "start:reload:$list" \
--bind "ctrl-r:reload:$list" \
--bind 'enter:execute:docker exec -it {2} bash || docker exec -it {2} sh' \
--bind 'ctrl-o:execute:docker logs {2} 2>&1 | view - +"setf log"' \
--bind "ctrl-s:execute-silent(docker stop {2})+reload:$list" \
--bind "ctrl-alt-x:execute-silent(docker rm -f {2})+reload:$list" \
--bind 'ctrl-t:execute:docker stats --no-stream {2}; docker top {2}; read' \
--bind 'ctrl-/:change-preview-window(80%|hidden|)' \
--preview-window bottom,follow \
--preview 'docker logs --follow --tail=500 {2}' "$@"