Bash 别名在 cygwin 中不起作用

Bash alias doesn't work in cygwin

有人可以向我解释如何设置 bash 别名吗?我在 windows 8.

上使用 cygwin

我在 /.bashrc 文件末尾添加了 alias my_first_alias='git status'。在 cygwin 中输入 my_first_alias 结果是 -bash: my_first_alias: command not found

尝试重新启动 cygwin,运行 . .bashrc 没有帮助。

你的别名命令的语法是正确的,只要别名命令实际被执行,它就应该能正常工作。听起来您的 .bashrc 文件在您启动 bash shell 时没有被加载。确保您的 ~/.bash_profile 文件中包含以下内容:

[[ -s ~/.bashrc ]] && source ~/.bashrc

还要确保 .bashrc 和 .bash_profile 的位置在您的主目录中。上面你引用了/.bashrc。我怀疑“/”是您的主目录。您可以通过输入以下命令从 shell 确定主目录的位置:

cd; pwd