I tried making a custom command for my terminal. I'm running Mac OS X Version 10.6.6.
Here are the steps I took:
Opened the terminal
Typed "ls -a" and saw a ".bash_profile" file
Typed "vi开发者_开发问答 .bash_profile" and saw that the file was empty
Added the following to the top of the file: "test() { echo hi }"
Saved the vi session by typing ":wq"
Then, I was back to the terminal, and typed "test", however nothing outputted (namely, I didn't see "hi").
So, what am I doing wrong? Thanks!
try to force re-evaluation of file by typing source .bash_profile
I know this is pretty late, but for future people who google this question, here's what you need to do:
When you edit the bash.profile file, you need to use the alias
command. For example: alias [name]="[script]"
Since you are trying to make a test command that sends an output of "hi", you would enter test where [name] is, and echo hi where [script] is. Do not forget to use quotations around the script
精彩评论