Saturday, June 23, 2012

Re: How to set USERNAME in RHS of "set" command

On 06/22/12 23:33, AndyHancock wrote:
> I've have the following in my vimrc to try to get bash functionality:
>
> set shell=c:\cygwin\bin\bash.exe -i

I'm surprised this doesn't give an error. Using ":set", spaces are
treated as delimiters between options, so it should give an error
something like "E518: Unknown option -i"

> set shell=c:\cygwin\bin\bash.exe --rcfile\ c:\cygwin\home\USER
> \.bashrc

which I would expect to happen here too (you escape the one after
"--rcfile", but not the one after "exe").

There are a couple of options, as you can escape the spaces with "\"
(though using Windows "\" as the path separator may then cause
issues; since Vim understands both, I'd stick to using "/" for
portability). You can also use Vim's ability to use :let do more
complex evaluations which is what I expect you want in this case:

:let &shell='c:\cyg…'.$USERNAME.'/.bashrc'

which you can read about at

:help :let-option

I might use "$HOME" instead of the full-path-with-username-replaced
as that should be more portable.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: