Created
March 30, 2011 23:17
-
-
Save sumeet/895504 to your computer and use it in GitHub Desktop.
Copy remote Vim's visual selections to a remote Mac.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"http" | |
"exec" | |
) | |
func Copy(response http.ResponseWriter, request *http.Request) { | |
if (request.Method == "PUT") { | |
cmd, _ := exec.Run("/usr/bin/pbcopy", []string{"pbcopy"}, nil, "", | |
exec.Pipe, exec.DevNull, exec.DevNull) | |
buffer := make([]byte, 1024) | |
bytesRead, _ := request.Body.Read(buffer) | |
for (bytesRead != 0) { | |
cmd.Stdin.Write(buffer[0:bytesRead]) | |
bytesRead, _ = request.Body.Read(buffer) | |
} | |
request.Body.Close() | |
cmd.Stdin.Close() | |
cmd.Close() | |
} | |
} | |
func main() { | |
http.HandleFunc("/copy", Copy) | |
http.ListenAndServe(":7777", nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vmap <leader>y :w !curl -T - http://10.10.7.12:7777/copy<CR><CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment