Skip to content

Commit 00b9f8a

Browse files
Merge pull request #59 from michelesr/feature/command-override
Add support for custom ranger command
2 parents bc63f64 + ed5c44f commit 00b9f8a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

plugin/ranger.vim

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ if exists('g:ranger_choice_file')
3434
endif
3535
endif
3636

37+
if exists('g:ranger_command_override')
38+
let s:ranger_command = g:ranger_command_override
39+
else
40+
let s:ranger_command = 'ranger'
41+
endif
42+
3743
if !exists('s:choice_file_path')
3844
let s:choice_file_path = '/tmp/chosenfile'
3945
endif
@@ -57,19 +63,19 @@ if has('nvim')
5763
endfunction
5864
enew
5965
if isdirectory(currentPath)
60-
call termopen('ranger --choosefiles=' . s:choice_file_path . ' "' . currentPath . '"', rangerCallback)
66+
call termopen(s:ranger_command . ' --choosefiles=' . s:choice_file_path . ' "' . currentPath . '"', rangerCallback)
6167
else
62-
call termopen('ranger --choosefiles=' . s:choice_file_path . ' --selectfile="' . currentPath . '"', rangerCallback)
68+
call termopen(s:ranger_command . ' --choosefiles=' . s:choice_file_path . ' --selectfile="' . currentPath . '"', rangerCallback)
6369
endif
6470
startinsert
6571
endfunction
6672
else
6773
function! OpenRangerIn(path, edit_cmd)
6874
let currentPath = expand(a:path)
6975
if isdirectory(currentPath)
70-
silent exec '!ranger --choosefiles=' . s:choice_file_path . ' "' . currentPath . '"'
76+
silent exec '!' . s:ranger_command . ' --choosefiles=' . s:choice_file_path . ' "' . currentPath . '"'
7177
else
72-
silent exec '!ranger --choosefiles=' . s:choice_file_path . ' --selectfile="' . currentPath . '"'
78+
silent exec '!' . s:ranger_command . ' --choosefiles=' . s:choice_file_path . ' --selectfile="' . currentPath . '"'
7379
endif
7480
if filereadable(s:choice_file_path)
7581
for f in readfile(s:choice_file_path)

0 commit comments

Comments
 (0)