EDIT: The below is applicable to earlier versions of MSYS2. As of 2020-01-21, it is not required any longer. FeRD's answer seems to work best.
I wanted to use fish instead of bash. Unfortunately most of the methods here didn't work, possibly because fish syntax is so different.
What worked best was wzhd's idea about running exec fish
as the first thing when bash begins. There was still a problem, however: If I wanted to use bash, I had to edit .bashrc
to remove that line because even if I run it from fish it would just start another fish instance.
The best thing to do is to make sure that exec fish
runs when msys2 begins, but not every time bash begins.
The way I found is through the file msys2_shell.cmd
in msys2's installation folder. I found these lines:
set SHELL_ARGS=
:collectparams
if not "x%~1" == "x" set SHELL_ARGS=%SHELL_ARGS% %1& shift& goto :collectparams
It seems they're defining parameters to pass to bash as soon as it begins, but only when this script runs (unlike .bashrc
). So I added this line just after:
set SHELL_ARGS=%SHELL_ARGS% -c "exec fish"
Everything seems to be fine so far. Starting msys2 replaces bash with fish as soon as the former finishes loading, but if I need a bash command line I can still just start it with bash
.
I was trying to do basically this method, and I couldn't get fish to work without error. – leetNightshade – 2018-04-12T18:17:48.763
1The
rm
is actually really innocent. The end of the/usr/share/zsh/functions/Newuser/zsh-newuser-install
script contains anrm -f $tmpfile*
to clean up after itself. It's exactly the same in my Fedora install's current/usr/share/zsh/5.7.1/functions/zsh-newuser-install
. – FeRD – 2019-07-04T18:42:37.057