From b7ff9612f9723b81b8091f3963f7a9c13f17cb87 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Mon, 2 Nov 2020 14:43:22 -0700 Subject: [PATCH] Add TxUncopy command This will cancel copy mode on the associated pane. --- README.md | 7 +++++++ autoload/tmuxify.vim | 22 ++++++++++++++++++++++ doc/tmuxify.txt | 8 ++++++++ plugin/tmuxify.vim | 2 ++ 4 files changed, 39 insertions(+) diff --git a/README.md b/README.md index dd21875..13b1261 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Features: - send visually highlighted lines to the associated pane - send to pane by prompting for input - send to pane by setting a run command for the current filetype +- cancel copy-mode on associated panes - once set, run commands are remembered, but can easily be reset - all the plugin configuration happens in one dictionary that holds filetypes as keys and run commands as values @@ -88,6 +89,12 @@ Executes TxCreate. Creates a new pane and associates with it. Executes TxKill. Closes the associated pane. +```vim +mv +``` + +Executes :TxUncopy. Cancels copy mode in the associated pane. + ```vim ms ``` diff --git a/autoload/tmuxify.vim b/autoload/tmuxify.vim index 911c007..b48b2c6 100644 --- a/autoload/tmuxify.vim +++ b/autoload/tmuxify.vim @@ -241,6 +241,28 @@ function! tmuxify#pane_send_raw(cmd, bang) abort call system('tmux send-keys -t '. pane_descriptor ." '". keys . "'") endfunction +" tmuxify#pane_uncopy() {{{1 +function! tmuxify#pane_uncopy(bang) abort + if empty(a:bang) + let scope = "b:" + else + let scope = "g:" + endif + + if !exists(scope . 'pane_id') && !tmuxify#pane_create(a:bang) + return + endif + + execute 'let pane_id = ' scope . 'pane_id' + let pane_descriptor = s:get_pane_descriptor_from_id(pane_id) + if empty(pane_descriptor) + echomsg 'tmuxify: The associated pane was already closed! Run :TxCreate.' + return + endif + + call system('tmux send-keys -t '. pane_descriptor ." -X cancel") +endfunction + " tmuxify#set_run_command_for_filetype() {{{1 function! tmuxify#set_run_command_for_filetype(...) abort if !exists('g:tmuxify_run') diff --git a/doc/tmuxify.txt b/doc/tmuxify.txt index 1609e2d..811ab3d 100644 --- a/doc/tmuxify.txt +++ b/doc/tmuxify.txt @@ -46,6 +46,8 @@ tmuxify is a plugin for handling tmux panes: - send to pane by setting a run command for the current filetype + - cancel copy-mode on associated panes + - once set, run commands are remembered, but can easily be reset - all the plugin configuration happens in one dictionary that holds @@ -125,6 +127,12 @@ Executes :TxCreate. Creates a new pane and associates with it. < Executes :TxKill. Closes the associated pane. +------------------------------------------------------------------------------ +> + mv +< +Executes :TxUncopy. Cancels copy mode in the associated pane. + ------------------------------------------------------------------------------ > ms diff --git a/plugin/tmuxify.vim b/plugin/tmuxify.vim index df4c758..7d10f69 100644 --- a/plugin/tmuxify.vim +++ b/plugin/tmuxify.vim @@ -14,6 +14,7 @@ let s:map_prefix = get(g:, 'tmuxify_map_prefix', 'm') " commands {{{1 command! -nargs=0 -bar -bang TxClear call tmuxify#pane_send_raw('C-l', ) command! -nargs=0 -bar -bang TxKill call tmuxify#pane_kill() +command! -nargs=0 -bar -bang TxUncopy call tmuxify#pane_uncopy() command! -nargs=? -bar -bang TxSetPane call tmuxify#pane_set(, ) command! -nargs=0 -bar -bang TxSigInt call tmuxify#pane_send_raw('C-c', ) command! -nargs=? -bar -bang TxCreate call tmuxify#pane_create(, ) @@ -29,6 +30,7 @@ if s:map_prefix !=# "" execute 'nnoremap ' s:map_prefix .'n :TxCreate' . global . '' execute 'nnoremap ' s:map_prefix .'p :TxSetPane' . global . '' execute 'nnoremap ' s:map_prefix .'q :TxKill' . global . '' + execute 'nnoremap ' s:map_prefix .'v :TxUncopy' . global . '' execute 'nnoremap ' s:map_prefix .'r :TxRun' . global . '' execute 'nnoremap ' s:map_prefix .'s :TxSend' . global . '' execute 'nnoremap ' s:map_prefix .'k :TxSendKey' . global . ''