Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash Programming - Creating a Custom Terminal Command - Mac

Tags:

bash

vi

macos

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!

like image 710
CodeGuy Avatar asked Mar 28 '11 15:03

CodeGuy


People also ask

How do I create a Terminal file on Mac?

In the Terminal app on your Mac, invoke a command-line editor by typing the name of the editor, followed by a space and then the name of the file you want to open. If you want to create a new file, type the editor name, followed by a space and the pathname of the file.


1 Answers

try to force re-evaluation of file by typing source .bash_profile

like image 176
Laurent G Avatar answered Sep 27 '22 21:09

Laurent G