I'm new to bash functions but was just starting to write some bits and pieces to speed up my work flow. I like to test this as I go along so I've found myself editing and sourcing my ~/.profile a lot and find ~/.
a bit awkward to type...
So the first thing I thought I'd do was the following:
sourceProfile(){
source ~/.profile
}
editProfile(){
vim ~/.profile && sourceProfile
}
when running editProfile I'm getting an issue on the sourceProfile call. Initially I was getting the error:
-bash: ~./profile: No such file or directory
Note the lack of typo in my function!
However it works if I use an alias instead.
alias sourceProfile='source ~/.profile'
However after adding that alias and then commenting it out and uncommenting the function I start getting a syntax error instead:
-bash: /home/jonathanramsden/.profile: line 45: syntax error near unexpected token `('
-bash: /home/jonathanramsden/.profile: line 45: `sourceProfile(){'
the proceeding line is:
alias sservice='sudo service'
I'm pretty sure all I did was comment/uncomment! And based on my googling it seems like that's the syntax for defining functions.