Skip to content

Commit

Permalink
Merge pull request #232 from mvanderkamp/issue-230
Browse files Browse the repository at this point in the history
Use `copy-mode -q` to leave copy mode before running a command
  • Loading branch information
mvanderkamp authored Sep 19, 2024
2 parents b110cd9 + 20ec061 commit 64df7ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
11 changes: 8 additions & 3 deletions doc/vimux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,17 @@ Default: 1
*VimuxConfiguration_reset_sequence*
4.4 g:VimuxResetSequence~

The keys sent to the runner pane before running a command. By default it sends
`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line.
The keys sent to the runner pane before running a command.

When vimux runs a tmux command, it first makes sure that the runner is not in
copy mode by running `copy-mode -q` on the runner. This sequence is then sent
to make sure that the runner is ready to receive input.

The default sends `C-u` to clear the line.
>
let g:VimuxResetSequence = ""
<
Default: "q C-u"
Default: "C-u"

------------------------------------------------------------------------------
*VimuxPromptString*
Expand Down
16 changes: 13 additions & 3 deletions plugin/vimux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let g:VimuxHeight = get(g:, 'VimuxHeight', '20%')
let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '')
let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v')
let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ')
let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'q C-u')
let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'C-u')
let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '')
let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane')
let g:VimuxRunnerQuery = get(g:, 'VimuxRunnerQuery', {})
Expand Down Expand Up @@ -71,9 +71,19 @@ function! VimuxRunCommand(command, ...) abort
if exists('a:1')
let l:autoreturn = a:1
endif
let resetSequence = VimuxOption('VimuxResetSequence')
let l:resetSequence = VimuxOption('VimuxResetSequence')
let g:VimuxLastCommand = a:command
call VimuxSendKeys(resetSequence)

try
call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex)
catch
let l:versionString = s:tmuxProperty('#{version}')
if str2float(l:versionString) < 3.2
let l:resetSequence = 'q '.l:resetSequence
endif
endtry
call VimuxSendKeys(l:resetSequence)

call VimuxSendText(a:command)
if l:autoreturn ==# 1
call VimuxSendKeys('Enter')
Expand Down

0 comments on commit 64df7ce

Please sign in to comment.