Skip to content

Instantly share code, notes, and snippets.

@yan-kisen
Forked from GottZ/dps.sh
Last active November 19, 2015 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yan-kisen/e395353b2d479d5b32ca to your computer and use it in GitHub Desktop.
Save yan-kisen/e395353b2d479d5b32ca to your computer and use it in GitHub Desktop.
/etc/profile.d/dps.sh
# Docker PS prettifier
# revision 7
# https://gist.github.com/GottZ/4a6c2af314d73cd8b71d
dps() {
docker ps $@ --format "table{{ .ID }}\\t{{ .Image }}\\t{{ .Names }}\\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";
}
'
}
dpsa() { dps -a $@; }
@yan-kisen
Copy link
Author

  1. Save file as /etc/profile.d/dps.sh

  2. Update /etc/profile

    for PROFILE_SCRIPT in $( ls /etc/profile.d/*.sh );  do 
    .  $PROFILE_SCRIPT
    done 
  3. Run with dps -a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment