How can you export your .bashrc to .zshrc?

前端 未结 2 1436
天涯浪人
天涯浪人 2021-01-29 21:23

I am trying to move to zsh from Bash.

I put my .bashrc directly to my .zshrc, and it caused a lot of errors when I try to use Bash again.

How can you exp

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-29 22:07

    While lhunath's answer pushed me in the right direction, zsh does not seem to source .profile automatically. Lot's of good info on this topic can be found on this superuser post.

    The adaption I'm using is putting common aliases and functions in .profile and manually sourcing them as follows:

    In ~/.bashrc:

    source ~/.profile
    

    In ~/.zshrc:

    [[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
    

    emulate is a zsh builtin command. With single argument set up zsh options to emulate the specified shell as much as possible.

提交回复
热议问题