today I wanted to write a function which will deploy my blog page (developed in nanoc) to github pages automatically - here's the script:
function cmit()
{
nanoc compile;
git add .;
git commit -am $1;
git push origin source;
cd output; git add .;
git commit -am $1;
git push origin master;
cd ..;
echo 'new version deployed! now starting nanoc locally..';
nanoc aco;
}
Example usage: cmit "my example commit!"
I don't really know how register my function in system (OSX) - in .bashrc
, .bash_profile
or maybe somewhere else? Please help!
To add computer-level scripts to the script menu, save them into the /Library/Scripts/ folder on your Mac. For quick access to this folder, select Open Scripts Folder > Open Computer Scripts Folder from the script menu.
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 first
function test() {
echo "Some test foo!"
}
$ source ~/.bashrc
$ test
Some 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With