【问题标题】:Unable to execute aliases defined in the .bashrc file in gitbash无法在 gitbash 中执行 .bashrc 文件中定义的别名
【发布时间】:2022-10-06 16:52:04
【问题描述】:

我在.bashrc 文件中添加了某些aliases,它指向kafkazookeeperstart-server bat 文件的Windows 位置。但是,当我在gitbash 中运行它们时,它会说Command not found 错误

例如,如果我在.bashrc 文件中有以下别名并且我在gitbash 中运行命令zoo 它会给出上述错误

alias zoo=\"D:/Tools/kafka_2.13-2.8.0/bin/windows/kafka-server-start.bat\"
  • Bash 不运行 Windows 批处理文件。使用 Windows 命令解释器来运行这些。
  • 无论如何,Kafka 在 Windows 中的运行并不好。您可能想改用 WSL2

标签: windows git-bash


【解决方案1】:

Gitbash 只读取.bash_profile 而不是.bashrc,要么在.bash_profile 中放置别名,要么将这些行放在.bash_profile 的顶部:

if [ -f ~/.bashrc ]
then
    . ~/.bashrc
fi

另见: Git for Windows doesn't execute my .bashrc file

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-21
    • 2013-10-11
    • 2021-09-24
    • 2021-08-16
    • 1970-01-01
    • 2015-03-28
    • 2014-10-29
    • 1970-01-01
    相关资源
    最近更新 更多