For the complete documentation index, see llms.txt. This page is also available as Markdown.

6.3 Switching Shells

The easiest way to permanently change the default shell is to use chsh. Running this command opens the editor configured by the EDITOR environment variable, which defaults to vi(1).

Zsh

Zsh is the default shell for Kali Linux and macOS. Zsh is not only a shell designed for interactive use, but also a powerful scripting language. zsh integrates many practical features from most mainstream shells such as bash, ksh, and tcsh, while also adding numerous original features.

Installing Zsh

  • Install using pkg:

# pkg install zsh zsh-completions zsh-autosuggestions zsh-syntax-highlighting

Package descriptions:

Package
Description

zsh

Zsh shell

zsh-completions

Automatic completion

zsh-autosuggestions

Fish shell-like Zsh auto-suggestions

zsh-syntax-highlighting

Fish shell-like Zsh syntax highlighting

  • Install using Ports:

# cd /usr/ports/shells/zsh/ && make install clean
# cd /usr/ports/shells/zsh-completions && make install clean
# cd /usr/ports/shells/zsh-autosuggestions/ && make install clean
# cd /usr/ports/shells/zsh-syntax-highlighting/ && make install clean
  • View Zsh installation information

Configuring Zsh

Change the current user's default login shell to Zsh:

Enter your password at the prompt and press Enter to change the shell. After logging out and logging back in, you can start using the new shell.

Note

chsh, chfn, and chpass are the same program, invoked through different names. Non-superusers can only change their shell to a standard shell listed in /etc/shells; changing from or to a non-standard shell will be rejected. The editor is determined by the EDITOR environment variable, defaulting to vi(1). After information verification, chpass automatically calls pwd_mkdb(8) to update the user database.

Edit the ~/.zshrc file and add the following lines:

Directory structure:

Use immediately:

Theming and Beautification

In addition to basic configuration, you can also beautify the shell interface through themes. Powerlevel10k is a widely used Zsh theme. The installation and configuration method is as follows:

Directory structure:

Reload the Zsh configuration file to activate the Powerlevel10k theme:

Follow the prompts to answer several questions to complete the configuration. It will take effect after restarting.

References

Bash

Bash (Bourne Again shell) is a shell program developed by the GNU Project as an enhanced replacement for the Bourne shell (sh). Bash is compatible with sh syntax and integrates useful features from csh and ksh, including command-line editing, command history, programmable completion, and job control. Bash is the default shell for most Linux distributions, but it is not a base system component in FreeBSD.

Installing Bash

  • Install using pkg:

  • Install using Ports:

Package descriptions:

Package
Description

bash

Bash shell main program

bash-completion-freebsd

Bash completion library extension for FreeBSD, installed automatically as a dependency

bash-completion-zfs

Bash completion library extension for OpenZFS

  • View post-installation configuration

Configuring Bash

After installing Bash and the related completion libraries, configuration is required for proper operation.

Related file structure:

To load Bash completion functionality, edit the ~/.bash_profile file and add the following line:

Use immediately:

Last updated