【问题标题】:Adding directory to the path in .zshrc [closed]将目录添加到.zshrc中的路径[关闭]
【发布时间】:2012-12-24 16:07:13
【问题描述】:

我在这个问题上已经讨论了几天了。我使用zsh 并且需要设置目录路径以便识别我使用的命令。到目前为止,请按照以下步骤操作:

cd ~

ls -al

ls -al 向我展示了这些文件:

.oh-my-zsh
.profile
.putty
.rediscli_history
.ringo-history
.ssh
.subversion
.viminfo
.zcompdump
.zsh-update
.zsh_history
.zshrc

我假设我需要将路径添加到.zshrc,所以:

open -e .zshrc

在文件末尾,我添加了我将用来设置我的项目的命令的路径(使用 ringojs):

export PATH=Users/repos/ringojs/bin/:$PATH

关闭文件,重新启动终端应用程序,重新启动计算机,但是找不到位于上述路径(/Users/repos/ringojs/bin)下的命令(ringo-admin):

ringo-admin create --google-appengine MyAppName
zsh: command not found: ringo-admin

请帮帮我,如果有帮助的话,这是我的.zshrc 文件内容:

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"

# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export PATH=Users/repos/ringojs/bin/ringo-admin:$PATH

请逐步指导我,因为我是zsh 的新手。谢谢。

更新:

echo $PATH 显示最近添加的目录:

/Users/repos/ringojs/bin/ringo-admin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin

我不明白为什么总是找不到命令。

【问题讨论】:

    标签: osx-lion zsh zshrc


    【解决方案1】:

    您缺少前导斜杠。试试:

    export PATH=/Users/repos/ringojs/bin/:$PATH
    

    【讨论】:

    • 感谢您的回复。不过,我已经尝试过了。总是同样的问题。
    • 在你的例子中,你有export PATH=Users/repos/ringojs/bin/ringo-admin:$PATH。您是否按照应有的方式删除了尾随的ringo-admin
    • 这里是echo $PATH结果:/Users/repos/ringojs/bin/ringo-admin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin所以添加的目录路径添加到.zshrc配置文件中。但是为什么还是找不到命令呢?
    • 我解决了这个问题,我只需要那个路径:export PATH=/Users/repos/ringojs/bin:$PATH 所以没有最后的斜杠和命令名,只有目录名bin。是的,我应该从路径中删除ringo-admin,只指定命令所在的目录。现在效果很好。谢谢:)
    • 别忘了重启zsh source ~/.zshrc
    猜你喜欢
    • 1970-01-01
    • 2015-01-27
    • 2011-11-11
    • 2016-06-03
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 2022-01-18
    相关资源
    最近更新 更多