Code Monkey home page Code Monkey logo

warp's Introduction

warp

Imagine if you could SSH somewhere by picking a hostname from a list.

Now you can:

warp demo

warp is a script that reads a file (~/.warp) and displays it in VIM. When you press ENTER, you SSH to the hostname under the cursor.

If you select multiple lines, it opens cluster SSH.

Why?

How do you manage your servers now?

  • do you TYPE the hostname, maybe relying on shell completion?
  • do you create (and maintain) a BUNCH of aliases, one for each host?

Picking from a list solves all that.

How?

Here's a sample ~/.warp file:

# format 1: one hostname per line
example.com
[email protected]

# format 2: hostname:port
anotherBox:2222                  # a comment

# format 3: more than 1 column per line, taken as-is
ssh anotherBox
ssh -p 2222 anotherBox
mosh anotherBox                  # doesn't have to be ssh...
mosh -p 2222 anotherBox

Details:

  • comments are trimmed, # and everything after
  • if what's left is one column, the command is implied: ssh
  • you can override the command with the SSH environment variable
  • lines with more than 1 column are taken as-is

Comments:

The .warp file itself can contain empty lines, comments, headers, separators, etc ... just don't press ENTER on lines you don't want to ssh to.

Any VIM movement commands will work, this is regular VIM after all. I recommend searching with regular expressions, but using line numbers is good too.

You can edit the buffer before making a selection. Changes will NOT be saved back to ~/.warp.

Cluster SSH

If you select (shift-v) multiple lines and press ENTER, the content of each line are passed together as the arguments of cluster SSH:

  • on Linux, the executable is named cssh
  • on MacOS, the executable is named csshX
  • you can specify the executable name using the MULTISSH environment variable

If you want to SSH to multiple hosts that are NOT on lines following each other: just slice and dice the buffer, put the lines together, add or modify something, select them and press ENTER. Changes will NOT be saved back to ~/.warp.

Warp as an executable

Put warp somewhere in your $PATH. This is simple but it won't be able to modify your history: your shell history will say warp without indications of where you warped to.

See below.

Warp as a bash/zsh script

Add source PATH/TO/warp to your .bashrc/.zshrc. Now you can warp: reload your shell, type warp, press enter. A function was added to your shell.

warp will modify the history to contain the SSH command (as if you typed it) rather than warp.

Contributors

Thanks to the following people for helping me out:

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.