- Adding Aliases to Shell in Catalina (Mac OS)
- How to change default shell to bash on Macos Catalina/Big Sur
- How to set default shell to bash on Macos Catalina
- List your shell options on Unix
- How to change your zsh to bash on macOS
- Find out your bash version
- How do I update or upgrade bash version?
- Conclusion
- Zsh Vs. Баш в macOS Каталина
- Apple replaces bash with zsh as the default shell in macOS Catalina
- Share this story
- Share All sharing options for: Apple replaces bash with zsh as the default shell in macOS Catalina
- How to switch back to bash in Terminal on macOS Catalina
- Switch back to bash in Terminal
- Change default shell to bash
Adding Aliases to Shell in Catalina (Mac OS)
I recently started using a mac with the Catalina OS (the latest one). Late to the party, I have been impressed by the features so far.
However, I recently ran into a bit of trouble when attempting to add some of my command line aliases. Here is how I resolved the issue with the help of StackOverflow.
To initially add my aliases, I edited the bash_profile config script, which is the method I had used for High Sierra.
I added a few of my favourite aliases and started a new shell session but received an error when trying to use one of the commands:
I guessed that the command was not working on account of a syntax error (possibly a trailing space somewhere).
On closer inspection, I noticed that zsh had replaced bash in the message.
As it turns out, the version of shell used with the latest OS (Catalina) is now zsh, also known as Z Shell. To make this clearer, running bash as a command to switch profiles within the session will display the message below:
Arguably, the change is due to zsh being a more modern version of shell.
After some searching on StackOverflow, I found that the solution was to add the aliases to the zsh equivalent of the config file. In my experience, I had to create the file itself:
After that, I readded the commands from the bash_profile script to .zshrc . I started a new shell session and found that they were all working again successfully.
An alternative to this solution would be to change your systems shell profile back to bash. Doing so is possible using the change shell command:
Once you have changed back to bash, you should be able to start a new session, and any aliases saved in bash_profile should work as expected. Keep in mind that the version of bash installed by default is out of date:
The latest version of bash is 5.0. It’s possible to read more about updating to the latest version here.
Finally, you can also see all of the versions of shell available on your machine by running the following command:
Despite having the option to switch versions being helpful, the advantages between versions seem relatively small. However, one of the most innovative features offered by Zsh, is the Oh My Zsh framework. Oh My Zsh is an opensource shell framework, which provides a ton of customisations to shell, in the form of themes and plugins. The plugins, in particular, look quite helpful for making the command line quicker and more intuitive to use, which is arguably the point of aliases anyway.
Thank you for reading and please let me know in the comments if this article was helpful in any way.
Источник
How to change default shell to bash on Macos Catalina/Big Sur
I noticed that my default shell set to zsh on Macos Catalina/Big Sur. How do I change my default shell to bash on Macos Catalina or above using the command line or GUI options?
A Unix shell is nothing but a program that accepts Unix commands from the keyboard and executes them. For a long time, the bash was a default shell in macOS. However, Apple replaced Bourne Again SHell with Z shell for licensing reasons. This page explains how to set up bash as your default login shell and interactive shell on macOS Catalina, “Big Sur” and above.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | macOS OS and Terminal app |
Est. reading time | 3 minutes |
How to set default shell to bash on Macos Catalina
The procedure is as follows:
- Open the terminal application.
- List available shells by typing cat /etc/shells .
- To update your account to use bash run chsh -s /bin/bash
- Close terminal app.
- Open the terminal app again and verify that bash is your default shell.
List your shell options on Unix
You must only include shells listed in the /etc/shells file. Otherwise, your account will get locked up when an invalid shell name or path is specified. Hence, always verify paths. Simply run the following cat command:
cat /etc/shells
How to change your zsh to bash on macOS
Of course, you are not limited to bash. We can see a list of all other shell installed by using the cat command and then use that shell:
# get a list
cat /etc/shells
# Change to ksh
chsh -s /bin/ksh
## OR fish shell if installed on your Mac ##
chsh -s /usr/local/bin/fish
See “How do I find out what shell I am using on Linux/Unix?” for other commands-line tips and tricks.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Find out your bash version
Type the following command:
bash —version
Sample outputs:
I am using bash version 3.2.57 on macOS.
How do I update or upgrade bash version?
Homebrew installs the apps you need that Apple didn’t include in their base operating system or app store such as cutting edge version of gnu/bash. See how to install Homebrew on macOS to use the brew package manager
Homebrew user can type the following brew command to install the latest version of bash on Catalina:
brew install bash
The newer version of bash is located at /usr/local/bin/bash:
ls -l /usr/local/bin/bash
cat /etc/shells
If not in /etc/shells, append it:
sudo -i
echo /usr/local/bin/bash >> /etc/shells
We can use the which command or type command/command command to locate a command path on macOS or Unix-like operating systems. For instance, get the pathnames of the files (or links) which would be executed in the current environment:
Set default shell to /usr/local/bin/bash, run the following chsh command chsh -s /usr/local/bin/bash
Verify new gnu/bash version:
bash —version
/usr/local/bin/bash —version
Sample outputs:
Conclusion
You learned how to set and use bash as the default shell on your Mac Catalina as Apple changed the default from bash to zsh.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
Zsh Vs. Баш в macOS Каталина
С запуском macOS Каталина, помимо множества новинок и функций, Apple введены и Zsh (Z оболочка) на месте Колотить (Борн-опять оболочка). Пользователи, знакомые со скриптами Bash и интерактивными командными строками из терминал, они быстро заметили это изменение. В Терминале предлагается выполнить командную строку, чтобы сделать это переход от баш к зш.
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Используется с 16 много лет назад, со времен OS X 10.2 Jaguar, Bash использовался в качестве основной оболочки разработчика для скрипты и командные строки к основанию системы macOS.
Почему был осуществлен переход от Bash к Zsh?
Проще говоря, речь идет об ограничениях, налагаемых Лицензия на распространение (GNU) для использования Bash.
Bash находится в процессе разработки, достиг версии 5.0. Окончательная версия выпущена в начале января 2019. Тем не менее, Apple используется до MacOS Mojave (выпущен осенью 2018 года) устаревшая версия. Было предпочтительнее Баш НИЧЕГОверсия 2007. Новые версии Bash были выпущены по лицензии GNU General Public License модифицированный (GPLv3), что требует некоторых ограничения и оговорки для поставщиков программного обеспечения.
Баш против. ЗШ
Для пользователей переключение с Bash на Zsh должно быть радостью. Особенно для тех, кто часто пользуется терминалом. Zsh (Z shell) основан на том же языке, что и Bash, но он приносит интересные особенности. Интуитивно понятные командные строки, плагинВездеходы и темы графика.
Помимо команд Bash, в Zsh есть много других специальных команд, и многие из них могут быть настроены пользователем для выполнения некоторых операций. Имя.
— автоматическое завершение командных строк (автозаполнение)
— расширенные переменные
— заменить путь
— интуитивно понятное расширение пути. “/u/lo/b ” идет в «/ usr / local / bin»
— поддержка о-мой-ЗШ для расширенных возможностей
– поддержка тем в терминале
— многие другие, представленные здесь.
О-My-ЗШ это самый популярный фреймворк для Zsh, поставляемый со многими плагинВездеходы и темы включен. Простота установки, настройки и настройки.
Как установить Oh-My-Zsh для Zsh на macOS
Выполните командную строку в Терминале:
sh -c «$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)»
После установки oh-my-zsh у вас щедрая библиотека плагины если темы. Кроме того, есть много параметров конфигурации и настройки в зависимости от ваших предпочтений. Все детали найти здесь.
Модуль и утилиты рекомендации: iTerm2 (эмулятор терминала, который заменит терминал), Homebrew и тема POWERLEVEL9K для Zsh (Oh-My-Zsh).
Как мы меняемся default оболочка в macOS Каталина
Если вы не удовлетворены Zsh, вы всегда можете вернуться к Bash через macOS Екатерина. Однако имейте в виду, что это элементарная версия Bash 2007 года выпуска.
Выполните командную строку в Терминале, чтобы вернуться в Bash:
Помимо Bash и Zsh вы также можете активировать другие оболочки в macOS Каталина.
Выполнить в терминале команду cat /etc/shells через которую можно увидеть снаряды, входящие в macOS Каталина.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
Источник
Apple replaces bash with zsh as the default shell in macOS Catalina
Big news for developers at WWDC
Share this story
Share All sharing options for: Apple replaces bash with zsh as the default shell in macOS Catalina
bash on macOS Mojave Photo by Tom Warren / The Verge
Apple unveiled macOS Catalina yesterday with support for iPad apps and lots of new features, but a big change for developers and power users was missing from the on stage presentation. Starting with macOS Catalina, Macs will now use zsh as the default login shell and interactive shell across the operating system. All newly created user accounts in macOS Catalina will use zsh by default. Bash will still be available, but Apple is signaling that developers should start moving to zsh on macOS Mojave or earlier in anticipation of bash eventually going away in macOS.
Apple hasn’t explained exactly why it’s making this change, but bash isn’t exactly a modern shell as it’s implemented in macOS, and a switch to something less aging makes a lot more sense for the company. Apple is stuck using version 3.2 of bash that has been licensed under GPLv2, as newer versions are licensed under GPLv3. Apple has kept clear of using GPLv3 packages in macOS as the license is generally more restrictive to companies like Apple that sign their own code and it includes explicit patent grants, too.
While a number of Mac developers have already moved on to even more modern shells like Fish, zsh is more compatible with Bourne shell (sh) and mostly compatible with bash. There’s a lot more flexible autocomplete with zsh, and if you’re interested in moving to zsh on macOS Mojave then there are plenty of helpful guides for getting the best terminal setup and getting used to zsh before bash is fully phased out.
Источник
How to switch back to bash in Terminal on macOS Catalina
Jul 22, 2019
Comment
The default shell on macOS Catalina has changed from Bash to Zsh. You have to run a command to actually make the change and many think that Zsh is better. If you’ve made the switch and want to change back to Bash as the default shell whenever you open Terminal, it’s an easy change to make. Here’s how you can switch back to bash in Terminal.
Switch back to bash in Terminal
Open the Terminal app and on the menu bar select the Terminal menu item. From the menu, select Preferences. On the Preferences window, go to the General tab. There’s an option called ‘Shells open with’. Select ‘Command (complete path):’. In the field below it, enter the following;
Quit Terminal and open it again. Terminal will now always open in Bash.
Change default shell to bash
The previous section changes which shell the Terminal opens with however it doesn’t actually change the default shell back to bash. It has more or less the same effect but if you want to change the default shell back to bash, run the following command in Terminal. You will have to enter your password.
After this command, you can leave the option in the Terminal preferences set to ‘Default login shell’ under the ‘Shells open with’ option.
Once you update to Catalina, there’s no removing Zsh from the system. Since you can change the shell back to Bash, it doesn’t matter much. The only downside of changing back to Bash is that each time you open a new Terminal window, there will be a message at the top telling you to switch to Zsh and giving you the command to make the switch.
As for which shell you should use, it’s really up to you. There are other shells besides Bash and Zsh available on macOS. If you want to view a list of all the shells that are available run the following command in Terminal.
After that, you can choose any one of the shells and use them either as the shell that Terminal uses or change the default shell. The command is the same except you have to change ‘bin/bash’ to whichever shell you want to set as the default.
If you want to switch to Csh, you’d run the following command;
Likewise, to change the shell that it opens to without changing the default shell, enter this in Terminal’s preferences.
Источник