From d81c35d7527bdb4aca2beec7454bee5c89219496 Mon Sep 17 00:00:00 2001 From: Dylan Semler Date: Wed, 15 Feb 2017 06:31:10 -0500 Subject: [PATCH] Simplify docker functions Instead of piping the standard output of `docker ps` and `docker images` through a series of heads, tails, and awks, use the flags available to the `docker` command to achieve the same goal. --- plugins/available/docker.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/docker.plugin.bash b/plugins/available/docker.plugin.bash index 4a2abbd7..0a93c245 100644 --- a/plugins/available/docker.plugin.bash +++ b/plugins/available/docker.plugin.bash @@ -4,13 +4,13 @@ about-plugin 'Helpers to more easily work with Docker' function docker-remove-most-recent-container() { about 'attempt to remove the most recent container from docker ps -a' group 'docker' - docker ps -a | head -2 | tail -1 | awk '{print $NF}' | xargs docker rm + docker ps -ql | xargs docker rm } function docker-remove-most-recent-image() { about 'attempt to remove the most recent image from docker images' group 'docker' - docker images | head -2 | tail -1 | awk '{print $3}' | xargs docker rmi + docker images -q | head -1 | xargs docker rmi } function docker-enter() {