开发者

Bash Programming - Creating a Custom Terminal Command - Mac

开发者 https://www.devze.com 2023-02-20 02:58 出处:网络
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:

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:

  1. Opened the terminal

  2. Typed "ls -a" and saw a ".bash_profile" file

  3. Typed "vi开发者_开发问答 .bash_profile" and saw that the file was empty

  4. Added the following to the top of the file: "test() { echo hi }"

  5. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消