我使用Homebrew Cask在OS x上安装应用程序,如何升级所有已安装的Cask ?


当前回答

Bash脚本升级包

受到帕斯卡答案的启发

#!/usr/bin/env bash

(set -x; brew update;)

(set -x; brew cleanup;)
(set -x; brew cask cleanup;)

red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

casks=( $(brew cask list) )

for cask in ${casks[@]}
do
    version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p")
    installed=$(find "/usr/local/Caskroom/$cask" -type d -maxdepth 1 -maxdepth 1 -name "$version")

    if [[ -z $installed ]]; then
        echo "${red}${cask}${reset} requires ${red}update${reset}."
        (set -x; brew cask uninstall $cask --force;)
        (set -x; brew cask install $cask --force;)
    else
        echo "${red}${cask}${reset} is ${green}up-to-date${reset}."
    fi
done

它的作用

更新酿造/酿造桶,清理 读酒桶清单 检查酿造桶信息的最新版本 如果可用,请安装新版本(并删除所有旧版本!)

来源:https://gist.github.com/atais/9c72e469b1cbec35c7c430ce03de2a6b

对不耐烦的人说一句:

curl -s https://gist.githubusercontent.com/atais/9c72e469b1cbec35c7c430ce03de2a6b/raw/36808a0544628398f26b48f7a3c7b309872ca2c6/cask_upgrade.sh | bash /dev/stdin

保存为/usr/local/bin/桶-upgrade,以便稍后在本地以桶-upgrade的形式运行

其他回答

买过时的酒桶:

酿酒桶过时了

升级桶:

酿造桶重新安装过时的桶

演示脚本:

$ cat ~/bin/brew_cask_upgrade.sh
#!/bin/bash
red=$(tput setaf 1)
# green=$(tput setaf 2)
reset=$(tput sgr0)

(set -x; brew update;)

for cask in $(brew cask outdated | awk '{print $1}')
do
    echo "${red}update ${cask} ...${reset}."
    (set -x; brew cask install --force "$cask";)
done

echo "${red}brew clean up ...${reset}"
(set -x; brew cask cleanup;)
echo "${red}brew clean up done.${reset}"

检查过时的酒桶:

酿酒桶过时了

升级所有过时的酒桶:

酿造桶升级

如果你想升级特定的桶,只需要在升级后添加桶名(例如:4k-video-downloader):

酿造桶升级4k视频下载器

for cask in $(brew list --cask); do brew upgrade --cask $cask; done;

一个简单的FOR循环迭代所有的桶,而不是手动升级一个接一个。

我使用

brew cask install --force `brew cask list`

酿造升级—酒桶$(酿造列表—酒桶)