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.
pull/908/head
Dylan Semler 2017-02-15 06:31:10 -05:00
parent c58088b509
commit d81c35d752
1 changed files with 2 additions and 2 deletions

View File

@ -4,13 +4,13 @@ about-plugin 'Helpers to more easily work with Docker'
function docker-remove-most-recent-container() { function docker-remove-most-recent-container() {
about 'attempt to remove the most recent container from docker ps -a' about 'attempt to remove the most recent container from docker ps -a'
group 'docker' 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() { function docker-remove-most-recent-image() {
about 'attempt to remove the most recent image from docker images' about 'attempt to remove the most recent image from docker images'
group 'docker' 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() { function docker-enter() {