Turns out it was projectile that was causing the problems. As soon as I disabled projectile-mode TRAMP was buttery smooth and I began to understand the hype behind it.
Hopefully this helps out someone else who has exhausted all other options.
Another solution I found if you don't want to disable projectile constantly is to put this command in your init.el
auto-revert-tail-mode is great, but it has its limits. Therefore I prefer to use an asynchronous shell command. Open the remote directory in dired, position the cursor to the file you want to watch, and apply ! tail -f * &.
If you want to suppress Tramp messages, decrease the verbosity. (setq tramp-verbose 1) shall be sufficient.
The equivalent of the git command in Magit is to set a new Remote.
This is where it is in the docs
Ma creates a new remote.
When asked for the name of your remote, the usual answer is the name of your remote server, typically 'origin'
I hope this saves someone some time!
I have also found the solutions on the tramp FAQ that address speeding tramp up to work pretty well.
From the page, here is what I added to my configuration:
(setq remote-file-name-inhibit-cache nil)
(setq tramp-verbose 1)...
I would do this outside of Emacs, with a wrapper script that pulls the updated config first.
Something like this:
cd ~/.emacs.d && git pull --rebase
exec /usr/bin/emacs "$@"
Then make this executable, name it emacs, and put it on your PATH before the real one.
Another option would be to have init.el do pretty much the same thing: (call-...
What about writing a "safe" version of shell-command that would properly escape arguments using shell-quote-argument ?
(defun safe-shell-command (args &optional output-buffer error-buffer)
(apply 'shell-command (mapconcat 'shell-quote-argument args " ")
output-buffer error-buffer nil))
(the same would easily apply to async-...
There is Tramp. You can edit a file on another machine using the syntax /ssh:user@machine:/path/to/file. If you take sudo instead of ssh, and empty user and machine, you can edit a local file as root. Like /sudo::/path/to/file.
If I understand your question correctly, the simplest solution that I have found is to set the variable directory-abbrev-alist to map directories in the compilation buffer to the host system.
For example I run my phpunit tests in a docker container as a compile command. When there are errors or failures the filepaths in the compilation buffer show up as /...
I wrote a command for automating @Manuel Uberti's answer. The second one is the one I'd use. It uses the first one for remote files and uses crux for local files.
(defun my--reopen-remote-file-as-root ()
"Reopen a remote file as root over tramp."
(find-alternate-file (let* ((parts (s-split ":" buffer-file-name))
Make sure that dired-dwim-target is set to t, split the frame in two windows, open a local directory in the other window with dired where you want the copy to land, mark the file that you want to copy with C on the remote directory, check that the destination is correctly set to the local directory and press RET.
Not the best solution, but certainly a working one: Use [dirtrack-mode]. The following preparations are needed:
1. On the remote machine:
Make sure the prompt of the remote shell contains the path including the server login in TRAMP notation (e.g. /email@example.com:/home/user). You can achieve this by setting PS1 (e.g. in the .bashrc file on the remote ...
Tramp works on the basis of default-directory. If you run a shell in Emacs, and you perform ssh in that shell, the buffers's default-directory is still the local path the shell was started from. You have three options to adapt default-directory:
Start the shell while you are visiting a remote file or directory. The shell doesn't run on your local host, but ...
No, You can't use a remote virtual environment with emacs with elpy as of now.
Here is jorgenschaefer the author of elpy) comments on this
I'm afraid that won't work. Tramp does a lot of magic with Emacs internals to do what it does, but it breaks in interesting ways if you try to tweak it too far. Elpy does that, because it runs so many different processes ...
You might be thinking about impatient-mode, which is available in MELPA, and also on GitHub. I haven't tried it myself, but according to Sacha Chua's blog post about it it seems to be easy to use:
Install the impatient-mode package.
Call M-x httpd-start.
Configure the firewall to allow incoming connections.
Put the selected buffer into impatient-...
And not to forget the hint in the Tramp manual:
Emacs computes the ‘dired’ options based on the local host but if
the remote host cannot understand the same ls command, then set
them with a hook as follows:
(when (file-remote-p default-directory)
(setq dired-actual-switches "-al"))))
If you simply want to know whether the file is accessed through a remote acces method, you can call file-remote-p (built into Emacs) or Tramp's similar function tramp-handle-file-remote-p. Both functions return nil for an actual file name and the method prefix (as a string) for a file accessed through a remote method.
This may or may not be what you're ...
I realize you're asking to detect tramp buffers vs, say, files on a remote mounted filesystem, but for posterity this might be useful to other searchers:
(defun buffer-is-on-local-fs-p ()
(let ((local-path (chomp (shell-command-to-string
(concat "df -l \"" (buffer-file-name) "\" | awk '/^...
,----[ C-h f url-handler-mode RET ]
| url-handler-mode is an interactive autoloaded compiled Lisp function
| in `url-handlers.el'.
| (url-handler-mode &optional ARG)
| Toggle using `url' library for URL filenames (URL Handler mode).
Your $PATH settings in your init file are not taken into account per default. Try the following:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
See also the Tramp manual discussing this setting.
Use M-x term instead of M-x shell. shell isn't a terminal emulator, term is. Also a hint: term-mode has two submodes, line-mode and char-mode. You can switch between them with C-c C-k and C-c C-j. line-mode is more like a normal Emacs buffer, e.g. you don't have a lot of Emacs key bindings like M-x in char-mode.
I found out what my particular problem was.
The server I'm trying to login to, displays a fancy motd message when logging in. This ascii-art contains some characters that emacs/tramp seems to dislike, probably backslashes/slashes.
In the end I just removed the motd message and everything is fine now.