Enabling interactive shell inside editors like vim

shellbridge is a daemon written in javascript, enabling an interactive shell experience inside editors like vim. Inspired by xiki but in a different way.

  • Execute arbitrary shell commands in text editors
  • Multiple long-lasting commands can be running in parallel
  • Interactive commands supported like mysql, redis-cli, ssh and even bash.

  • vim 7.3+ compiled with +client-server option
  • newer nodejs

You may get them by apt-get install nodejs npm vim vim-gnome on ubuntu.

My env. is ubuntu 14.04, nodejs 0.10.25 and vim 7.4 p183.

For Ubuntu 12.04, please install newer node and npm from PPA and the official installer script.

  1. sudo npm install -g shellbridge
  2. shellbridge --server to start the daemon
  3. echo source `npm root -g`/shellbridge/editors/shellbridge.vim >> ~/.vimrc
  4. Start vim with any servername, eg. vim --servername anyword
  5. Alt-n to initialize the shellbridge interface
  6. Insert echo 123 then Alt-n to execute the line

echo <your pwd> | sudo -S bash will do the trick. For convenient, you could map it in your ~/.shellbridgerc to have a quick start next time.

You may start by mysql -n. A mapping is shipped in the default shellbridgerc, you should be able to start it by mysql only.

Sure, in fact shellbridge interact with editors through only 2 commands: insertCmd & editorCmd. shellbridge can talk to everything has these 2 APIs implemented. The first step would be configuring your ~/.shellbridgerc and hack your favorite editor.

Yes, every key mapping can be changed. Feel free to add mapping below in your ~/.vimrc

let g:shellbridge_init = "<m-n>"

Available mappings are g:shellbridge_init g:shellbridge_exec g:shellbridge_kill g:shellbridge_cleanup g:shellbridge_select g:shellbridge_next g:shellbridge_previous g:shellbridge_sort g:shellbridge_filter

  • supported performing actions below inside output
    • clear
    • sort
    • filter
  • added syntax highlight to ended commands
  • revamped the end-to-end architecture
  • supported filtering output by alt f
  • identified lines indented as sub-command, no need to be indented with exactly 2 spaces
  • updated default key mappings:
    1. alt n to start/execute
    2. alt s to sort
  • showed all key mappings when started
  • vim key mappings are now configurable
  • optimized vim conceal
  • fixed the abnormal highlighting
  • Supported multiple line execution and added output buffer

This simple project is fun. I enjoy so much working on it. Please feel free to ask/file issue if you got any problem on setup. Any suggestions are welcome. Thanks so much for giving it a try. :)