1

How can I copy all the the command paths from the bash environment $PATH variable to the zsh environment?

I'm on macOS 11.6.1 (and about to install 11.6.6).

Many of the commands I used in bash don't work in zsh (the new default for Apple's Command line shell for new accounts). How can I get started with fixing my path?

7
  • There are quite a few questions about how to set PATH in both bash and zsh on the site, some of them are listed in the Related section at right. Did you look at the answers there for pointers?
    – nohillside
    Jun 8 at 6:10
  • 1
    If you use a different shell, you need to set up it. I would use a text editor, and mimic the setup of your previous bash in the respective zsh setup files. Since bash and zsh share some similarities, some parts may be copied verbatim, but you still will need to manually inspect each statement to verify that it work the same way in zsh. The whole process will likely not only relate to your PATH, but to all other settings as well. BTW, I personally find it much more convenient in zsh to use the array path instead of the scalar PATH, but this is a matter of taste of course. Jun 8 at 7:05
  • I set up bash many years ago and added commands copying lines from blogs over the last few years. Can't retrace those steps unfortunately. \ Jun 8 at 10:36
  • 1
    All the configurations you did for bash are still in .bashrc, can‘t you just copy them over? If you got stuck doing this, please add some details about it to the question.
    – nohillside
    Jun 8 at 10:48
  • 2
    Post the results of the following command grep -E '(PATH|path)' .profile .bash_profile .zprofile .zshenv .bashrc .zshrc. Also do you know how to use a command line text editor or do you rely on a GUI text editor?
    – fd0
    Jun 8 at 18:27

1 Answer 1

1

The main thing is to run the old shell and then echo $PATH.

bash
echo $PATH
exit 

At that point, you can copy that value and paste it in your zsh dot files as a comment and work on replicating the missing items.

I don’t know a tool that converts the path or files, but here is a place for you to start your learning on z shell. You can keep using bash and take your time setting up zsh so I recommend tiny steps on small tasks like you identified. First fix the path, then fix the next item with a new question is my advice. You don’t need to redo all four years of setup in one leap.

3
  • good advice. I was since recommended in the #HaskellTooling discord channel to use Fish as a terminal environment. even more incompatibilities! basic setup scrips for tools like GHC (ghcup) not working because script language is obviously different. what language do bash/zsh/fish use? is it LISP? Jun 11 at 9:12
  • Mike, this may work for static PATH definitions, it will not work if PATH gets built dynamically based on system state.
    – nohillside
    Jun 12 at 19:18
  • @wide_eyed_pupil Bash and Zsh use shell scripting. As both shells are extensions of the POSIX standard, the syntax is pratically identical (zsh offers more functionality though).
    – nohillside
    Jun 12 at 19:19

You must log in to answer this question.

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