From 08aa5e406a1f7b39182e79ea4eb7fabf7d61eaa3 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 Dec 2013 14:34:38 +0100 Subject: //Cancer -> // because that is what painload is all about --- bridge/share/doc/bridge/README.md | 59 +++++++++++++++ bridge/share/vim/vimfiles/plugin/bridge.vim | 113 ++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 bridge/share/doc/bridge/README.md create mode 100644 bridge/share/vim/vimfiles/plugin/bridge.vim (limited to 'bridge/share') diff --git a/bridge/share/doc/bridge/README.md b/bridge/share/doc/bridge/README.md new file mode 100644 index 00000000..77c62374 --- /dev/null +++ b/bridge/share/doc/bridge/README.md @@ -0,0 +1,59 @@ +Bridge is a tool to connect your favourite editor and interpreter (or +similar) for maximum profit. + + +## usage by example + + # start your favourite interpreter, e.g. bc, in a new session + bridge create my_fancy_interpreter bc + + # attach a terminal to the session + bridge attach my_fancy_interpreter + + # fire up your favourite editor (in another terminal) + vim + # press to connect to the session + # press return + # write interpreter stuff, e.g. 42^23 + # mark that stuff + # press return + + # paste some stuff into the session + bridge paste my_fancy_interpreter '1 + 2 + 4^M' + # (note that ^M is carriage return obtained by pressing ^V^M AKA C-V C-M) + + # or use bridge as a sink in your pipeline + echo 2^20 | bridge paste my_fancy_interpreter + + # you can use tab-completion everywhere (if installed) + + +## install bridge (bourne) shell integration + +Hint #1: reboot your system or similar for this to take full effect +Hint #2: you could also use ~/.profile or similar + + echo 'PATH="${PATH+$PATH:}//bridge/bin"' >> /etc/profile + + +## install bridge Vim integration + +Hint: your vim-setup probably differs + + ln -s //bridge/share/vim/plugin/bridge.vim ~/.vim/plugin/ + + +## install bridge bash completion + +Hint #1: reboot your system or similar for this to take full effect +Hint #2: this could differ on your system, of course +Hint #3: you could also use ~/.profile or similar + + ln -s //bridge/etc/bash_completion.d/bridge /etc/bash_completion.d/ + + +## install bridge into some usr-like hierarchy [advanced] + + tar -C //bridge -c . | + tar --exclude=./README.md -C ~/opt -v --keep-newer-files -x + diff --git a/bridge/share/vim/vimfiles/plugin/bridge.vim b/bridge/share/vim/vimfiles/plugin/bridge.vim new file mode 100644 index 00000000..91f072d1 --- /dev/null +++ b/bridge/share/vim/vimfiles/plugin/bridge.vim @@ -0,0 +1,113 @@ +" /vim/bridge.vim + +if ! exists('s:bridge_name') + let s:bridge_name = "" +endif + +fun! Bridge_complete(A,L,P) + let a = strpart(a:A,0,a:P) + return split(system("bridge list \"".a.".*\""), "\n") +endfun + +fun! Bridge_status() + if s:bridge_name == "" + return "Disconnected" + else + return "Connected to " . s:bridge_name + else + endif +endfun + +setlocal statusline=%<%f\ \(%{Bridge_status()}\)\ %h%m%r%=%-14.(%l,%c%V%)\ %P\ of\ %L\ \(%.45{getcwd()}\) + +fun! Bridge_display() + if s:bridge_name == "" + echo "Not connected!" + return + endif + let cmd = "bridge attach ".s:bridge_name + silent exe "!" . cmd + redraw! +endfun + +fun! Bridge_connect() + if s:bridge_name == "" + let m = "boot new" + else + let m = s:bridge_name + endif + let name = input("Connect to [".m."]: ", "", "customlist,Bridge_complete") + if name == "" + if s:bridge_name != '' + " stay connected + echo + return + endif + let system = input("Command: ", "") + if system == "" + echo "Aborted!" + return + endif + let name = input("Session name: ", "") + if name == "" + echo "Aborted!" + return + endif + TODO_boot_new + endif + if system("bridge list ".name) == "" + echo "No such session: ".name + return + endif + let s:bridge_name = name + let s:laststatus = &laststatus + let &laststatus = 2 + echo "Connected to " . s:bridge_name +endfun + +fun! Bridge_disconnect(m) + if s:bridge_name == "" + echo "Not connected!" + else + let &laststatus = s:laststatus + let m = "Disconnected from ".s:bridge_name + if a:m != "" + let m .= ": ".a:m + endif + echo m."!" + let s:bridge_name = "" + endif +endfun + +function! Bridge_paste( data ) + if a:data == '' + echo "Nothing to send!" + else + let l:data = a:data + if exists("g:bridge_prologue") | let l:data = g:bridge_prologue . l:data | endif + if exists("g:bridge_epilogue") | let l:data = l:data . g:bridge_epilogue | endif + call system("bridge paste " . s:bridge_name, l:data . "\") + endif +endfunction + +nmap :call Bridge_display() +nmap [24^ +nmap :call Bridge_connect() +nmap :call Bridge_disconnect("") +nmap [24$ + +nmap el :call Bridge_paste(getline(".")) +nmap ec m'ya(:call Bridge_paste(getreg('"'))`' +nmap et m'(y%:call Bridge_paste(getreg('"'))`' + +nmap ee :call Bridge_paste(input("paste: ", "")) + +" sugar +nmap ec + +"" visual shell +vmap m'y:call Bridge_paste(getreg('"'))v`' +vmap ee :call Bridge_paste(input("paste: ", "")) +vmap et + + -- cgit v1.2.3