Last active
February 17, 2021 19:18
-
-
Save akarzim/6a0d679ef8e61d728be47bd7f47362de to your computer and use it in GitHub Desktop.
Revisions
-
akarzim revised this gist
Dec 23, 2018 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,10 +10,22 @@ Defines [Docker][1] aliases and functions. - `dkE!` Run an interactive command in a running container by name - `dkps!` Display the first matching docker container ID by name ## How to use ### With [zplug][2] ```sh zplug "akarzim/6a0d679ef8e61d728be47bd7f47362de", \ from:gist, \ use:"zsh-docker-bang-aliases.zsh", \ if:"(( $+commands[docker] ))" ``` ## Acknowledgements Please consider [akarzim/zsh-docker-aliases][3] by [François Vantomme][4] (MIT License). [1]: https://www.docker.com/ [2]: https://github.com/zplug/zplug [3]: https://github.com/akarzim/zsh-docker-aliases [4]: https://github.com/akarzim -
akarzim created this gist
Dec 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # ZSH Docker Aliases Defines [Docker][1] aliases and functions. ## Aliases ### Docker - `dka!` Attach to a running container by name - `dkE!` Run an interactive command in a running container by name - `dkps!` Display the first matching docker container ID by name ## Acknowledgements Please consider [akarzim/zsh-docker-aliases][2] by [François Vantomme][3] (MIT License). [1]: https://www.docker.com/ [2]: https://github.com/akarzim/zsh-docker-aliases [3]: https://github.com/akarzim This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # Display the first matching docker container ID by name # # Usage: dkps! app # > docker ps -f "name=app" -f "status=running" -q | head -n 1 function dkps! { docker ps -f "name=$1" -f "status=running" -q | head -n 1 } # Attatch docker by container partial name # # Usage: dka! app # > docker attach $(docker ps -f "name=app" -f "status=running" -q | head -n 1) function dka! { docker attach $(dkps! $1) } # Exec docker interactive command by container partial name # # Usage: dkE! app bash # > docker exec -e COLUMNS=`tput cols` -e LINES=`tput lines` -it $(docker ps -f "name=app" -f "status=running" -q | head -n 1) bash function dkE! { docker exec -e COLUMNS=`tput cols` -e LINES=`tput lines` -it $(dkps! $1) $*[2,$] }