Skip to content

jacobsandlund/copyv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

149 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

copyv

Version control for copy paste! copyv will keep copy-pasted code up to date with a single command, even merging updates with your changes.

Installation

git clone git@github.com:jacobsandlund/copyv.git # or use https
cd copyv
zig build -Doptimize=ReleaseFast
cp zig-out/bin/copyv ~/.local/bin # or somewhere on your PATH

Usage

Instead of copying code from GitHub, copy the URL for a file, then add a copyv: <URL> comment in your code. If you want only certain lines, that works too (click the first line number, then shift-click the final--for markdown files, first switch to the Code tab instead of the Preview).

For example, in your ~/.config/nvim/init.lua, add:

-- copyv: https://github.com/nvim-telescope/telescope.nvim/blob/master/README.md?plain=1#L141-L145

Then run copyv <file> to copy the code.

Note

If you actually want to try running this example, use this URL instead, since this is an example of running copyv in the past: https://github.com/nvim-telescope/telescope.nvim/blob/63e279049652b514b7c3cbe5f6b248db53d77516/README.md?plain=1#L138-L142

$ copyv ~/.config/nvim/init.lua

Your file now contains:

-- copyv: https://github.com/nvim-telescope/telescope.nvim/blob/63e279049652b514b7c3cbe5f6b248db53d77516/README.md?plain=1#L157-L161 begin
local builtin = require('telescope.builtin')
vim.keymap.set('n', 'ff', builtin.find_files, {})
vim.keymap.set('n', 'fg', builtin.live_grep, {})
vim.keymap.set('n', 'fb', builtin.buffers, {})
vim.keymap.set('n', 'fh', builtin.help_tags, {})
-- copyv: end

Later, when the upstream config improves, run copyv (no args) to update all tagged code:

$ copyv

This merges in all the changes up to the latest, including commit 286628d which adds a missing <leader>, and updates the SHA:

--- copyv: https://github.com/nvim-telescope/telescope.nvim/blob/63e279049652b514b7c3cbe5f6b248db53d77516/README.md?plain=1#L138-L142 begin
+-- copyv: https://github.com/nvim-telescope/telescope.nvim/blob/3a12a853ebf21ec1cce9a92290e3013f8ae75f02/README.md?plain=1#L145-L149 begin
 local builtin = require('telescope.builtin')
-vim.keymap.set('n', 'ff', builtin.find_files, {})
-vim.keymap.set('n', 'fg', builtin.live_grep, {})
-vim.keymap.set('n', 'fb', builtin.buffers, {})
-vim.keymap.set('n', 'fh', builtin.help_tags, {})
+vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
+vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
+vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
+vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
 -- copyv: end

About

Version control for copy+paste

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages