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

Use copy-mode -q to leave copy mode before running a command #232

Merged
merged 3 commits into from
Sep 19, 2024
Merged
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
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