Skip to content

Commit 46c5fff

Browse files
committed
fish: user_setup: Modify .bashrc to launch fish by default
This helps always get fish within a systemd-nspawn container spawned with '--bind-user', as the shell value from /etc/passwd does not get transferred in. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent fe33eff commit 46c5fff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fish/functions/user_setup.fish

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ function user_setup -d "Setup a user account, downloading all files and placing
192192
rm -rf $__fish_config_dir/config.fish
193193
ln -frsv $ENV_FOLDER/fish/config.fish $__fish_config_dir/config.fish
194194
195+
# Invoke fish by default in bash
196+
# https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish
197+
if not begin
198+
test -f $HOME/.bashrc
199+
and string match -qr 'exec fish \$LOGIN_OPTION' <$HOME/.bashrc
200+
end
201+
echo '
202+
if [[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z $BASH_EXECUTION_STRING && $SHLVL == 1 ]]; then
203+
shopt -q login_shell && LOGIN_OPTION=\'--login\' || LOGIN_OPTION=\'\'
204+
exec fish $LOGIN_OPTION
205+
fi' >>$HOME/.bashrc
206+
end
207+
195208
# Global .gitignore
196209
set gitignore $HOME/.gitignore_global
197210
git config --global core.excludesfile $gitignore

0 commit comments

Comments
 (0)