Skip to content

Commit

Permalink
fish: user_setup: Modify .bashrc to launch fish by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nathanchance committed Dec 20, 2024
1 parent 4d49e67 commit c3fbdeb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fish/functions/user_setup.fish
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ function user_setup -d "Setup a user account, downloading all files and placing
rm -rf $__fish_config_dir/config.fish
ln -frsv $ENV_FOLDER/fish/config.fish $__fish_config_dir/config.fish
# Invoke fish by default in bash
# https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish
if not begin
test -f $HOME/.bashrc
and string match -qr 'exec fish \$LOGIN_OPTION' <$HOME/.bashrc
end
echo '
if [[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z $BASH_EXECUTION_STRING && $SHLVL == 1 ]]; then
shopt -q login_shell && LOGIN_OPTION=\'--login\' || LOGIN_OPTION=\'\'
exec fish $LOGIN_OPTION
fi' >>$HOME/.bashrc
end

# Global .gitignore
set gitignore $HOME/.gitignore_global
git config --global core.excludesfile $gitignore
Expand Down

0 comments on commit c3fbdeb

Please sign in to comment.