From e579621279fa6a7f51bc6802fadc3667b1457103 Mon Sep 17 00:00:00 2001 From: native-api Date: Wed, 27 Oct 2021 00:15:55 +0300 Subject: [PATCH] Created MacOS login shell (markdown) --- MacOS-login-shell.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 MacOS-login-shell.md diff --git a/MacOS-login-shell.md b/MacOS-login-shell.md new file mode 100644 index 0000000..c6392e1 --- /dev/null +++ b/MacOS-login-shell.md @@ -0,0 +1,42 @@ +# Configure the terminal to run your shell as a login shell + +The stock shell configuration examples for MacOS assume that the shell in the terminal runs as a login shell. + +## Check if the current shell is a login shell + +* Bash: + + ```bash + shopt -q login_shell && echo 'Login shell' || echo 'Not login shell' + ``` +* Zsh: + + ```zsh + if [[ -o login ]]; then echo "login shell"; else echo "not login shell"; fi + ``` + +* Fish: + + ```fish + status --is-login; and echo "login shell"; or echo "not login shell" + ``` + +## Set the shell to run as a login shell + +There are two possible ways here. + +### Set the shell as your login shell (recommended) + +* `System Preferences` > `Users and groups` > Open the padlock to allow changes > +Right click on the corresponding user's name > `Advanced options` > Select the +shell from the dropdown list next to `Login shell` + +* Then, in the Terminal app: `Preferences` > `General` > `Open shells with` > `Predefined login shell` + +### Configure the terminal to explicitly run a shell as a login shell + +* In the Terminal app: `Preferences` > `General` > `Open shells with` > `Command (full path)` + + * Zsh: `/bin/zsh --login` + * Bash: `/bin/bash -l` + * Fish: ` --login`