Coder Social home page Coder Social logo

remote-development-manager's Introduction

Remote Development Manager

An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open. RDM works by listening on a unix socket locally that can be forwarded to an SSH session.

The server works on MacOS and Linux, but the client commands are not OS specific.

Installation

The easiest way to install rdm is to download the latest release for your platform. Alternatively, you can build it yourself with go build main.go.

e.g. for a Linux server you can use wget to download the binary then put it somewhere in your $PATH:

wget https://github.com/BlakeWilliams/remote-development-manager/releases/latest/download/rdm-linux-amd64
mv rdm-linux-amd64 /usr/local/bin/rdm
chmod +x /usr/local/bin/rdm

If you are running the server on MacOS you can set up rdm as a launchd service that will automatically start on system boot:

$ rdm service install
Run state:     [Running] done!
Run `launchctl print gui/501/me.blakewilliams.rdm` for more detail.
Configured to start at boot. Uninstall using:
        rdm service uninstall

Usage

The following is an example of forwarding an rdm server to a remote host: ssh -R 127.0.0.1:7391:$(rdm socket) [email protected]. It's worth noting the port number is not currently configurable and will always attempt to connect to 7391.

For Codespaces, rdm can be forwarded as part of the gh cs ssh command as arguments to ssh, e.g.: gh cs ssh -- -R 127.0.0.1:7391:$(rdm socket)

Server commands:

  • rdm server - hosts a server locally (macOS only) so that your machine can receive copy, paste, and open commands.
  • rdm stop - attempts to close a running server.
  • rdm logpath - returns the path where server logs are located. Useful for tail $(rdm logpath)
  • rdm socket - returns the path where the server socket lives. Useful for SSH commands, as seen above.

Client commands:

  • rdm copy - reads stdin and forwards the input to the host machine, adding it to the clipboard. e.g. echo "hello world" | rdm copy
  • rdm paste - reads and prints the host machine's clipboard. rdm paste
  • rdm open - forwards the first argument to open. e.g. rdm open https://github.com/blakewilliams/remote-development-manager

Integrations

Here's a few tools you can easily hook rdm into:

Tmux

If you're using macOS and are already delegating copy to pbcopy you can easily use rdm in an ssh session by creating an alias.

alias pbcopy="rdm copy"

Alternatively, you can define the commands explicitly for rdm:

bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "rdm copy"
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "rdm copy"

Neovim

Neovim supports custom clipboards out-of-the-box. You can use rdm with Neovim using the following code:

let g:clipboard = {"name": "rdm", "copy": {}, "paste": {}}
let g:clipboard.copy["+"] = ["rdm", "copy"]
let g:clipboard.paste["+"] = ["rdm", "paste"]
let g:clipboard.copy["*"] = ["rdm", "copy"]
let g:clipboard.paste["*"] = ["rdm", "paste"]

Or if you use lua:

vim.g.clipboard = {
  name = "rdm",
  copy = {
    ["+"] = {"rdm", "copy"},
    ["*"] = {"rdm", "copy"}
  },
  paste = {
    ["+"] = {"rdm", "paste"},
    ["*"] = {"rdm", "paste"}
  },
}

For open support, add the following to ~/.zshenv if you're using zsh:

alias open="rdm open"
alias xdg-open="rdm open"

GitHub CLI

GitHub CLI allows you to configure the browser used to open URL's. We can use this to set rdm as the browser target:

$ gh config set browser "rdm open"

TO-DO

So far this is just an experiment and there's a lot to be done to get it to a stable point. Contributions are very welcome.

  • Daemonize the server process
  • Add a configuration file that allows custom commands
  • Add instructions for vim

remote-development-manager's People

Contributors

blakewilliams avatar brasic avatar franciscoj avatar gnfisher avatar kenyonj avatar maxbeizer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

remote-development-manager's Issues

socket connection refused after sleeping with rdm server left running

๐Ÿ‘‹ Hello! This utility greatly improves the quality of my life, thanks for making it and sharing it!

I've run into a rough edge that I'd thought I'd capture in an issue.

While having a running rdm server in the background, I close my laptop. When I open the laptop again, the rdm server is unreachable.

In a codespace, I'll try to view a PR on github and get the following:

% gh pr view --web
Opening <snip> in your browser.
2022/09/14 14:03:41 Can not send command: could not send command: Post "http://unix///tmprdm.sock": dial unix /tmprdm.sock: connect: no such file or directory

If I check on my host machine (macOS) and try to to stop the running server, I get the following error:

~ % rdm stop
2022/09/14 10:03:50 Can not send command: could not send command: Post "http://unix///var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock": dial unix /var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock: connect: connection refused
~ % rm -rf /var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock
~ % rdm server &
[1] 11953
~ %

My current solution is to rm -rf <path to the socket> and restart the server. It would be great if the server could persist, or if it stopped itself when the machine went into a state where the socket gets "lost" (I know almost nothing about unix sockets or what might be happening).

If you're open to it, I might try to put a PR together in my spare time as a project to start learning go, but I will be very slow to do this ๐Ÿ•บ

Remote vim paste with rdm does not work as expected

Hey @BlakeWilliams ๐Ÿ‘‹๐Ÿป

I found an issue with my vim copy/paste config. Perhaps the issue is not in vim, but in rdm.

To illustrate, say I am on codepsaces, in a vim buffer with the following content:

one two three
four five
six seven

I am in normal mode, and my cursor is on the "f" from "five". I type yw (yank word), and that should copy the word "five". Then I type P to paste before my cursor, and this is the expected result:

one two three
four fivefive
six seven

But this is the actual result:

one two three
five
four five
six seven

It seems like copy behaves as if I had done a yy, or Y (copy line).

This is my vim config:

https://github.com/mjacobus/dotfiles/blob/3f60925fe661e8e12ddf27a4c235cda4ba849efe/neovim/.config/nvim/config.vim#L403-L410

" Forward clipboard in a codespace
if !empty($CODESPACES)
  let g:clipboard = {"name": "rdm", "copy": {}, "paste": {}}
  let g:clipboard.copy["+"] = ["rdm", "copy"]
  let g:clipboard.paste["+"] = ["rdm", "paste"]
  let g:clipboard.copy["*"] = ["rdm", "copy"]
  let g:clipboard.paste["*"] = ["rdm", "paste"]
endif

Also I played with rdm outside vim, to see if I found any clue.

image

I will dig some more later, and share what I found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.