我使用Homebrew Cask在OS x上安装应用程序,如何升级所有已安装的Cask ?
当前回答
基于@Atais的回答,我将他的逻辑增强为更好的东西。我想要一种方法,在真正强制升级之前,首先检查要升级的包。
$ brew- bucket .sh只是列出了一个类似Homebrew的酿造更新的输出。 上面的列表显示了所有安装的包,绿色的特遣队表示任何未决的更新。 $ brew- bucket .sh upgrade将强制升级这些包。
代码:
# Usage:
#
# $ brew update
# You should execute this first to update everything locally.
#
# $ brew-cask.sh [update]
# This will list all of your cask packages and rather there is an upgrade
# pending with a ✔ checkmark, just like Homebrew does with "brew update".
# The update command is optional, as it doesn't actually do any tracking, there's
# not really anything to "update" with cask. But it keeps with the pattern of
# of Homebrew's "brew update" pattern for those with memory muscle fingers (like me).
#
# $ brew-cask.sh upgrade
# This performs a "brew cask install <cask> --force" of all cask packages that have
# an update pending.
#
# This code was inspired by http://stackoverflow.com/a/36000907/56693
# get the list of installed casks
casks=( $(brew cask list) )
if [[ "$1" == "upgrade" ]]; then
for cask in ${casks[@]}; do
current="$(brew cask info $cask | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
installed=( $(ls /opt/homebrew-cask/Caskroom/$cask))
if (! [[ " ${installed[@]} " == *" $current "* ]]); then
echo "Upgrading $cask to v$current."
(set -x; brew cask install $cask --force;)
else
echo "$cask v$current is up-to-date, skipping."
fi
done
else
echo "Inspecting ${#casks[@]} casks. Use 'brew-cask.sh upgrade' to perform any updates."
for (( i = i ; i < ${#casks[@]} ; i++ )); do
current="$(brew cask info ${casks[$i]} | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
installed=( $(ls /opt/homebrew-cask/Caskroom/${casks[$i]}))
if (! [[ " ${installed[@]} " == *" $current "* ]]); then
casks[$i]="${casks[$i]}$(tput sgr0)$(tput setaf 2) ✔$(tput sgr0)"
fi
done
echo " ${casks[@]/%/$'\n'}" | column
fi
只要安装它(也就是“我现在就需要它!”)
它被检入我的。dotfiles回购;所以,你可以快速地将它安装到你的~/binwith:
$ curl -L https://raw.githubusercontent.com/eduncan911/dotfiles/master/bin/brew-cask.sh --create-dirs -o ~/bin/brew-cask.sh
$ chmod 755 ~/bin/brew-cask.sh
然后像这样使用它:
$ brew-cask.sh
$ brew-cask.sh upgrade
如果你的路径中没有~/bin,在上面的语句前加上~/bin/。
其他回答
可以列出已安装的桶:
brew cask list
并强制重新安装桶与:
brew cask install --force CASK_NAME
因此,将第一个命令的输出输出到第二个命令中,我们更新了所有的桶:
brew cask list | xargs brew cask install --force
买过时的酒桶:
酿酒桶过时了
升级桶:
酿造桶重新安装过时的桶
演示脚本:
$ 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}"
我和鱼壳打交道。 所以我使用:brew upgrade (brew list—cask)。 这对我很管用。
for cask in $(brew list --cask); do brew upgrade --cask $cask; done;
一个简单的FOR循环迭代所有的桶,而不是手动升级一个接一个。
带有'auto_updates'或'version:latest'的桶将不会升级;通过——贪婪地升级它们:
brew upgrade --cask --greedy
推荐文章
- 如何在Mac上的命令行安装JQ ?
- 在Mac OS X上安装/升级gradle
- 如何在终端中提高光标速度?
- Objective-C中的自动引用计数不能防止或减少什么样的泄漏?
- 如何在Mac OS安装时停止MySQL ?
- PIP成功安装包,但在命令行中找不到可执行文件
- 无法在Mac OS X 10.9上安装Lxml
- 在OS X上使用sed进行就地编辑
- MacVim和普通Vim有什么区别?
- 查看保存的NSUserDefaults的简单方法?
- homebrew、macports或其他软件包安装工具的区别/用途是什么?
- (Mac) -bash: __git_ps1:命令未找到
- 如何创建Bash别名?
- Java/JDK的苹果硅芯片
- Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)