简体   繁体   English

运行.bashrc时找不到别名命令

[英]Alias command not found when running .bashrc

I'm trying to do the simplest of shell aliases like I always use to do. 我正在尝试做最简单的shell别名,就像我经常使用的那样。

Here's my .bashrc (and same happened with ZSH and .zshrc) for instance : 例如,这是我的.bashrc(与ZSH和.zshrc相同):

alias ll=“ls -al”
alias edit_http=“open -e /etc/httpd/conf/httpd.conf”

and here's my $PATH variable : 这是我的$ PATH变量:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

When I open a new terminal window I get this : 当我打开一个新的终端窗口时,我得到以下信息:

-bash: alias: -al”: not found
-bash: alias: -e: not found
-bash: alias: /etc/httpd/conf/httpd.conf”: not found

Here's my ls -al result of .bashrc : 这是我的.bashrc的ls -al结果:

-rwxr-xr-x@   1 ed    staff     78 Mar 17 03:55 .bashrc

Strangely I can type this into Terminal and it works : 奇怪的是,我可以在Terminal中键入它,并且可以正常工作:

alias ll="ls -al"

But not from within the .bashrc file. 但不是来自.bashrc文件中。

Any suggestions ? 有什么建议么 ? I've checked so many forum entries and nothing worked so far. 我检查了很多论坛条目,但到目前为止没有任何结果。

It looks like something went wrong during copying the alias into your .bashrc. 在将别名复制到您的.bashrc期间,似乎出了点问题。

You ended up with 'wrong' quotation mark. 您最终以“错误”的引号引起来。 Replace with " and it should work. is unicode but you require ascii quotation marks. For testing you can use this .bashrc 替换为" ,它应该可以工作。 是Unicode,但是您需要ASCII引号。要进行测试,可以使用此.bashrc。

# bashrc example
# won't work
alias ll=“ls -al”
# will work
alias la="ls -al"

And with this code you can verify your problem: 并使用此代码可以验证您的问题:

$ source .bashrc
-bash: alias: -al”: not found
$ ll
-bash: “ls: command not found
$ la
total 0
drwxr-xr-x   2 alneuman  staff    68 Mar 17 12:18 .
drwxrwxrwx+ 70 alneuman  staff  2380 Mar 17 12:18 ..

Have a look here at unix.stackexchange. 在这里查看unix.stackexchange。 Somebody had the same issue. 有人有同样的问题。 Brave new unicode world ;) 勇敢的新unicode世界;)

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

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