From 0954f959c39903d436e27d22d83a7e8c66414e63 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 20 Dec 2024 02:44:55 -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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fish/functions/user_setup.fish b/fish/functions/user_setup.fish index 2c989cb5..2f37df88 100644 --- a/fish/functions/user_setup.fish +++ b/fish/functions/user_setup.fish @@ -192,6 +192,16 @@ 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