I'm new to emacs and a little confused about opening a saved file on an ssh client so I can edit it (this is for school)
What I have done is...
Opened my terminal on mac
Opened emacs via terminal
Split emacs screen so I have one side to edit a c program and another side for terminal (to compile faster)
Logged onto an ssh client (there is a file on there that I'm supposed to edit)
The only problem is that I'm unsure how to open that specific file from my emacs terminal if that file is from an ssh client.
I have tried emacs filename.c on the emacs terminal & it opens a version of my file that isn't colored and scrolls oddly.
How can I correctly open the file so that it's colored and scrolls like the regular files on emacs?
I have also tried c-c c-f on terminal and typed my filename.c but it just opens a blank page.
Any suggestions? Thank you in advance!
Emacs can access files on a remote machine via its package Tramp. In order to open such a file from your local machine, apply
C-x C-f /ssh:user#host:/path/to/file
user is your login name at the remote machine, and host is the name of that machine.
Related
I was so used to the way of opening a file in Emacs, by just C-x C-f and typing and tab-completing, without needing to use a mouse. In VS Code, I have to go through a "open file" system dialogue using a mouse to find my file. But when opening a file in SSH server, VS Code offers a built-in dialogue to find your file, by just typing and auto-complete. Is there a way to use the "open SSH file" dialogue to open local files, or a similar way by just typing and tab complete?
Add the following setting in your JSON config:
"files.simpleDialog.enable": true
This does not open the native file browser for local files. Instead, you can search for them in the same manner as you would do for remote files:
When i open my workspace in VScode i go directly into my SSH work area, which is what i want. But i want to have a split terminal with access to both my SSH-work area and a terminal for my local computer, but i cant access the local one without making an explicitly new terminal from the dropdown window. And if i try to split the new local terminal i get the error "The terminal shell CWD "/Users/asd/work/" does not exist" as if its being looked for in my SSH work directory. Is there any way of specifying the default terminal to be on my local computer? If i do so in the terminal preferences in VScode i get the CWD-error on startup instead.
This should have been resolved with microsoft/vscode-remote-release issue 1479
Both of you don't have C:\Windows\System32 on your path, I don't understand why that is.
But I will change this to not rely on the PATH.
Even if this was for Windows originally, opening a local shell, (Mac or Windows) should now be possible while having a remote session.
Wtih ctrl+shift+p or cmd+shift+p(Command Palette), you have:
Terminal: Create New Integrated Terminal (local)
Bonus, with VSCode 1.53 (Jan. 2021), there is now:
Remote layout persistence
Terminal layout is restored on remote terminal reconnection. In the video below, the terminal layout is restored when reloading VS Code and reconnecting to a Windows Subsystem for Linux (WSL) remote instance.
I run Emacs with -nw mode, but when I double click on a file I want to edit from my desktop, it opens up the Emacs app outside the terminal. Is there a way to change this?
Using OSX 10.8.5 and emacs 24.3.1.
After opening Emacs, run server-mode. Instead of associating the double click with Emacs, associate it with emacs-client. The client will connect to the server and open the file will open in the running Emacs instance. (not tested on OSX)
I was using Emacs on another terminal today and I noticed that when I hit C-x C-f to open a file that Emacs showed "Loading Tramp..." and then listed the files. I could either type my desired directory/file or I could use the left/right arrow key and Return to shift through directories and open a file. I was totally awesome. I am familiar with Tramp mode and started fiddling with it but I could not figure out how to get it to work, or if the two are even related, on my machine.
How do I get a file tree that I can use arrow keys with in Emacs?
This is how it appears on the other terminal:
Find file: .../dir1/dir1/{css/ | try.org | misc.txt | .emacs}
That likely was ido-mode, which is bundled with Emacs. Put this in the init file:
(ido-mode)
While it's on, it will rebind some common commands to its own versions that use this visual interface.
Tramp mode is not related. It just gets loaded if ido-use-virtual-buffers is t and you visited some remote files recently.
I want to keep emacs open most of the time, and then whenever I open a text file, python file, etc (from nautilus/finder), I want it to open as a new buffer in my current emacs instance, rather than starting a new instance.
I tried following this guide:
I wasn't really sure about what to do with the file, but what I tried was copying it to /usr/bin/emacs_openfile, adding #!/bin/sh to the first line, and running chmod +x emacs_openfile
However, it doesn't work for me and just opens a new instance, even though I was able to associate text files with this program.
On a sidenote, I set emacs as the default editor using this.
You want emacs client.
Basically, set emacsclient as your default editor, and add (server-start) somewere in your emacs config.
There needs to be a running Emacs instance for emacsclient to work, but if it's a hassle it's possible to have a headless Emacs launched at login.
Did you start server in emacs? Make sure that you add (server-start) to your .emacs or do M-x server-start from an existing EMACS session.
Conceptually, it's really easy, just do emacsclient file-name on the command line or where you name the program.
Just for your information, If you are using GUI version on Mac, the dir os emacsclient is below:
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient