-1

I'm currently using the Homebrew package manager, and I have to say that it is really really great!

My question is: there is a way to automate brew update and brew upgrade in order to execute this commands when a shell is opened? I'm not very expert about bash programming, so I'm not sure if this thing is possible or not, I'm currently using iTerm.

Anton Dozortsev
  • 2,984
  • 18
  • 21
g_rmz
  • 305
  • 1
  • 3
  • 9
  • Other answers state this, but there is no need to update/upgrade at this rate for command line tools like this. Being bleeding edge will only cut you and you should only update/upgrade when needs require it. Remember: While some developers love being bleeding edge, the reality is Linux/Unix tools are built with longevity and stability in mind. – Giacomo1968 Sep 21 '15 at 08:15
  • See [This SO question and excellent answer](http://stackoverflow.com/questions/20528282/how-to-update-homebrew-with-cron-on-mac-os) – agtoever Sep 25 '15 at 09:26

2 Answers2

4

I agree with @fd0 that this probably shouldn't be automated to the point of launching it for every shell. This can get ugly if you have multiple shell windows. I opted for a semi-automated solution by creating an alias in my ~/.profile that performs several brew functions. Check out this post for details.

SaxDaddy
  • 3,809
  • 20
  • 19
1

Automating such a process in a shell startup file is a bad idea. Every new instance of a shell would execute both commands. You could place a function in your .bashrc and and call the function which would cut down on the number of characters that you need to type but that's not a real game changer.

fd0
  • 1,490
  • 10
  • 13
  • Is possibile to write the function in order to execute it only the first time the shell is opened? – g_rmz Sep 19 '15 at 16:53
  • 1
    If you want to automate the process then use `launchd` or `cron`. Don't use a shell startup file. – fd0 Sep 19 '15 at 17:27