Last active
September 8, 2021 01:30
-
-
Save shmup/db671132f0f9882187b28a677fa8df72 to your computer and use it in GitHub Desktop.
nonymous-ix.vim uses .netrc for auth, and fucks with ix.io
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
" nonymous-ix.vim uses .netrc for auth, and fucks with ix.io | |
" insert :IX [optional visual selection] - copies url to system clipboard | |
" replace :RX <URL> [optional visual selection] | |
" delete :DX <URL> | |
if has('win64') || has('win32') || has('win16') | |
let s:env = 'WINDOWS' | |
else | |
let s:env = toupper(substitute(system('uname'), '\n', '', '')) | |
endif | |
" linux requires curl and xclip | |
if s:env =~ 'LINUX' && executable('xclip') | |
command! -range=% IX <line1>,<line2>w !curl -n -F 'f:1=<-' ix.io | tr -d '\n' | tee >(xclip -i -selection clipboard) | |
command! -nargs=1 -range=% RX <line1>,<line2>w !curl -n -X PUT -F 'f:1=<-' <args> | tr -d '\n' | tee >(xclip -i -selection clipboard) | |
command! -nargs=1 -range=% DX w !curl -n -X DELETE <args> | |
endif | |
" macos requires curl | |
if s:env =~ 'DARWIN' | |
command! -range=% IX <line1>,<line2>w !curl -n -F 'f:1=<-' ix.io | tr -d '\n' | tee >(pbcopy) | |
command! -nargs=1 -range=% RX <line1>,<line2>w !curl -n -X PUT -F 'f:1=<-' <args> | tr -d '\n' | tee >(pbcopy) | |
command! -nargs=1 -range=% DX w !curl -n -X DELETE <args> | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because
ix.io
returns an existingID
if you try to-X PUT
existing content, I decided I want to put the:RX <url>
response on the clipboard, but still let it output visually in vim so you can visually read/click theURL
.Using
tee >()
does this for me, but unsure if it's the best way.