2017-07-23 28 views
1

我想在安裝後執行一些修改的homebrew(桶)公式中運行本地shell腳本。木桶公式是穩定的,因爲它總是安裝「最新」,因此手動插入不應該在不久的將來被更新覆蓋(我希望)。在自制公式中運行shell腳本

我試圖

exec '~/bin/script.sh' 
system '~/bin/script.sh' 

這兩個不工作。我該如何做?

編輯:嘗試使用@Ortomalas答案,我得到:

Error: Command failed to execute! 

==> Failed command: 
/usr/bin/sudo -E -- sed -i .bak 20i<style>*{text-rendering: optimizeLegibility;}</style> /Applications/RStudio.app/Contents/Resources/www/index.htm 

==> Standard Output of failed command: 


==> Standard Error of failed command: 
sed: 1: "20i<style>*{text-render ...": command i expects \ followed by text 

postflight

postflight do 
    # Unhide the application 
     system_command 'sed', 
        args: ['-i .bak', "20i\<style>*{text-rendering: optimizeLegibility;}</style>\ ", "#{appdir}/RStudio.app/Contents/Resources/www/index.htm"], 
        sudo: true 
end 

我嘗試了各種方法使用system_command但我未成功與任何。上面的例子提供了一個嘗試。

作爲一種變通方法,我做如下:

brew cask install rstudio-daily && bash ~/bin/Fira-code-ligatures.sh 

可是,我真的寧願intregate我的自定義bash腳本到homebrew公式。

+0

你在'〜/ bin/Fira-code-ligatures.sh'上設置了'chmod + x'嗎?你能告訴我們你的postflight塊嗎? –

+0

查看新更新@OrtomalaLokni –

+0

您能否向我們展示'〜/ bin/Fira-code-ligatures.sh'的內容? –

回答

1

您可以包含一個postflight塊。 parralels-desktop木桶是這樣的:

postflight do 
    # Unhide the application 
    system_command '/usr/bin/chflags', 
        args: ['nohidden', "#{appdir}/Parallels Desktop.app"], 
        sudo: true 
    end 

用你自己的值替換這些值。