-bash: otool: command not found, Can you teach bash a default location to look for a command?

StackOverflow https://stackoverflow.com/questions/11157277

  •  16-06-2021
  •  | 
  •  

I can find the tool command in my filesystem under:

/Applications/Xcode.app/Contents/Developer/usr/bin/otool

If I specify that entire path, otool will work.

/Applications/Xcode.app/Contents/Developer/usr/bin/otool -tV hello -p _main

However, since I have to be inside the folder of the hello.c file I'm referencing, bash won't find otool automatically if I just type

otool -tV hello -p _main

I've had this same problem with a number of commands. Is there any way to set up bash so it automatically finds otool (and similar commands), without me having to writing out the entire path name each time? Thanks!

Note: If it matters, I'm using a Mac.

Note 2: I've read through a ton of the "Command not found" threads but none seem to answer the question of teaching bash where to look for a command by default. I feel like this question should have been answered somewhere, but haven't come across it yet. Since the only programs I'll be working with any time soon will be iOS/Xcode related, this is worthwhile shortcut.

有帮助吗?

解决方案

PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin

Put this in your ~/.bashrc to have it persist.

其他提示

You can also Try using alias to do this. e.g.

$ alias otool='/Applications/Xcode.app/Contents/Developer/usr/bin/otool'

You can also add this in your bashrc/profile file.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top