Last active
August 29, 2015 14:17
-
-
Save osamu2001/a4dcce1c806cc1bb597e to your computer and use it in GitHub Desktop.
TRAMPを使ってdockerコンテナ内のファイルを開く ref: http://qiita.com/osamu2001/items/3058f7c3e3d8d9a6e532
This file contains 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 characters
;; http://www.emacswiki.org/emacs/TrampAndDocker | |
(push | |
(cons | |
"docker" | |
'((tramp-login-program "docker") | |
(tramp-login-args (("exec" "-it") ("%h") ("/bin/bash"))) | |
(tramp-remote-shell "/bin/sh") | |
(tramp-remote-shell-args ("-i") ("-c")))) | |
tramp-methods) | |
(defadvice tramp-completion-handle-file-name-all-completions | |
(around dotemacs-completion-docker activate) | |
"(tramp-completion-handle-file-name-all-completions \"\" \"/docker:\" returns | |
a list of active Docker container names, followed by colons." | |
(if (equal (ad-get-arg 1) "/docker:") | |
(let* ((dockernames-raw (shell-command-to-string "docker ps | perl -we 'use strict; $_ = <>; m/^(.*)NAMES/ or die; my $offset = length($1); while(<>) {substr($_, 0, $\ | |
offset, q()); chomp; for(split m/\\W+/) {print qq($_:\n)} }'")) | |
(dockernames (cl-remove-if-not | |
#'(lambda (dockerline) (string-match ":$" dockerline)) | |
(split-string dockernames-raw "\n")))) | |
(setq ad-return-value dockernames)) | |
ad-do-it)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment