I want use emacs remote server(freebsd use sftp with ssh).
I already read this and write (require 'tramp) (setq tramp-default-method "ssh") in my .emacs. I use C-c C-f RET /sftp:ganluo-home-vm-freebsd-user#192.168.1.104/.
But it does not work
Look Here:I use emacs for windows so can't direct use tramp.Have to download plink.exe(I use it maybe had other way) and do some other exp:
first download here (also you can found some windows conntion unix\linux software in this website).Find plink.exe download it (offer release and development and source code)
than you can cut plink.exe in the your emacs\bin directory.
find your Environment Variables Edit/New "PATH" Add your emacs\bin complete directory and last the path must with ';'
C:\Emacs\bin;
then sign out use cmd test plink command is useful.if doesn't restart you PC.
C-c C-f /pink:YouName#HOST[IP,HOSTName]:/
it had some problem,I will post new status right here.
Related
In emacs, the locate command provides a way to run unix's locate and open files on the local filesystem.
I'm using TRAMP to access remote files - is it possible to use emacs' locate to find and open remote files?
Likely, it is not possible. locate uses call-process, which does not run remote processes.
I don't know if you can use Emacs's locate function with TRAMP per se, but you could connect to a host remotely and run locate on that system via M-x shell or M-x eshell. I have some wrapper functions which make this task easier (although I mostly got them from elsewhere):
(defun remote-eshell (host)
(interactive "sHost: ")
(let ((default-directory (concat "/ssh:" (format "%s:" host))))
(eshell host)))
(defun remote-shell (host)
(interactive "sHost: ")
(let ((default-directory (concat "/ssh:" (format "%s:" host))))
(shell)))
After locating the desired files on the remote host, you can then open them via TRAMP using C-x C-f /ssh:remotehost
Also, if you're connecting via TRAMP to a remote host, you should make sure that said host is not sending any weird prompts since TRAMP doesn't handle those well. See more about that here.
This is somewhat weird, I compiled from source postgresql. I've had no problem using psql at all.
$ psql -d rita
psql (9.3.2)
Type "help" for help.
rita=>
`
However when I try to run M-x sql-postgres on emacs, it prompts for user, password, database, host. But when I input the data in the minibuffer just appears: Unable to locate SQL program psql. I hope anyone can tell me how can I fix this, or what is happening.
Your psql isn't on the standard path.
You are likely setting the PATH in
~/.bashrc, and Emacs will not see it unless you launch Emacs from the terminal.
A solution is:
(setq sql-postgres-program "/usr/local/pgsql/bin/psql")
Or ln -s to /usr/bin if you want.
Alternatively, you can add the path to the psql binary to your emacs 'exec-path list as follows:
(add-to-list 'exec-path "/path/to/program")
(setenv PATH (mapconcat 'identity exec-path ":"))
I run Emacs on a Mac as my development environment. Launching emacs from the Dock doesn't include the path for programs installed via MacPorts. This is going to be a standard problem for anyone who has "non-standard" exec path elements and launches Emacs via their GUI. For me, OSX : MacPorts : /opt/local/... this includes psql, mysql, py-flakes and others. I could either set a variable for each add-on or modify exec-path. The setenv is needed where the elisp function defers searching the exec-path to the shell. The C-c C-v binding in python mode leverages the shell and the $PATH environment to find py-flakes.
The add-to-list is a simple solution that prepends the path to the list. One could make a case for more complex path wrangling in your .emacs file. YMMV.
I have different work-specific .emacs configuration files on servers where I do work for various companies. These are packages that, for various reasons, I don't want to store locally on my machine. Is there any way to start up emacs using one of those remote directories as if it were local?
Tramp is great for actually editing remote files as if they were local -- now I'd like to be able to start up a whole emacs editor in the same way.
Out of curiosity I just gave this a go:
emacs -q --load "/ssh:USER#HOSTNAME:.emacs.d/init.el"
That worked, however the remote init.el is setting load paths like "~/.emacs.d/vendor/", so really an init file needs to be aware that the paths and filenames it sets need to be relative to a common base. This base could be set by a common variable, so try:
emacs -q --eval '(setq init-base "/ssh:USER#HOSTNAME:") (load (concat init-base ".emacs.d/init.el"))'
Then in the remote config, prepend init-base to any path or filename it sets that should be remote.
start up emacs using one of those remote directories as if it were local
If the servers are unix/linux servers and you have ssh access, then you could try SSH Filesystem. Then you can mount the servers to local directories, e.g.:
> sshfs server1: ~/remote/server1
> sshfs server2: ~/remote/server2
Then you could start emacs with emacs --no-init-file --load ~/remote/servers2/.emacs and so on.
packages that, for various reasons, I don't want to store locally
If packages are installed in .emacs.d on the remote machines you could create scripts like the following on your local machine:
;; .emacs.server1.el
(add-to-list 'load-path (expand-file-name "~/remote/server1/.emacs.d"))
(add-to-list 'load-path (expand-file-name "~/remote/server1/.emacs.d/package1"))
(load (expand-file-name "~/remote/server1/.emacs"))
And then start emacs like this: emacs --no-init-file --load ~/.emacs.server1.el
Obvious this script depends on the mounts above.
You may find the SO question Originate edit of remote file using emacs tramp from ssh session is asking for a solution to a related problem. Perhaps the answers there might give you what you want, namely, you can attach to an emacs running on the remote machine.
For session management with emacs, I appended the following lines to my .emacs file
(load "desktop")
(desktop-load-default)
(desktop-read)
I was able to save the session using M-x desktop-save. But after exiting emacs, I am unable to recover the earlier saved session. I did start emacs in the same directory as that during "desktop-save"
Please let me know if I am missing anything or not correct in my efforts
Thanks
-- Harish
Chapter 51 'Saving Emacs Sessions' of my Emacs manual (using a Emacs 23 snapshot) has this
You can save the desktop manually
with the command M-x desktop-save'.
You can also enable automatic saving
of the desktop when you exit Emacs,
and automatic restoration of the last
saved desktop when Emacs starts: use
the Customization buffer (*note Easy
Customization::) to set
desktop-save-mode' to t' for future
sessions, or add this line in your
~/.emacs' file:
(desktop-save-mode 1)
which is different from what you tried.
The following worked for me (emacs 21.3.1):
(load "desktop")
(setq desktop-save-mode 1)
(desktop-load-default)
(desktop-read)
The desktop-save-mode line is only needed if you want to save desktop automatically on exit (i.e. without bothering to type M-x deskstop-save).
The only difference is that I put those lines at the beginning of the .emacs file but I doubt that's a problem.
I'm trying to get emacs tramp running under Windows XP to work over putty plink on an Amazon EC2 instance. The documentation for doing this is sparse. I can find partial documentation, but none that addresses all the steps required to get this working.
Can anyone provide a walk through, or a pointer to a walk through?
(add-to-list 'load-path
(expand-file-name "C:/tools/emacsw32/emacs/lisp/tramp/lisp"))
(require 'tramp)
;(setq tramp-chunksize "500")
(setq tramp-default-method "plink")
from my dot-emacs file. If I find more notes, I shall add them here.
I'll assume you have a GNU/Linux server you want to access, a username and a .ppk file. Also, Emacs 24.4+.
First set up server in PuTTY Configuration
In section Session, specify Host Name, for example username#server.
Go to section Connection > SSH > Auth and Browse for your "Private key file for authentication".
Back to section Session, name your Saved Sessions, for example putty-test, and click Save button.
Check your connection by clicking the Open button. If it works, you can close these now.
Next, head to your Emacs.
Make sure Emacs knows where your plink.exe is. One way is to just inform Emacs directly in your .emacs, for instance I have at the moment,
(setenv "PATH" (concat "c:/Users/Brady/Documents/putty/;" (getenv "PATH")))
Simply type C-x C-f //plink:putty-test:/ RET. Wait a moment while it connects, and window will open to dired buffer on the remote ~/ directory.
This worked for me on :
Windows 10
Emacs found at https://sourceforge.net/projects/emacsbinw64/files/release/.
cygwin64
Putty.
https://github.com/d5884/fakecygpty
The changes from the original tramp-sh.el is
for cygwin, use fakecygpty with ssh and change the prompt to ##
for plink, remove -ssh option
I have also renamed these method with w to differentiate it.
(when (string-equal system-type "windows-nt")
(add-to-list 'tramp-methods
`("sshw"
(tramp-login-program "fakecygpty ssh")
;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
(tramp-login-args (("-l" "%u" "-o \"StrictHostKeyChecking=no\"") ("-P" "%p") ("-t")
("%h") ("\"")
(,(format
"env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
tramp-terminal-type
"##"))
("/bin/sh") ("\"")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
(tramp-default-port 22))
)
(add-to-list 'tramp-methods
`("plinkw"
(tramp-login-program "plink")
;; ("%h") must be a single element, see `tramp-compute-multi-hops'.
(tramp-login-args (("-l" "%u") ("-P" "%p") ("-t")
("%h") ("\"")
(,(format
"env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
tramp-terminal-type
"$"))
("/bin/sh") ("\"")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
(tramp-default-port 22))
)
)