Mientras trabajaba con Linux, debe haber oído hablar de algunos nombres extraños como bash, zsh, csh, etc., pero nunca llegó a conocerlos. Así que te diriges a Internet para leer sobre los distintos shells en Linux. En los sistemas basados en Unix y Linux, el shell predeterminado que se incluye con los sistemas es bash, pero zsh llama su atención de inmediato. zsh es un shell de Linux personalizable que admite complementos y ayuda a aumentar enormemente su productividad. En este artículo, explicaremos qué es zsh y cómo personalizarlo usando Oh My Zsh en Linux.
Tabla de contenido
¿Qué es z Shell (zsh) en Linux?
El Z-Shell (zsh) es un shell de Unix potente y altamente personalizable, que es popular entre los desarrolladores y usuarios avanzados. Fue desarrollado como una versión extendida de Bourne Shell (sh) por Paul Falstead en el año 1990 y está repleto de excelentes características y opciones.
Zsh es altamente personalizable y los usuarios pueden configurarlo según sus preferencias con los archivos de configuración o incluso usar varios complementos para ampliar su funcionalidad. Tanto zsh como bash son dos de los shells más populares disponibles para Linux. Aunque ambos se basan en Bourne Shell (sh), existen muchas diferencias críticas entre ellos. Veamos algunas de las diferencias que hacen que los usuarios elijan zsh sobre bash:
- Zsh tiene mejor autocompletado, autocorrección y complementos que bash.
- Zsh tiene mejor soporte para secuencias de comandos y globbing y coincidencia de patrones que bash.
- En general, zsh es un shell más potente y personalizable que bash.
En general, zsh ofrece funciones nuevas y mejoradas, lo que lo convierte en una opción popular para muchos usuarios. Ahora es el shell predeterminado en macOS, mientras que bash sigue siendo el shell predeterminado en la mayoríadistribuciones de Linux.
Cómo instalar zsh en sistemas Linux
Ahora que conoce todas sus características, pasemos a instalar zsh en Linux. Asegúrese de cumplir con los siguientes requisitos previos antes de que podamos continuar.
- Cualquier distribución popular de Linux, preferiblemente actualizada a la última versión
- Acceso Sudo o cualquier usuario con privilegios de root
- la última versión de wget, git y curl
Ahora, puede instalar zsh con los siguientes comandos según su distribución:
Para sistemas Linux basados en Debian:
sudo apt instalar zsh
Para sistemas Linux basados en Fedora:
sudo dnf instalar zsh
Para sistemas Linux basados en Arch:
sudor pacman -S zsh

2. Una vez instalado, puede verificar la instalación con el siguiente comando. Este comando mostrará la versión actualmente instalada de zsh.
zsh --versión

3. Para hacer que zsh sea el shell predeterminado en su sistema Linux, use el siguiente comando. Ingrese la contraseña raíz cuando se le solicite.
chsh -s $(que zsh)

4. Para usar z shell, reinicie su sistema. Una vez que se reinicie, abra la terminal y se le pedirá la nueva configuración. Prensa "0
” en el teclado para crear un archivo de configuración vacío, ya que le enseñaremos cómo configurar zsh con complementos y temas.
Cómo instalar Oh My Zsh en Linux
Hay muchos complementos y temas que puede usar para personalizar y configurar zsh. Puede ser difícil para los principiantes administrar y realizar un seguimiento de las configuraciones.
Para resolver este problema, Oh My Zsh fue desarrollado por Robby Russell en 2009. Oh My Zsh es un marco impulsado por la comunidad parainstalar y mantener complementos zsh, temas, crear nuevos alias de shell, y más. Incluye un conjunto de configuraciones y funciones preconfiguradas para facilitar las personalizaciones para usuarios de todo tipo. Para instalar Oh My Zsh, use cualquiera de los siguientes comandos:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
O
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Cualquiera de los comandos anteriores descargará el script Oh My Zsh y lo instalará. Una vez que se complete la instalación, se realizará una copia de seguridad del archivo .zshrc existente (donde se almacenan y cargan todas sus configuraciones) y se creará un nuevo archivo .zshrc con la plantilla predeterminada.
Personalice Z Shell en Linux usando Oh-My-Zsh
Ahora que Oh My Zsh está instalado en su sistema Linux, veamos cómo configurar Z Shell con él. Oh My Zsh viene con muchos temas, que puedes usar para personalizar la Terminal.
1. Utilice los temas Oh My Zsh preinstalados
Por defecto, oh my zsh aplicará el tema "robbyrussell". Pero si necesita cambiar el tema, puede elegir entre la amplia variedad de temas preinstalados. Puede obtener una vista previa de los temas en elpágina wiki oficial de oh my zsh. Para ver la lista de temas preinstalados. usa este comando:
ls ~/.oh-mi-zsh/temas/

Una vez que haya elegido un tema, debe modificar el archivo de configuración .zshrc. Utilice el siguiente comando para abrir el archivo de configuración en elNanoeditor de texto en Linux:
nano .zshrc
Ahora busque la línea que diceZSH_THEME="robbyrussell"
. Cambia el nombre del tema a uno que te guste en el siguiente patrón:
ZSH_THEME=""
Por ejemplo, si desea utilizar el tema "agnoster" en zsh en Linux, su parámetro debería verse así:
ZSH_THEME="agnóstico"

Luego, presione CTRL + X para salir del editor nano. Se le preguntará si desea guardar los cambios realizados o no. Aquí, presione "Y" para guardar los cambios y luego presione Entrar para finalmente guardar y salir del editor de texto nano. Utilice el siguiente comando para que los cambios surtan efecto:
fuente ~/.zshrc
2. Instala un tema personalizado
Si no le gustan los temas preinstalados en oh my zsh en su máquina Linux, incluso puede instalar temas personalizados de su elección. Por ejemplo, si desea instalar el tema "powerlevel10k", primero debe descargar el repositorio de temas con el siguiente comando:
clon de git --profundidad=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

A continuación, abra el archivo .zshrc en el editor de línea de comandos nano o en cualquier otro editor de texto de Linux de su elección:
nano .zshrc
Ahora, busca la línea que diceZSH_THEME
. Cambie el nombre del tema como se muestra a continuación:
ZSH_THEME="powerlevel10k/powerlevel10k"

Luego, siga los pasos mostrados anteriormente para guardar y salir del editor. Para aplicar sus cambios, use el siguiente comando una vez más. Luego se le solicitará el asistente de configuración de powerlevel10k. Siga los pasos para configurar según sus preferencias.
fuente ~/.zshrc
3. Habilitar complementos incluidos
Los complementos amplían la funcionalidad de zsh al siguiente nivel. Oh-My-Zsh viene con una amplia variedad de complementos, que puede usar modificando el archivo de configuración. Puede ver la lista completa de complementos disponibles en elpágina oficial de GitHubo ejecute el siguiente comando para ver la lista completa de complementos:
ls -a ~/.oh-my-zsh/complementos/

Una vez que haya elegido el complemento a usar, abra el archivo .zshrc en el editor de texto nano con el siguiente comando:
nano ~/.zshrc
Luego busque la línea que dicecomplementos =().
Agregue el nombre del complemento dentro de los corchetes en la siguiente sintaxis:
plugins=()
Por ejemplo, si desea usar los complementos git y docker, use este comando:
plugins=(git docker)

Ahora guarde y salga del editor de texto como se muestra arriba. Luego, ejecute el siguiente comando para aplicar los cambios:
fuente ~/.zshrc
Ahora puede usar los complementos en su flujo de trabajo, pero consulte la documentación oficial para obtener más información sobre los comandos.
4. Instalar complementos personalizados
Además de usar los complementos incluidos, incluso puede instalar algunos complementos personalizados populares para hacer que su flujo de trabajo sea más eficiente. Siga estos pasos para instalar complementos de terceros con oh my zsh en Linux:
1. Clone el repositorio git del complemento en el$ZSH_CUSTOM/complementos
. Por ejemplo, si necesita instalar el complemento de sugerencias automáticas, que recomienda comandos basados en el historial, use este comando:
clon de git https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

2. Una vez clonado el repositorio, abra el .zshrc en su editor de texto preferido y busque la línea que comienza concomplemento =
y agregue el nombre del complemento dentro del paréntesis como se muestra a continuación:
plugin=()
En este caso, agreguezsh-autosuggestions
dentro de los corchetes como se muestra a continuación:
plugin=(zsh-autosugerencias)

3. Una vez que haya terminado de agregar los nombres de los complementos, guarde y salga del editor. Ahora ejecute el siguiente comando para finalmente aplicar los cambios que ha realizado:
fuente ~/.zshrc
Comience a escribir cualquier comando que haya ejecutado y le sugerirá la versión más reciente. Pulse la tecla de flecha derecha o laFINtecla para aceptar la sugerencia.
5. Configurar las actualizaciones automáticas de Oh My Zsh
Con el archivo .zshrc, puede configurar todo el shell al contenido de su corazón para que sea completamente suyo. Zsh carga la configuración de este archivo cada vez que se inicia una nueva sesión de terminal. En este archivo, puede agregar sus funciones personalizadas, alias, combinaciones de teclas, etc.
Generalmente, Oh My Zsh configura actualizaciones automáticas, pero si no está habilitado de forma predeterminada, elimine el comentario de la siguiente línea dentro del archivo .zshrc:
zstyle ':omz:actualizar' modo automático

FAQs
How do I install zsh on Linux? ›
- There are two main ways to install Zsh: ...
- Verify installation by running zsh --version . ...
- Make it your default shell: chsh -s $(which zsh) or use sudo lchsh $USER if you are on Fedora. ...
- Log out and log back in again to use your new default shell.
- Test that it worked with echo $SHELL .
- Before installing zsh on your Mac, you need to determine whether or not Homebrew is already present on your device. First, open the Terminal by going to Launchpad and typing Terminal . ...
- To install zsh simply paste the following command: brew install zsh.
- $ type -a zsh ## find path to ksh ## $ chsh -s /bin/zsh ## change bash to ksh ## Verify it, type:
- $ grep "^${USER}" /etc/passwd. Log out and log in again. ...
- $ su - vivek. The type command display all locations containing an executable named bash/ksh/zsh/fish on your computer.
- Update the packages. ...
- Install prerequisite packages (ZSH, powerline & powerline fonts) ...
- Clone the Oh My Zsh Repo. ...
- Create a New ZSH configuration file. ...
- Install PowerLevel9k! ...
- Set up a theme for your Terminal — Open .zshrc File using gedit editor. ...
- Change your Default Shell.
Open the terminal, click Terminal -> Preferences and for the setting “Shells open with”, select the option “Command (complete path)” and enter “/bin/zsh”. Close and launch a new Terminal window. The shell should be zsh. You will be prompted to update your default shell to zsh.
How to install zsh on Bash? ›- Download the latest MSYS2 zsh package from the MSYS2 package repository. ...
- Install an extractor that can open ZST archives such as PeaZip or 7-Zip Beta.
- Extract the contents of the archive (which should include etc and usr folders) into your Git Bash installation directory.
The default shell is zsh. You can change the shell that new Terminal windows and tabs open with. In the Terminal app on your Mac, choose Terminal > Settings, then click General. Next to “Shells open with,” select “Command (complete path),” then enter the complete path to the shell you want to use.
Do you need to install zsh on Mac? ›The Z shell (also known as zsh ) is a Unix shell that is built on top of bash (the default shell for macOS) with additional features. It's recommended to use zsh over bash . It's also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.
How to use zsh after install? ›Once installed, you can set zsh as the default shell using: chsh -s $(which zsh) . After issuing this command, you'll need to log out, then log back in again for the changes to take effect. If at any point you decide you don't like zsh, you can revert to Bash using: chsh -s $(which bash) .
How do I manually change shell in Linux? ›To change your shell use the chsh command:
The chsh command changes the login shell of your username. When altering a login shell, the chsh command displays the current login shell and then prompts for the new one.
How do I find my default shell in Linux? ›
- 2.1. echo $SHELL. The $SHELL variable contains the name of the default shell. We can display its value: $ echo $SHELL /bin/bash. ...
- 2.2. echo $0. We can also use the echo command with the $0 variable: $ echo $0 bash. This approach works well on the command line but not from within a script.
The Bash Shell
Bash was first released in 1989, and for most Linux distributions it's the default Shell environment.
Installing Zsh
It's possible to run Zsh on Windows, but only on top of a Linux or Linux-like layer such as Windows Subsystem for Linux (WSL) or Cygwin.
- Run the following apt update command to update your system's local package index. ...
- Once updated, run the below apt install command to install Zsh and its dependencies. ...
- Lastly, run the zsh command below to check the version of Zsh installed.
- $sudo apt-get install git.
- $sudo apt-get install zsh.
- $sh -c “$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)”
- $sudo chsh -s $(which zsh) $(whoami)
- ZSH_THEME=”robbyrussell”
- Reference.
It's a hidden file, so you might not see it in your home directory, but you can view it by running open ~/. zshrc from the terminal. Swap out open with your favorite editor command, such as nano , subl or vim .
Where is the zsh config file in Linux? ›Zsh Config Path
By default, Zsh will try to find the user's configuration files in the $HOME directory. You can change it by setting the environment variable $ZDOTDIR . Personally, I like to have all my configuration files in $HOME/. config .
- Open the terminal application.
- Refresh package database on Ubuntu by running: $ sudo apt update.
- Install bash-completion package on Ubuntu by running: $ sudo apt install bash-completion.
- Log out and log in to verify that bash auto completion in Ubuntu Linux working properly.
- You can also use the command sudo bash install.sh or sudo sh install.sh to run the script.
- If you're just installing the software in your own home directory and don't need root permissions, you can use omit sudo and use ./install.sh instead.
- From Windows desktop Open Settings.
- Click on Update and Security.
- Under “Use developer features,” select the Developer mode option to set up the environment to install Bash. ...
- After installing the necessary components, you'll need to restart your computer.
What is the default shell for zsh? ›
The default shell is zsh. You can change the shell that new Terminal windows and tabs open with.
Is my Mac using zsh or bash? ›Every Mac comes with a Unix shell that provides a command line interface. Macs running macOS 10.15 and later use Zsh by default. Before that, Macs used the Bash shell by default. Of course, no matter what version of macOS you're using, you can change the shell your Mac is using.
What is the default zsh prompt? ›Typically, the default zsh prompt carries information like the username, machine name, and location starting in the user's home directory. These details are stored in the zsh shell's system file at the /etc/zshrc location. In this string of variables: %n is the username of your account.
Do I need to install Linux if I have a Mac? ›Conclusion. If you want to have the best of both Mac OS and Linux on your MacBook, you will have to install and run Linux on your Mac. The fastest way to install Linux on Mac is through the use of reliable virtual desktop software, such as Parallels. Click here to learn more about Parallels Desktop.
What does zsh mean in Terminal Mac? ›The Z shell, more commonly referred to as zsh , is a UNIX shell that is built on top of the Bourne shell (macOS default shell), better known as bash . Z shell is basically an extended version of Bash, with many additional features.
How do I enable zsh on my Mac? ›The default shell is zsh. You can change the shell that new Terminal windows and tabs open with. In the Terminal app on your Mac, choose Terminal > Settings, then click General. Next to “Shells open with,” select “Command (complete path),” then enter the complete path to the shell you want to use.
How to configure zsh on macOS? ›- Step 1: Install Zsh. brew install zsh. ...
- Step 2: Install Oh-My-Zsh. In terminal type the following command: sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- Step 3: Configure Oh-My-Zsh. ...
- Step 4: Install Plugins.
- You need to open the Terminal application on your macOS.
- The shell option must be tapped on, located in the menu bar.
- Now, hit the "Reset" option from the menu; otherwise, you may type on your Mac keyboard the option+command+R key.
- Click the "Dash" icon, and then type "terminal" in the search box.
- Click the "Terminal" icon to launch the Gnome terminal with its bash shell.
- Close the Terminal window.
- Press "Ctrl-Alt-T" to open the shell from the keyboard.
- Press "Ctrl-Alt-F1" to open a virtual Linux terminal.
chsh --shell /bin/bash <your-username> This would change the default shell to 'bash'.
How do I change the default terminal in Linux? ›
- Run update-alternatives --config x-terminal-emulator to see all available terminals installed on your system.
- Select the terminal you prefer.
The actual process for changing your default shell from Bash to ZSH is extremely easy. Just run chsh -s /bin/zsh . Note that you'll need to supply the correct path your ZSH binary which you can get with the which zsh command we used earlier. Click here for more information on the chsh command.
How do I find the shell command details? ›Searching shell command history
Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.
The default shell runs when you open a terminal window. chsh -s /bin/ksh – Change the shell used from /bin/bash (default) to /bin/ksh for your account using the chsh command.
What is a login shell Linux? ›A login shell is exactly that: a shell that launches when you directly log in to the Linux machine. When you log into your system from a virtual console or over SSH, the shell that starts is a login shell. By contrast, if you start up a terminal window, that shell session is typically not a login shell.
What is shell prompt in Linux? ›Shell Prompt
The prompt, $, which is called the command prompt, is issued by the shell. While the prompt is displayed, you can type a command. Shell reads your input after you press Enter. It determines the command you want executed by looking at the first word of your input. A word is an unbroken set of characters.
- Option 1: open the terminal and cd into the folder where your script is located. ...
- Option 2: make the script 'executable' by running chmod +x myscript.sh on the terminal. ...
- Option 3: move myscript.sh into one of the folders in your PATH (to see what these folders are, run echo $PATH ).
Update your Terminal preferences to open the shell with the command /bin/bash , as shown in the screenshot above. Quit and restart Terminal. You should see “hello from bash”, but if you run echo $SHELL , you will see /bin/zsh .
Is zsh using bash? ›It uses a completely different syntax. Bash uses . inputrc and bind builtIn to bind keys to readline commands. Zsh uses bindkey builtIn to bind keys to zle widgets.
How do I install zsh plugins? ›Install Plugins
Custom plugins can be installed at ~/. oh-my-zsh/custom/plugins . To use a plugin, you can simply add it to the plugins list in your ~/. zshrc file.
Why use zsh instead of Bash? ›
Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.
How to remove zsh in Linux? ›If you are looking to uninstall zsh from a Ubuntu/Debian/Linux Mint based systems, then you need to use sudo apt remove zsh or sudo apt-get remove zsh command as shown below. cyberithub@ubuntu:~$ sudo apt remove zsh [sudo] password for cyberithub: Reading package lists...
How do I customize my zsh prompt in Linux? ›To customize the ZSH prompt, we need to modify the prompt= variable inside the . zshrc file. We can populate the prompt variable with various placeholders, which will alter how the ZSH prompt appears.
How do I switch from bash to Oh my zsh? ›If you have Bash set as the default and you launch Terminal or open a new Terminal session, you will see the following message: “The default interactive shell is now zsh. To update your account to zsh, please run chsh -s /bin/zsh .” Hit enter or return.
How do I know if zsh is installed on Linux? ›You can check if this is the case and if so, which version you are running using the command: zsh --version . If the version is 4.3. 9 or higher, you should be good to go (we'll need at least this version to install Oh My Zsh later on).
Does Linux come with zsh? ›Zsh is available for Microsoft Windows as part of the UnxUtils collection and has been adopted as the default shell for macOS and Kali Linux. The "Oh My Zsh" user community website provides a platform for third-party plug-ins and themes, featuring a large and active contributor base.
Where is zsh located in Linux? ›ZSH Settings #
These are stored in a . zshrc file located in your home directory. It's a hidden file, so you might not see it in your home directory, but you can view it by running open ~/. zshrc from the terminal.
The Z Shell, or Zsh is also a UNIX shell that is very similar to Bash. You can also script and use the shell as a command interpreter. Zsh is an extension of the Bourne shell with a lot of improvements. Zsh was released in 1990 by Paul Falstad, and it has some features that Bash, Korn Shell, and C Shell share.
Do I need to install zsh? ›The Z shell (also known as zsh ) is a Unix shell that is built on top of bash (the default shell for macOS) with additional features. It's recommended to use zsh over bash . It's also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.
Should I use zsh or Bash? ›Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.
Does Mac run on Linux? ›
The MacBook Pro, like all the best Macs, is a popular developer laptop and, even with the transition to Apple Silicon, it's still perfectly possible to use Linux.
What is a zsh terminal? ›What is Zsh? Zsh, also known as the Z shell, extends functionality of the Bourne Shell (sh), offering newer features and more support for plugins and themes.
What is the profile file for zsh? ›zshrc . This file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. Within it you can change your terminal prompt, change the colors of text, add aliases to functions you use all the time, and so much more.