Zsh 别名无法像 bash 中那样工作

发布于 2024-09-13 08:04:09 字数 474 浏览 0 评论 0原文

我在 .bashrc 中使用此别名,但在使用 .zshrczsh 中似乎不起作用。我使用的其他别名工作正常,因此我知道 .zshrc 正在获取其他别名。

alias rubydev3="cd ~/code/ruby/rails/rails3projects/"

这是错误消息:

cd:cd:10: no such file or directory: /home/jryan/code/ruby/rails/rails3tutorial/

我不知道 cd:cd:10 是否意味着任何应该作为线索的东西,但我刚刚开始使用 zsh 所以我我不知所措。如果该命令应该像我在这篇文章中那样工作,我确信它可能与另一个配置文件冲突或类似的事情有关。

I use this alias in my .bashrc but doesn't seem to work in zsh using .zshrc. Other aliases I use are working fine so I know the .zshrc is sourcing other aliases.

alias rubydev3="cd ~/code/ruby/rails/rails3projects/"

This is the error message:

cd:cd:10: no such file or directory: /home/jryan/code/ruby/rails/rails3tutorial/

I don't know if the cd:cd:10 means anything that should be a clue, but I am just starting to use zsh so I'm at a loss. If the command should work as I have it in this post that I'm sure it probably has something to do with another config file conflicting or something like that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风渺 2024-09-20 08:04:09

尝试定义一个函数而不是别名

function rubydev3 {
    builtin cd ~/code/ruby/rails/rails3projects/
}

Try defining a function instead of an alias:

function rubydev3 {
    builtin cd ~/code/ruby/rails/rails3projects/
}
泪痕残 2024-09-20 08:04:09

错误信息是在尝试使用别名时还是在处理~/.zshrc时发出的?我注意到错误消息的目录与别名不同。尝试这个命令:

type -a rubydev3

它将向您展示如何定义“rubydev3”。

它有可能被重新定义。

此外,cd 可能已使用别名,这会产生干扰。要解决这个问题,请使用以下命令:

alias rubydev3="builtin cd ~/code/ruby/rails/rails3projects/"

Is the error message issued when you try to use the alias or during the processing of ~/.zshrc? I notice that the error message has a different directory than the alias. Try this command:

type -a rubydev3

It will show you how "rubydev3" is defined.

It's possible that it's getting redefined.

Also, it's possible that cd has been aliased and that's interfering. To fix that, use this:

alias rubydev3="builtin cd ~/code/ruby/rails/rails3projects/"
身边 2024-09-20 08:04:09

偶尔 - 你在使用 rvm 吗?这会为 cd 添加功能,请尝试将其关闭。

export rvm_project_rvmrc=0

On the off chance - Are you using rvm? This adds functionality to cd, try turning it off.

export rvm_project_rvmrc=0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文