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:
- move function definitions separate file,
script
, within directory,brew-script
- make
brew-script
downloadable tarball,brew-script.tar.gz
- have brew formula append text end of
~/.bash_profile
includescript
when terminal session starts
concerns
is modifying
.bash_profile
in brew formula bad practice? (eg. when uninstallingbrew uninstall script
, brew should somehow remove text appended.bash_profile
... parsing.bash_profile
doesn't seem fun.)is there convention established including functions in bash scripts available command line?
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
Post a Comment