DEV Community

Cover image for Set zsh as the default shell in your terminal.
Ismael Garcia
Ismael Garcia

Posted on • Edited on

12 2 1 1 1

Set zsh as the default shell in your terminal.

How to set ZSH as the default shell in your terminal.

ZSH also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes. Since it’s based on the same shell as Bash that makes it easy for use and switching over is a breeze.

Open vim or your favorite code editor

sudo vim ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Now we need to edit the file and add the following line to the end of the file remember to add a comment just to remember, what is that line of code task.

exec zsh
Enter fullscreen mode Exit fullscreen mode

It will execute the command every time you load the terminal and run your zsh shell.

This is not the only way that you can get to the goal of setting zsh as the default shell but for me, this is the best and easy way to do the job.

Please if you have a better solution let me know I'm willing to learn new ways and do it in a better way.

Update

The best solution is just use the fallowing command to switch

chsh -s $(which zsh)
Enter fullscreen mode Exit fullscreen mode
view raw socials.md hosted with ❤ by GitHub

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (5)

Collapse
 
ihorvorotnov profile image
Ihor Vorotnov • Edited

You aren't actually making it a default shell, your shell is still /usr/bin/bash. You are just executing a ZSH framework on top of bash shell and the only environment where it makes sense is Cygwin on Windows. On all other operating systems you'd be better off by actually making it your default login shell with a standard chsh command chsh -s $(which zsh). It's even easier, isn't it? And won't bite you back if you're developing shell scripts.

Collapse
 
leamsigc profile image
Ismael Garcia • Edited

Thank you for the information and for the better solution I really appreciated.
Yeah, you are right it is better to make it the default login shell.

I'm not developing scripts for now, but like you said you never know in the future right.

Collapse
 
calvez profile image
calvez

Could be good if @leamsigc update this post because google ranks it on pretty good place. It's very bad solution and nonsense.
@ihorvorotnov said the correct way.

Collapse
 
mehehehehe82 profile image
Tem326

Why would you ever want to edit your bashrc as root?

Collapse
 
dananee profile image
GoldCoin

thank you bro it workes fine

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay