1

I want a Linux programmer's text editor with the possibility to search in a directory on remote server over SSH (I assume that the editor should call grep on the remote host and parse grep output.)

Just mounting an SSH dir locally and searching it as if it were a local directory is not acceptable, because this way it is too slow and too inefficient. I want the editor to call grep directly on the server, to avoid transferring non-matched files between the server and the client.

1
  • I don't know of any editors that do this natively, but a vast majority of the big ones (vi, emacs, etc) have the ability to invoke shell commands directly from the editor. Aug 30, 2018 at 19:19

3 Answers 3

2

In a sense, all text editors can do this. SSH search isn't really something a text editor needs to do, or should, but since there's already tools for remote mounting over SSH, and those tools can work with any text editor...

The simplest way would be to mount the remote directory locally, using whatever SSH method seems most convenient. See Mount remote directory using SSH, then search it directly or through some editor shell macro or plug-in.

2
  • You answer is wrong: Searching through locally mounted SSH directory is way too slow
    – porton
    Aug 31, 2018 at 13:00
  • @porton, Re "way too slow": please revise the question to specify what sort of minimum speed and efficiency is required.
    – agc
    Aug 31, 2018 at 13:08
2

SSH into the remote box and use vi, vim, emacs or whatever text editor you like - I prefer joe. Your use of grep and other utils will be on the local file system, use screen and you can connect and disconnect at will and easily toggle between shell sessions.

Heck at work I have gig ethernet to my servers from my desktop so I just SSH in and export my display back and start a GUI editor, typically Geany. Live dangerous and edit live :)

1

You are looking for Emacs, Tramp will allow you to open remote files or directories transparently (pun intended).

UPDTATE suggested by OP

Tramp works by executing process in the remote host via ssh and reading the output back into Emacs, so there are no "unwanted file downloads". TRAMP will also allow you to manually execute a shell from within Emacs, do file related operations (copy/rename/delete), etc.

4
  • Please specify how it searches the remote server's files -- that is would it use 1) the remote server's grep, and then send the client the search results only; or does it use 2) the client's grep, thus requiring downloading each file searched.
    – agc
    Aug 31, 2018 at 21:14
  • It starts the process in the remote host, execute the process in the remote host, and only brings back it's output. You should read the link I provided
    – yorodm
    Sep 3, 2018 at 12:56
  • @yoridim, Thanks. Note: that link leads to an 11 chapter 5000+ lines long firehose of information. Please quote the relevant part, and improve the URL to cite the specific chapter.
    – agc
    Sep 3, 2018 at 14:37
  • @agc, Sorry, been an Emacs user for a while so I sometimes forget how verbose the documentation can be. Updated my answer.
    – yorodm
    Sep 3, 2018 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.