简体   繁体   English

在bash.bashrc中设置别名

[英]Set aliases in bash.bashrc

When I try to set aliases, I get two different results using two different methods. 当我尝试设置别名时,使用两种不同的方法会得到两种不同的结果。 I'm using cygwin. 我正在使用cygwin。

METHOD 1: 方法1:

In cygwin I execute the following: 在cygwin中,我执行以下命令:

alias python='/cygdrive/c/python27/python.exe'

python <name of python file>

...and it runs just fine, as expected ...并且运行正常,正如预期的那样

METHOD 2: 方法2:

In my bash.bashrc file I add the following line: 在我的bash.bashrc文件中,添加以下行:

alias python='/cygdrive/c/python27/python.exe'

python <name of python file>

...and I get the following error: ...并且出现以下错误:

:no such file or directoryython.exe

Just two questions: What is the difference between these two methods? 只是两个问题:这两种方法有什么区别? Why is one causing and error and one is not? 为什么是一种原因和错误,而另一种原因不是错误? Thanks <3 谢谢<3

The error indicate that the bash.bashrc file was not loaded. 该错误表明未加载bash.bashrc文件。

Check these: 检查这些:

  1. The bashrc filename is usually .bashrc / .bash_profile and it's in the user's home directory. bashrc文件名通常是.bashrc / .bash_profile ,位于用户的主目录中。 Or it should exists as /etc/bash.bashrc . 或者它应该以/etc/bash.bashrc存在。
  2. The file is not loaded automatically, restart the shell to load it. 该文件不会自动加载,请重新启动外壳程序以加载它。

See how this error is all confused looking? 看到这个错误如何让人困惑吗?

:no such file or directoryython.exe

Your bash.bashrc file has DOS line endings. 您的bash.bashrc文件具有DOS行结尾。 Go fix that. 去解决那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM