My shell migration record

Image credit: Fish shell logo

Table of Contents

From bash to zsh

Although I switched to the fish shell two weeks after using the zsh shell (the fish shell has a special introduction below), this does not deny that the zsh shell is still a good shell. You can switch from any shell to zsh shell in the following way.

  • Use the following instructions when installing zsh,

  brew install zsh (MacOS)
  apt install zsh (Ubuntu / Linux Mint)
  • If you want to know the shell currently installed in the system, enter the following command,

  cat /etc/shells
  • How to use zsh as your default shell? Enter the following command,

  chsh -s /usr/local/bin/zsh
  • Error reading about the configuration file

When the shell script explains the error, you can check the currently used sh path. For example, it may be that sh points to dash, which causes an error. View through the following statement.

  ls -l `which sh`
  • Script interpreter differences in syntax

When switching from traditional bash and other shells to zsh, you will find that the index of the first element of the collection starts from 1. If you want to start from 0, configure the following statement in the configuration file.

  • Fix array index for zsh:

  if [ "$ZSH_NAME" = "zsh" ];then
      setopt localoptions ksharrays

Configure zsh

Similar to the bash shell's .bashrc, the configuration of zsh also requires a configuration file. This file is the .zshrc file in the user directory. Click here to open the configuration file I uploaded to Github to download and use.

From zsh to fish-shell

After using the zsh shell, I switched to the fish shell in about two weeks. This is not because zsh is not good, but the natural completion and ease of use of fish attracted me. After moving to the fish environment, the shell toss is a conclusion. The following records of the process.

fish shell installation and default shell switch

This was mentioned above. Now we will introduce the instructions that different operating systems need to execute.

  • MacOS:

  brew install fish
  • Ubuntu/Linux Mint:

  apt install fish
  • OpenSUSE:

  sudo zypper install fish

If it is an OpenSUSE environment running under Windows, you may need root permission, then add sudo in front of the command. Use the following statement to view the shell used by the current system.

  cat /etc/shells

If your fish shell is displayed at /usr/bin/fish, Then execute the following statement to switch it to the default shell (add sudo if you have insufficient permissions).

  chsh -s /usr/bin/fish

Now reopen a terminal session and you will find that the default shell has been switched to fish. If it reports a lot of errors about hostname immediately after opening the fish shell, that is to say, the current environment lacks a package called hostname, then use the package manager of the distribution you are using to install hostname, for example, under OpenSUSE,

  sudo zypper install hostname

Configuration of Fish shell

The configuration I wrote was uploaded on Github, click here to view my configuration.

Common problems when using python under the fish shell

There are two issues that I need to pay attention to at present,

  • About tmux

When tmux has a session in the background, even if the update PYTHONPATH environment variable will not take effect, then all processes of tmux need to be closed before the update will take effect. In addition to fish, other shell environments should also be encountered. I first appeared in fish and kept it as a record.


The way to define environment variables in fish shell is set <variable_name> <parameter_1> <parameter_2> This method has great advantages and is very convenient, but for PYTHONPATH, then set PYTHONPATH <parameter_1>:<parameter_2> is more versatile. The reason is that after testing, both methods can be used normally under MacOS, but it is running on Jetson When testing under Ubuntu on Nano, only the second method is available. The specific reason is not yet clear, there may be different reasons for the operating system, It may also be caused by different python versions (For example, the version number is the same, but the different processor architectures cause differences in compilation methods and cause this problem).

Edit this page

Xin Li
Xin Li

Research in areas such as machine learning, deep learning, and artificial intelligence applications, specialize in priority sampling and learning algorithm for non-uniform data and offset data.Learn more

comments powered by Disqus