Skip to content

Commit 81b73a9

Browse files
committed
Merge pull request #30 from elight/master
Adds terminal page up and down commands
2 parents ffc2185 + 9a0739b commit 81b73a9

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

README.mkd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Easily interact with tmux from vim.
44

5-
![vimux](https://www.braintreepayments.com/assets-faccd47687/assets/images/blog/vimux3.png)
5+
![vimux](https://www.braintreepayments.com/assets-faccd47687/assets/images/blog/vimux3.png)
66

7-
What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL.
7+
What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL.
88

9-
My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `RunVimTmuxCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `RunVimTmuxCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `RunLastVimTmuxCommand` that will execute the last command you called with `RunVimTmuxCommand`.
9+
My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `RunVimTmuxCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `RunVimTmuxCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `RunLastVimTmuxCommand` that will execute the last command you called with `RunVimTmuxCommand`.
1010

1111
Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc.
1212

plugin/vimux.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ command VimuxCloseRunner :call VimuxCloseRunner()
1414
command VimuxClosePanes :call VimuxClosePanes()
1515
command VimuxCloseWindows :call VimuxCloseWindows()
1616
command VimuxInspectRunner :call VimuxInspectRunner()
17+
command VimuxScrollUpInspect :call VimuxScrollUpInspect()
18+
command VimuxScrollDownInspect :call VimuxScrollDownInspect()
1719
command VimuxInterruptRunner :call VimuxInterruptRunner()
1820
command VimuxPromptCommand :call VimuxPromptCommand()
1921
command VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
@@ -127,6 +129,13 @@ function InterruptVimTmuxRunner()
127129
call VimuxInterruptRunner()
128130
endfunction
129131

132+
function VimuxScrollDownInspect()
133+
ruby CurrentTmuxSession.new.inspect_scroll_down
134+
endfunction
135+
136+
function VimuxScrollUpInspect()
137+
ruby CurrentTmuxSession.new.inspect_scroll_up
138+
endfunction
130139

131140
function VimuxInspectRunner()
132141
ruby CurrentTmuxSession.new.inspect_runner
@@ -209,6 +218,23 @@ class TmuxSession
209218
def inspect_runner
210219
_run("select-pane -t #{target(:pane => runner_pane)}")
211220
_run("copy-mode")
221+
_move_up_pane
222+
end
223+
224+
def inspect_send_command(cmd)
225+
t = target(:pane => runner_pane)
226+
_run("select-pane -t #{t}")
227+
_run("copy-mode")
228+
_send_command(cmd, t, false)
229+
_move_up_pane
230+
end
231+
232+
def inspect_scroll_up
233+
inspect_send_command("C-u")
234+
end
235+
236+
def inspect_scroll_down
237+
inspect_send_command("C-d")
212238
end
213239

214240
def current_panes

0 commit comments

Comments
 (0)