From 0ab7cb06285f72bfb45d86e97e586d07001a27b4 Mon Sep 17 00:00:00 2001 From: Michael Christensen Date: Thu, 17 Jan 2019 00:03:09 -0800 Subject: [PATCH] Adding a couple shortcuts for working with Docker --- Examples.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Examples.md b/Examples.md index 91a75e6..6faacfa 100644 --- a/Examples.md +++ b/Examples.md @@ -45,6 +45,7 @@ Table of Contents * [fzf-marker](#fzf-marker) * [Search for academic pdfs by author, title, keywords, abstract](#search-for-academic-pdfs-by-author-title-journal-institution) * [BibTeX](#bibtex) +* [Docker](#docker) @@ -1158,4 +1159,25 @@ Search records in BibTeX files using FZF, select records to cite, or pretty prin ![](https://d.pr/i/8uXzLx+ "screenshot") -This plugin is at https://github.com/msprev/fzf-bibtex \ No newline at end of file +This plugin is at https://github.com/msprev/fzf-bibtex + +### Docker + +```sh +# Select a docker container to start and attach to +function da() { + local cid + cid=$(docker ps -a | sed 1d | fzf -1 -q "$1" | awk '{print $1}') + + [ -n "$cid" ] && docker start "$cid" && docker attach "$cid" +} +``` + +```sh +# Select a running docker container to stop +function ds() { + local cid + cid=$(docker ps | sed 1d | fzf -q "$1" | awk '{print $1}') + + [ -n "$cid" ] && docker stop "$cid" +} \ No newline at end of file