我可以在我的文件系统中找到工具命令:
/Applications/Xcode.app/Contents/Developer/usr/bin/otool
如果我指定整个路径,otool将起作用。
/Applications/Xcode.app/Contents/Developer/usr/bin/otool -tV hello -p _main
但是,因为我必须在我正在引用的hello.c文件的文件夹中,所以如果我输入
,bash将不会自动找到otoolotool -tV hello -p _main
我在许多命令中遇到了同样的问题。 有没有办法设置bash所以它会自动找到otool(和类似命令),而不必每次都写出整个路径名?谢谢!
注意:如果重要,我正在使用Mac。
注意2:我已经阅读了大量的“未找到命令”线程,但似乎没有人回答教bash默认查找命令的问题。我觉得这个问题应该在某个地方得到解答,但还没有遇到过。由于我将很快与之合作的唯一程序将与iOS / Xcode相关,这是值得的捷径。
答案 0 :(得分:3)
PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
将它放在~/.bashrc
中以使其保持不变。
答案 1 :(得分:1)
您也可以尝试使用别名来执行此操作。 e.g。
$ alias otool ='/ Applications / Xcode.app / Contents / Developer / usr / bin / otool'
您也可以在bashrc / profile文件中添加它。