Registering custom shell function in system (OSX)
Just added it to the bottom of your ~/.bashrc
file then you will be able to use cmit
like a regular command, you will need to refresh your current shell to pick up the changes so run source ~/.bashrc
. If you have the function saved in a file cmit
just do cat cmit >> ~/.bashrc
to append the function to the end of your ~/.bashrc
.
You could try out a test function first:
# add to ~/.bashrc firstfunction test() { echo "Some test foo!"}$ source ~/.bashrc$ testSome test foo!
You can put it in your .bashrc
, it will work as long as you're logged as the owner of this .bashrc
file.
If you want it to be available for any user, put the content of your function in a script file, make it executable using chmod
then move it in /usr/bin
(I'm assuming you have admin rights on that system)
Note: typically you'd give it rwx rx rx
rights, which corresponds to a chmod 755 my_script
EDIT:
can you create your own lets say .my_bashrc and somehow tell system to look in that file as well?
Yes you could, just tell your .bashrc
to source your file:
source ~/my_files/.my_bashrc
or
. ~/my_files/.my_bashrc