zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.09k stars 1.17k forks source link

Custom settings for copy/parse #938

Open id777 opened 6 years ago

id777 commented 6 years ago

Hi! I think it's would be great to have settings to set custom command for copy and pase. Like in vim:

vmap <F6> :!xclip -f -sel clip<CR>
map <F7> :-1r !xclip -o -sel clip<CR>

or tmux:

bind C-p run-shell "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
bind C-y run-shell "tmux show-buffer | xclip -sel clip -i"

I know what micro support by default xclip or xcel (using this package https://github.com/zyedidia/clipboard) but i want to share clipboard from my server using TCP tunnel, not -X. It's more faster and don't required to install additional stuff on server to minimal support -X (for xclip or xcel). For example lemonade https://github.com/pocke/lemonade for this I need declare commands in micro like: lemonade copy (for copy to remote) and lemonade paste (for paste from remote). Like I said this method to share clipboard using TCP connection (not -X with xclip or xsel) working instantly, not like when with -X. If your ping > 200mc to server, delay using copy pasting with -X is about 1.5 sec. That's a lot. That's why I need custom commands for copy and paste in micro and use lemonade utility instead.

zyedidia commented 6 years ago

It seems like this is just a matter of making a binding that runs a custom shell command. You could write these commands yourself in your ~/.config/micro/init.lua file. You can call shell functions using the HandleShellCommand function and then bind these two functions to CtrlC and CtrlV.

I can write more a bit later giving an example if that would be helpful.

id777 commented 6 years ago

@zyedidia thanks for reply! Yes, for now it would be super helpful because I don't know lua. I think this info can be somewhere in the readme as well.

But still it will be good in the future to have these custom clipboard settings in the main json config.

Chrysostomus commented 5 years ago

Could this be used to make micros clipboard work on wayland? I'm thinking of using something like https://github.com/brunelli/wl-clipboard-x11 instead of xsel to set wayland clipboard with micro. Would this be feasible? Any additional pointer on how to do this would be greatly appreciated

Pestdoktor commented 5 years ago

@Chrysostomus You could use my fork of github.com/zyedidia/clipboard which includes support for wl-clipboard