Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TxUncopy command #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,6 +89,12 @@ Executes TxCreate. Creates a new pane and associates with it.

Executes TxKill. Closes the associated pane.

```vim
<leader>mv
```

Executes :TxUncopy. Cancels copy mode in the associated pane.

```vim
<leader>ms
```
Expand Down
22 changes: 22 additions & 0 deletions autoload/tmuxify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions doc/tmuxify.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -125,6 +127,12 @@ Executes :TxCreate. Creates a new pane and associates with it.
<
Executes :TxKill. Closes the associated pane.

------------------------------------------------------------------------------
>
<leader>mv
<
Executes :TxUncopy. Cancels copy mode in the associated pane.

------------------------------------------------------------------------------
>
<leader>ms
Expand Down
2 changes: 2 additions & 0 deletions plugin/tmuxify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let s:map_prefix = get(g:, 'tmuxify_map_prefix', '<leader>m')
" commands {{{1
command! -nargs=0 -bar -bang TxClear call tmuxify#pane_send_raw('C-l', <q-bang>)
command! -nargs=0 -bar -bang TxKill call tmuxify#pane_kill(<q-bang>)
command! -nargs=0 -bar -bang TxUncopy call tmuxify#pane_uncopy(<q-bang>)
command! -nargs=? -bar -bang TxSetPane call tmuxify#pane_set(<q-bang>, <f-args>)
command! -nargs=0 -bar -bang TxSigInt call tmuxify#pane_send_raw('C-c', <q-bang>)
command! -nargs=? -bar -bang TxCreate call tmuxify#pane_create(<q-bang>, <args>)
Expand All @@ -29,6 +30,7 @@ if s:map_prefix !=# ""
execute 'nnoremap <silent>' s:map_prefix .'n :TxCreate' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'p :TxSetPane' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'q :TxKill' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'v :TxUncopy' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'r :TxRun' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'s :TxSend' . global . '<cr>'
execute 'nnoremap <silent>' s:map_prefix .'k :TxSendKey' . global . '<cr>'
Expand Down