Modularizing and distributing bash script via Homebrew -


context

i have functions defined in ~/.bashrc i'd turn homebrew package. currently, these functions act custom commands on command line:

# .bashrc function foo() {     # interesting }  # @ terminal $ foo # => interesting thing 

approach

i've created homebrew formula using brew create. current approach follows:

  1. move function definitions separate file, script, within directory, brew-script
  2. make brew-script downloadable tarball, brew-script.tar.gz
  3. have brew formula append text end of ~/.bash_profile include script when terminal session starts

concerns

  1. is modifying .bash_profile in brew formula bad practice? (eg. when uninstalling brew uninstall script, brew should somehow remove text appended .bash_profile... parsing .bash_profile doesn't seem fun.)

  2. is there convention established including functions in bash scripts available command line?

  3. is common ask user add text .bash_profile or .bashrc?

desired result

should able install cleanly brew , run foo command:

$ brew install script $ foo # => interesting thing 

(assume brew formula installed locally. i'll worry auditing , pushing formula homebrew later)

refer https://github.com/homebrew/homebrew/issues/50232 , https://github.com/homebrew/homebrew/issues/50231.

i have script safely‡ modifies ~/.bash_profile part of homebrew install process. https://github.com/paul-hammant/homebrew-tap/blob/master/switchjdk.rb

‡ allegedly


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -