0

I've written a very simple utility to allow a couple of colleagues to easily access some system logs.

The dependencies for this are installed by running a curl to an install.sh file on GitHub.

There are a couple of functions and aliases that are handy to have in your bash profile. Out of interest how would I programmatically add items to a user's bash profile in a shell script.

Molenpad
  • 833
  • 2
  • 14
  • 34
  • What have you tried so far? How has it failed? The usual gross "just append to the file" thing is... well... the usual thing (maybe with better-behaved programs creating start/end markers so they can undo their own changes later by deleting everything between them). – Charles Duffy Nov 30 '18 at 18:55
  • BTW, I strongly suggest you consider the approach given at https://stackoverflow.com/questions/27026015/update-bashrc-from-provisioning-shell-script-with-vagrant -- adding a line that `source`s a separate file that contains the function, instead of trying to add the function text. That's easier to maintain, easier to delete, and easier to distinguish from content the user amended by hand. – Charles Duffy Nov 30 '18 at 18:59
  • BTW, note that `declare -f somefunc` will emit the definition of `somefunc` on its stdout, so that's something you can redirect. – Charles Duffy Nov 30 '18 at 19:00

0 Answers0