From c3fbdeb20fc9149cdc401433d5a200acf4f732c9 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 20 Dec 2024 12:02:05 -0700 Subject: [PATCH] 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 --- fish/functions/user_setup.fish | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fish/functions/user_setup.fish b/fish/functions/user_setup.fish index 2c989cb5..40bc9d5f 100644 --- a/fish/functions/user_setup.fish +++ b/fish/functions/user_setup.fish @@ -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