If you know for sure, that you are using this function only from the command line, you can of course place it into your initialization files.
If you plan to use it from other shell scripts too, you have to ways to go:
You can organize your programming environment around libraries consisting of one or more function definitions, which you source from those shell scripts which need them, or
You drop the idea of using functions and make executable scripts out of it.
As long as your functions are not supposed to manipulate shell variables, it's up to you which way to go. Using a separate, executable script instead of a function, has of course the advantage that it can be executed from any other program, not only from bash.
~/.profileis to configure your login session, not your shell. Only the login shell reads that file.bashcustomisation goes in~/.bashrc– Stéphane Chazelas Nov 14 '17 at 21:53/home/user/binis designed for user scripts. You may add this. – Nov 14 '17 at 22:22$PATHis built read this. – Nov 14 '17 at 22:26~/binhas been designated for user scripts, except by recent versions of Ubuntu. – igal Nov 15 '17 at 06:14~/.bashrc( or any other file for that matter ) ? Manual way only? – Sergiy Kolodyazhnyy Nov 15 '17 at 08:33~/.bashrc. I wouldn't say that~/.bashrcis the "manual way" of doing anything, since it's run automatically (under the appropriate conditions). – igal Nov 15 '17 at 13:10~/.bashrcyou could use thetypeordeclare -fcommands. They will output the function definition. So you could do something likedeclare -f myfunction >> ~/.bashrcto append the function definition formyfunctionto the~/.bashrcfile. – igal Nov 15 '17 at 13:16