Skip to content

Instantly share code, notes, and snippets.

@scmrus
Created June 25, 2016 11:51
Show Gist options
  • Save scmrus/62b917dd8a5059a30cb1b490c7fac9d9 to your computer and use it in GitHub Desktop.
Save scmrus/62b917dd8a5059a30cb1b490c7fac9d9 to your computer and use it in GitHub Desktop.
alias drm="docker run --rm -it"
dps(){
docker ps $@ --format "table{{.ID}}\\t{{ .Names }}\\t{{ .Image }}\\t{{ .Status }}\\t{{ .Ports }}" | awk '
NR % 2 == 0 {
printf "\033[0m";
}
NR % 2 == 1 {
printf "\033[1m";
}
NR == 1 {
PORTSPOS = index($0, "PORTS");
PORTS = "PORTS";
PORTSPADDING = "\n";
for(n = 1; n < PORTSPOS; n++)
PORTSPADDING = PORTSPADDING " ";
}
NR > 1 {
PORTS = substr($0, PORTSPOS);
gsub(/, /, PORTSPADDING, PORTS);
}
{
printf "%s%s\n", substr($0, 0, PORTSPOS - 1), PORTS;
}
END {
printf "\033[0m";
}
'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment