1

When I do source $HOME/.bashrc, it results in the following:

screenshot

As you can see, it jumbles up the text where the path of the current directory would be. I am calling this because I am trying to change the colors of the directories when using ls, but it only works when I source .bashrc.

1
  • You can skip the first part of my answer if you don't want to use the default zshrc setup. The rest of the answer will still work but you will need to restart zsh to get rid of the jumbled up text.
    – mchid
    Feb 10, 2020 at 9:49

1 Answer 1

0

Before you begin, exit out of zsh and then run the zsh command. You should get a prompt that asks you to make a selection. Press 2. This will create a default ~/.zshrc file.


Files with the "rc" suffix are called run-control files¹.

bash uses a ~/.bashrc file for configuring your bash session and zsh uses a ~/.zshrc file.

The ls configuration in your bashrc file uses "aliases". Run the following command to show all of your ls aliases:

cat ~/.bashrc | grep "alias.*ls"

Now, to transfer those aliases to your ~/.zshrc file, run the following commands:

cat ~/.bashrc | grep "alias.*ls" >> ~/.zshrc
. ~/.zshrc

Note: . ~/.zshrc is the same as source ~/.zshrc but with less typing.


You can do the same thing for grep:

cat ~/.bashrc | grep "alias.*grep" >> ~/.zshrc
. ~/.zshrc

¹inherited from "rc file" used on older Unix systems

1
  • Different syntax is sometimes used for zsh and bash. See the section "prompt" in this detailed answer for the customized prompt differences.
    – mchid
    Feb 10, 2020 at 6:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .