Skip to content

Commit

Permalink
New configuration option g:VimuxSocketPath
Browse files Browse the repository at this point in the history
It allows to specify tmux socket path
  • Loading branch information
jajm committed Nov 13, 2014
1 parent 50254fa commit 025a4f8
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions plugin/vimux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endfunction

function! VimuxSendKeys(keys)
if exists("g:VimuxRunnerIndex")
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
else
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
endif
Expand All @@ -65,30 +65,30 @@ function! VimuxOpenRunner()
if _VimuxRunnerType() == "pane"
let height = _VimuxOption("g:VimuxHeight", 20)
let orientation = _VimuxOption("g:VimuxOrientation", "v")
call system("tmux split-window -p ".height." -".orientation)
call _VimuxTmux("split-window -p ".height." -".orientation)
elseif _VimuxRunnerType() == "window"
call system("tmux new-window")
call _VimuxTmux("new-window")
endif

let g:VimuxRunnerIndex = _VimuxTmuxIndex()
call system("tmux last-"._VimuxRunnerType())
call _VimuxTmux("last-"._VimuxRunnerType())
endif
endfunction

function! VimuxCloseRunner()
if exists("g:VimuxRunnerIndex")
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
unlet g:VimuxRunnerIndex
endif
endfunction

function! VimuxTogglePane()
if exists("g:VimuxRunnerIndex")
if _VimuxRunnerType() == "window"
call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
let g:VimuxRunnerType = "pane"
elseif _VimuxRunnerType() == "pane"
let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
let g:VimuxRunnerType = "window"
endif
endif
Expand All @@ -97,27 +97,27 @@ endfunction
function! VimuxZoomRunner()
if exists("g:VimuxRunnerIndex")
if _VimuxRunnerType() == "pane"
call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex)
call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex)
elseif _VimuxRunnerType() == "window"
call system("tmux select-window -t ".g:VimuxRunnerIndex)
call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex)
endif
endif
endfunction

function! VimuxInspectRunner()
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
call system("tmux copy-mode")
call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
call _VimuxTmux("copy-mode")
endfunction

function! VimuxScrollUpInspect()
call VimuxInspectRunner()
call system("tmux last-"._VimuxRunnerType())
call _VimuxTmux("last-"._VimuxRunnerType())
call VimuxSendKeys("C-u")
endfunction

function! VimuxScrollDownInspect()
call VimuxInspectRunner()
call system("tmux last-"._VimuxRunnerType())
call _VimuxTmux("last-"._VimuxRunnerType())
call VimuxSendKeys("C-d")
endfunction

Expand All @@ -127,7 +127,7 @@ endfunction

function! VimuxClearRunnerHistory()
if exists("g:VimuxRunnerIndex")
call system("tmux clear-history -t ".g:VimuxRunnerIndex)
call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex)
endif
endfunction

Expand Down Expand Up @@ -158,7 +158,7 @@ function! _VimuxTmuxWindowIndex()
endfunction

function! _VimuxNearestIndex()
let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n")
let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n")

for view in views
if match(view, "(active)") == -1
Expand All @@ -182,9 +182,18 @@ function! _VimuxOption(option, default)
endfunction

function! _VimuxTmuxProperty(property)
return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '')
return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '')
endfunction

function! _VimuxHasRunner(index)
return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":")
return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":")
endfunction

function! _VimuxTmux(...)
let command = "tmux"
if exists("g:VimuxSocketPath")
let command .= ' -S ' . g:VimuxSocketPath
endif
let command .= ' ' . join(a:000, ' ')
return system(command)
endfunction

0 comments on commit 025a4f8

Please sign in to comment.