Skip to content

Instantly share code, notes, and snippets.

@Janik-Haag
Created January 1, 2024 05:56
Show Gist options
  • Save Janik-Haag/ee03294370e58bd3d670a4b81f3994f6 to your computer and use it in GitHub Desktop.
Save Janik-Haag/ee03294370e58bd3d670a4b81f3994f6 to your computer and use it in GitHub Desktop.
this makes <leader>sh append the stdout of a command to your cursosrs position in normal mode and replaces your selection in visual mode.
function GetShellInput()
call inputsave()
let in = system(input('sh: ')) | return (substitute(in, '\n$', ''', '''))
call inputrestore()
endfunction
nnoremap <leader>sh :exec 'normal a' . call("GetShellInput",[])<CR>
vnoremap <leader>sh c<C-R>=call("GetShellInput",[])<CR><ESC>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment