justinmk / vim-gtfo

Go to Terminal or File manager :point_right:
322 stars 17 forks source link

user customization of termpath #25

Open Konfekt opened 9 years ago

Konfekt commented 9 years ago

Dear Justin, the lines

    if s:termpath =~? "bash" && executable(s:termpath)
      silent exe '!start '.$COMSPEC.' /c "cd "'.l:dir.'" & "' . s:termpath . '" --login -i "'
    else "Assume it's a path with the required arguments (considered 'not executable' by Vim).
      if s:empty(s:termpath) | let s:termpath = 'cmd.exe /k'  | endif
      " Yes, these are nested quotes (""foo" "bar""), and yes, that is what cmd.exe expects.
      silent exe '!start '.s:termpath.' "cd "'.l:dir.'""'
    endif

are insufficient to deal with user customized termpath variables.

For example, I wanted gtfo to set up such that it uses mintty of msys2 and

mintty -i /msys2.ico /usr/bin/env CHERE_INVOKING=1 /usr/bin/bash --login

would invoke the first case of the above if clause but the above command already takes care of the cd command. Wrapping the above command in a bat, so that gtfo does not detect the bash string, still leaves the unnecessary cd command.

Perhaps the way to go is to allow the user to specify all the parameters passed to the terminal AND their order by a wildcards for the path such as @PATH.

That is, something like

let g:gtfo#terminals = {'win' : 'ms2.bat @PATH@'}

or

let g:gtfo#terminals = {'win' : 'cd '' @PATH@ '' && cygstart mintty /bin/env CHERE_INVOKING=1' /bin/bash''}
justinmk commented 9 years ago

would invoke the first case of the above if clause

@Konfekt I can make the condition more precise so that it correctly falls through to the second clause.

still leaves the unnecessary cd command.

So it works, except for an unnecessary cd?

Perhaps the way to go is to allow the user to specify all the parameters passed

Configuration defeats the purpose of the plugin :) g:gtfo#terminals was added for desperate edge cases.

Konfekt commented 9 years ago

Yes, it works without cd, but this is a user defined batch file.

gtfo`s utility lies in providing defaults for spawning a terminal or file manager in any os from VIM.

However if the user decides to spawn in a particular OS its customized terminal or file manager, gtfo should not interfere. This is why, in case the user provides such a customization, the check for bash is not sufficient.

I think better would be do add an variable isUserTermpath that keeps track if the termpath was provided by the user or not. In this case, just

 silent exe '!start '.s:termpath

and allow for a wildcard in the user customized termpath to let the user decide where in the string of arguments passed to the shell the file path actually has to go. Everything else is out of scope.

If this sounds sane, I'd offer to implement this in a pull request.