Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

23

[NOTE] this answer was heavily edited to follow the updates of with-editor developments. Most comments likely won't make much sense anymore. There are some new comments which do make sense. Magit contains a library named with-editor available at https://github.com/magit/with-editor which allows you to use your local Emacs as an $EDITOR on remote machines ...


15

When you are saying "I am using tramp via ssh" I suppose you open a file like /ssh:host:/path/to/file. This is supposed to use always the ssh method. If you want to use the scp method, you shall use /scp:host:/path/to/file. This uses automatically ssh for short files, and scp for large files. If you trust the default method set in tramp-default-method, you ...


14

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 ...


11

That looks like a bug in eshell, you should report it. I think you can fix it by (defadvice eshell-gather-process-output (before absolute-cmd (command args) act) (setq command (file-truename command))) Bottom-line, the problem is that tramp ends up constructing a remote command line of the form (I'm removing some escaping to make it clearer): cd /home/...


11

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.


10

This cannot be done without some changes to mosh. Unlike ssh, mosh doesn't transmit every character that is sent by the application — it will happily skip sending data that has already scrolled off-screen, and will omit data that has been overwritten by later screen updates over high-RTT links. Therefore, it cannot be easily used for automation. There has ...


10

You can get rid of these buffers with M-x tramp-cleanup-all-connections.


8

Here's a really quick and dirty solution: (defun my-view-source (url) (interactive "MURL: ") (switch-to-buffer (url-retrieve url (lambda (_))))) url-retrieve is built-in to Emacs; there are also alternatives such as request.el.


8

The "problem" is that with M-x shell (or M-x eshell btw), Emacs uses a very limited terminal emulator, so that TERM is correctly set to dumb Fancy pagers cannot operate under such limited constraints, which is why you have to use cat instead. Now, when you open an ssh connection from that shell, TERM is still dumb, but PAGER is reset to whatever the other ...


8

Since TRAMP uses ssh by default, the real question you are asking is if you should use local or remote emacs to edit remote files. Right? Is it considered better to use ... There is no better, just that use cases differ for both local and remote editing. What are some of the considerations involved in making this decision? If you normally work with ...


8

You can attempt locating an executable in exec-path with executable-find: (executable-find "ls") ;=> "/usr/bin/ls" (executable-find "sl") ;=> nil


7

I use a simple password manager called pass. It offers a simple command line interface with is ideal for integrating with Emacs. The backing store is a GPG encrypted GIT repo. It actually ships with an Emacs package although I don't use it. My interface is laughably simple: (defun my-fixup-gpg-agent (frame) "Tweak DISPLAY and GPG_TTY environment variables ...


7

As pointed out by @Nsukami and briefly summarized in my comment he linked to, this is not supported out-of-the-box yet. But by following these suggestions you should be able to get it to work. What I don't understand is, if this doesn't work with when ssh'ing into a remote host, when would setting $EDITOR [to anything but emacsclient] by handy? Using ssh ...


7

I think one of the things unclear from the FAQ is the necessity that both server and client be resolveable from each other. You can see this thread from 2009. Eventually, back then I did get it to work, but now I do see the same as the OP. This is what I tried: setup.el: (require 'server) (setq server-name "sx-test" ; name of the server ...


7

You'll have to customize the tramp-password-prompt-regexp variable with the second prompt to finish the 2-factor authentication. The remote shell setup part of the manual has a simple example. This is not a new feature but an old feature that you adapt to the second prompt of the 2-factor authentication. This same facility was used in days of yore for ...


7

I had this exact same problem but it had nothing to do with RVM on ( which I also have ) on my Ubuntu-16.10 machine. It was related to by custom prompt (PS1) The issue was the prompt PS1. This fix : https://stackoverflow.com/questions/6954479/emacs-tramp-doesnt-work Essentially in your .bashrc case "$TERM" in "dumb") export PS1="...


6

I've asked on the mosh ML list for support, see http://thread.gmane.org/gmane.network.mosh.devel/112. The answer was "this is not going to happen any time soon".


6

Do as recommended in the Tramp manual. Write your settings into ~/.authinfo.gpg. This requires a more recent Emacs which supports auth-source.el, I guess any Emacs 24.* should do.


6

You could change the .bashrc such that it doesn't modify the prompt when the TERM variable is set to "dumb". if test $TERM = "dumb" # leave the prompt alone else # set up fancy prompt end According to the manual TERM is governed by tramp-terminal-type, which defaults to dumb.


6

In recent Tramp versions, there is the variable tramp-histfile-override. You can override its default value.


6

Like @lawlist said, determining if a file or directory is remote is easy and can be done using file-remote-p which will actually return the remote host is available. You could then use find-file-hook and dired-mode-hook to check if the file is remote and if so assign the host a color(s) and use that color to determine the mode-line and mode-line-inactive ...


6

Similar to Emacs bug#20015, this can be avoided by setting tramp-ssh-controlmaster-options before loading tramp. (setq tramp-ssh-controlmaster-options "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no") (require 'tramp) Or with use-package: (use-package tramp :init (setq tramp-ssh-controlmaster-options "-o ...


6

Emacs knows two basic commands for running external processes, call-process for synchronous processes, and start-process for asynchronous processes. For the remote case, these commands have been extended as process-file and start-file-process. Remote synchronous processes use always the same ssh connection Tramp uses for its internal commands. Asynchronous ...


5

I don't have that problem, using find-tag over TRAMP resolves the filenames over TRAMP as well. That said, that works only if the TAGS file contains relative paths (relative to the location of the TAGS file itself, therefore over TRAMP), and not absolute ones. I guess it'd be better if in case of absolute filenames over TRAMP, the resolution was smart ...


5

What about writing a "safe" version of shell-command that would properly escape arguments using shell-quote-argument ? For example: (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-...


5

The w3 mode can do this with the w3-source-document-at-point command which by default is bound to s. You could also use M-! and invoke curl.


5

This question has been already answered by rekado (thanks!) (as a reply to another more general question about eshell): You can configure TRAMP to respect the PATH variable on the remote machine (for remote eshell sessions) by adding 'tramp-own-remote-path to the list 'tramp-remote-path: (add-to-list 'tramp-remote-path 'tramp-own-remote-path) ...


5

In addition to the Tramp manual, there's a full manual for auth-source.el: (info "auth") that I wrote, which may help you. In the case of SSH logins, you may find it better to avoid passwords altogether--look at SSH keys instead.


5

One way is to use *eshell*. M-x eshell cd /ssh:<server_name>:~ run-python /usr/bin/ipython Switch to *Python* buffer.


5

I agree with Emacs User: Neither approach is objectively "better". If you don't have any obvious compelling reason to go with one or the other, then it's really just a subjective balance between performance and convenience. If you need only occasional access to any given server, the ease of using TRAMP ought to trump a low-to-moderate performance hit. If ...


Only top voted, non community-wiki answers of a minimum length are eligible