Use wsl's bash as shell on Windows 10

32 views
Skip to first unread message

Justus Kidding

unread,
Feb 1, 2022, 3:17:44 PM2/1/22
to vim_use
Hi!

I am trying to set up bash as my default shell for vim. However I am not able to get it to work. This is the current setup which allows for commands without arguments to be executed:
if has('win32')
        set shell=bash
        set shellpipe=|
        set shellredir=>
        set shellcmdflag=-c
endif
For example, !ls executes as expected and prints the content of the current directory. However if I wanted to do !ls ~ the following error appears:
:!ls ~
/bin/bash: ls ~: command not found
Shell exited 127

What would be the correct way to setup bash.exe as the shell?

Thanks!
Terra

M

unread,
Feb 2, 2022, 6:21:32 AM2/2/22
to vim...@googlegroups.com
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/12e463b4-dd4a-4a2d-abb5-97fbd30e6cacn%40googlegroups.com.
>

Hello,

Quoting my own config verbatim:

if has('win32')
set shell=bash shellcmdflag=-c shellredir=>%s\ 2>&1 shellslash noshelltemp
let &shellxescape = ''
let &shellxquote = has('nvim') ? '' : '"'
let $CYGWIN = 'noglob'
let $MSYS = 'noglob'
endif

Of course, you don't need has('nvim'), $CYGWIN or $MSYS if you have
neither of these.

Also, I'm not sure which one shall be correct for WSL and/or specific
Vim patch: shelltemp or noshelltemp? You may want to try both.

Regards,
Matvey

Justus Kidding

unread,
Feb 2, 2022, 11:03:05 AM2/2/22
to vim_use

Thanks! That worked perfectly! How were you able to figure it out, as in, what was your thought process when writing your config? Asking so I can maybe help myself in the future :)

M

unread,
Feb 2, 2022, 11:42:58 AM2/2/22
to vim...@googlegroups.com

ср, 2 февр. 2022 г. в 19:03, Justus Kidding <ichbi...@gmail.com>:
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/b11896fa-de89-464e-8fbe-e20d69d838d8n%40googlegroups.com.

 1. Type :help 'shell<CR> and read about all options starting with "shell", esp. "default for Unix" value
2. ?
3. PROFIT

Regards,
Matvey

Justus Kidding

unread,
Feb 2, 2022, 11:55:54 AM2/2/22
to vim_use
Maybe to rephrase my second question: Why didn't my config work? I tried to follow the section from "help 'shell'". How do I know which symbols to use?

M

unread,
Feb 2, 2022, 1:03:59 PM2/2/22
to vim...@googlegroups.com
>>> <https://groups.google.com/d/msgid/vim_use/b11896fa-de89-464e-8fbe-e20d69d838d8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>> 1. Type :help 'shell<CR> and read about all options starting with
>> "shell", esp. "default for Unix" value
>> 2. ?
>> 3. PROFIT
>>
>> Regards,
>> Matvey
>>
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/a8eca22a-ac3d-4917-8c89-9c7362ba88c0n%40googlegroups.com.
>

If a command gets wrong then it should probably be something about
quoting. But I cannot tell just like that. So don't be afraid to
experiment and try yourself.

Regards,
Matvey
Reply all
Reply to author
Forward
0 new messages