Ouch, this is a better version of what I submitted a few days ago [1]. I guess that's what I get for trying to emulate the unwieldiness of ssh_config.<p>[1] <a href="https://news.ycombinator.com/item?id=8324538" rel="nofollow">https://news.ycombinator.com/item?id=8324538</a>
I made myself a simpler version of this a while back. I would simply put the rcfile in a folder and then host that folder with:<p><pre><code> python2 -m SimpleHTTPServer 12345
</code></pre>
Then you can just use something like the following function to get a remote session:<p><pre><code> sshrc() {
ssh -R 12345:127.0.0.1:12345 -t ${*:1} 'bash -c "bash --rcfile <(curl -s http://127.0.0.1:12345/sshrc)"'
}
</code></pre>
This has some nice side effects in that you can then just host your vimrc the same way. I think you can get vim to load plugins from a http runtime path too, but I have never looked into it.<p>Doing it this way has its own quirks though.
Something similar, which allows you want to extend shell scripts to a remote system transparently is "rpcsh" -- take a look at:
<a href="https://gist.github.com/derekp7/9978986" rel="nofollow">https://gist.github.com/derekp7/9978986</a><p>This function allows you to push out local functions, variables, and arrays to a remote system. There is an updated version in the client script for my backup utility (snebu), which also includes getting remote variables returned to the local shell script, and also bouncing through sudo.<p>Should I move this to a regular project on Github, or keep it in the gist?
Well, this post read my mind. Literally my first thought waking up this morning was "why don't I have some way to use my .vimrc over ssh?" I open up Hacker News and voila!<p>Very nice - clean and simple.
I was thinking of putting together a crude hack to implement just a subset of what this offers. I cannot thank the authors enough. I'm trying this out the moment I get home.<p>I feel as though we should have had first-class support for portable environments all along, and it shocks me that we haven't considered building this kind of facility before. This could be a game changer. Like vim package managers and other sensibly modern things, I totally expect to see this evolve to become the new norm.<p>I see this kind of configuration:<p>* global personal configs (lightweight, truly global settings for work and home)<p>* local overrides (work, home, per machine, non-SSH)<p>* remote overrides (SSH machines)<p>Global configs should be portable everywhere. For everything else, I see a system capable of merging several such configs and matching the current environmental and capability context.
Fantastic. Looks like a perfect complement to my Workspace[1] script, and way easier than having to git push/pull my dotfiles directory.<p>Thanks!<p><a href="https://github.com/matadon/workspace" rel="nofollow">https://github.com/matadon/workspace</a>
I do something like this manually. I set up an alias on my home that copies a locally stored environments file onto any server I ssh onto.<p>Pretty simple stuff to set up, but allows for some pretty powerful configuration
I wonder if it would be able to make it work with mosh (<a href="http://mosh.mit.edu/" rel="nofollow">http://mosh.mit.edu/</a>), which would be awesome!
Eureka! This so simple to use and so useful -- I'll use sshrc every day now. And the embedded xxd -ps is a clever copy. Great idea Russell. Thank you.
As a complement to this nice tool, I can recommend sshfs [1], which enables you to mount a remote machine as a local folder.<p>[1] <a href="https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-use-...</a>
Love the elegant simplicity. Should we add something like this to Userify (<a href="https://userify.com" rel="nofollow">https://userify.com</a>) or perhaps offer to pull your dotfiles (.bashrc, .vimrc, etc) from Github?
What would it take to adapt this to also source other config files ? I'm thinking about gitconfig and vimrc, but I'm sure there could be more.
I've seen tool after tool that tries to make SSH'ing into a remote machine more "comfortable", but I honestly don't do enough remote work over SSH to make it worth the time required to set it up. I probably spend an hour or two over SSH per week, and Ubuntu's minimalist shell defaults are perfectly fine for the little work I do.