Sunday, June 24, 2012

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

On Jun 23, 7:49 am, Tim Chase <v...@tim.thechases.com> wrote:
> 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").

You're right. I was handraulically trying to copy the bashrc
statements into my posting. Foolish me. Humans stopped typing error
free the moment computer editors and word processors became
widespread.

> 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.

I was starting to much around with the following in my vimrc:

let &shell='c:\cygwin\bin\bash.exe\ --rcfile c:\cygwin\home\'.
$USERNAME.'\.bashrc'

Then I found the *real* source of my problem. There is nothing wrong
with

set shell=c:\cygwin\bin\bash.exe\ -i

The problem is that it was enclosed

if has("win32")
" etc.
endif

I was running on a 64-bit Windows 7. Heh. Heh heh. (I smack my
forehead).

However, your example is still highly educational, for which I thank
you.

--
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: