diff --git a/README.md b/README.md index 1edfb07..548716a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ # vim-docker-tools -![demo](https://thumbs.gfycat.com/JitteryHealthyAmericanshorthair-size_restricted.gif) + +![demo](https://thumbs.gfycat.com/JitteryHealthyAmericanshorthair-size_restricted.gif) + * Open DockerTools Panel with `:DockerToolsOpen`, close it with `:DockerToolsClose` * Toggle DockerTools Panel with `:DockerToolsToggle` * Set Docker daemon host with `:DockerToolsSetHost` * Support `:ContainerStart`, `:ContainerStop`, `:ContainerRemove`, `:ContainerRestart`, `:ContainerPause`, `:ContainerUnpause`, `:ContainerLogs`. For details please check out the documentation (`:help docker-tools-commands`). * Autocompletion for container commands * Full documentation in `:help vim-docker-tools` -# Install + +## Install + * Pathogen * `git clone https://github.com/kevinhui/vim-docker-tools.git ~/.vim/bundle/vim-docker-tools` * Vim-plug @@ -17,5 +21,7 @@ * `Plugin 'kevinhui/vim-docker-tools'` * Manual * Copy all of the files into your `~/.vim` directory -# Contributing + +## Contributing + Feel free to raise any questions/issues/comments. Submit pull request as you want. diff --git a/autoload/docker_tools.vim b/autoload/docker_tools.vim index 4de1d4a..e1a8b4b 100644 --- a/autoload/docker_tools.vim +++ b/autoload/docker_tools.vim @@ -66,6 +66,13 @@ function! docker_tools#dt_toggle_help() abort call s:dt_ui_load() endfunction +function! docker_tools#dt_attach() abort + if s:dt_container_selected() + let containerid = s:dt_get_id() + call s:term_win_open(printf('%s%s exec -it %s /bin/sh -c "[ -e /bin/bash ] && /bin/bash || /bin/sh"',s:sudo_mode(),g:dockertools_docker_cmd,containerid),containerid) + endif +endfunction + function! docker_tools#dt_toggle_all() abort let b:show_all_containers = !b:show_all_containers call s:dt_ui_load() @@ -128,6 +135,7 @@ function! s:dt_set_mapping() abort nnoremap r :call docker_tools#dt_action('restart') nnoremap p :call docker_tools#dt_action('pause') nnoremap u :call docker_tools#dt_action('unpause') + nnoremap t :call docker_tools#dt_attach() nnoremap > :call docker_tools#dt_run_command() nnoremap < :call docker_tools#dt_logs() nnoremap a :call docker_tools#dt_toggle_all() @@ -170,6 +178,7 @@ function! s:dt_get_help() abort let help .= "# x: delete container\n" let help .= "# p: pause container\n" let help .= "# u: unpause container\n" + let help .= "# t: attach container window\n" let help .= "# >: execute command to container\n" let help .= "# <: show container logs\n" let help .= "# a: toggle show all/running containers\n" diff --git a/doc/vim-docker-tools.txt b/doc/vim-docker-tools.txt index 5ee0b8a..e099984 100644 --- a/doc/vim-docker-tools.txt +++ b/doc/vim-docker-tools.txt @@ -110,6 +110,7 @@ MAPPINGS *docker-tools-mappings* x | Delete container. p | Pause container. u | Unpause container. + t | Attach container window. > | Execute command to container. < | Show container logs. a | Toggle show all/running containers.