无法从 .bashrc 调用定义的函数

Cla*_*ong 3 command-line zsh bashrc

我有一个这样的函数.bashrc

function gs () {
  cmm="$1"
  if test -z "$cmm"
  then
    cmm="This is Manh Cuong's commit ."
  fi
  
  git add . && git commit -m "$cmm" && git push
}
Run Code Online (Sandbox Code Playgroud)

gs它与终端中的命令配合良好gs "new commit"。但我刚刚在我的 Ubuntu 20.04 Asus 笔记本电脑上安装了zshoh-my-zsh 。然后我打电话gsgs "new commit",它不再起作用了。我不知道如何解决它。有人可以帮助我吗。非常感谢。

Bal*_*Jha 7

如果您正在运行zshshell,那么您必须将其放入~/.zshrc而不是~/.bashrc.

将其添加到那里后,您可以打开新终端或运行 source ~/.zshrc来使用它。