Wednesday, July 3, 2019

HomeBrew Tips and Tricks on Mac



https://brew.sh/
Homebrew installs packages to their own directory and then symlinks their files into /usr/local.

https://github.com/sindresorhus/quick-look-plugins

The tap command allows Homebrew to tap into another repository of formulae. Once you've done this you've expanded your options of installable software.
These additional Git repos (inside usr/local/Library/Taps) describe sets of package formulae that are available for installation.
E.g.
brew tap                     # list tapped repositories
brew tap <tapname>           # add tap
brew untap <tapname>         # remove a tap

brew tap adds more repositories to the list of formulae that brew tracks, updates, and installs from. By default, tap assumes that the repositories come from GitHub, but the command isn't limited to any one location.
brew tap <user/repo> makes a shallow clone of the repository at https://github.com/user/repo. After that, brew will be able to work on those formulae as if they were in Homebrew's canonical repository

https://github.com/Homebrew/homebrew-cask
https://github.com/nicolashery/mac-dev-setup
Homebrew Services
A nice extension to Homebrew is Homebrew Services. It will automatically launch things like databases when your computer starts, so you don't have to do it manually every time.


$ brew cask install eclipse-jee
brew search eclipse               # Searches all known Casks for a partial or exact match.
brew search eclipse-jee           # Searches all known Casks for a partial or exact match.
brew cask info eclipse-jee        # Displays information about the given Cask

brew cask install eclipse-jee     # Install the given cask.

brew cleanup                      # For all installed or specific formulae, remove any older versions from the cellar.


brew cask install caffeine -- dead
https://github.com/AdoptOpenJDK/homebrew-openjdk
brew cask install adoptopenjdk

Other Versions:

brew tap AdoptOpenJDK/openjdk
brew cask install <version>
https://dev.to/therealdanvega/new-macbook-setup-for-developers-2nma
The default version of bash is v3.2 and I want to go ahead and upgrade this to 4.x. There is a really good guide here that you can follow to upgrade bash.
  • bash -v (bash-3.2)
  • brew install bash
  • if you close the terminal or open a new tab it will show 4.4 but this still isn't the default version.
  • which bash will show you what bash you're using.
https://medium.com/@deianisac/how-to-quickly-set-up-a-mac-b9f89aed0dc
brew cask install 1password
brew cask install beamer


But what about apps from the Mac App Store?
Yes, I know. Some apps you want to install might not be available with Homebrew and Cask. If you’ve grown attached to Terminal, you should install mas-cli.

brew install mas
mas search app name

https://www.stuartellis.name/articles/mac-setup/
brew install jenv
Next, add this to your PATH:
$HOME/.jenv/bin
Add this to your ~/.bashrc file:
eval "$(jenv init -)"
Open a new terminal window, and run this command:
jenv enable-plugin export
This enables jEnv to manage the JAVA_HOME environment variable.
To avoid inconsistent behaviour, close all the terminal windows that you currently have open. The jEnv utility will work correctly in new terminal windows.
Lastly, run this command to register your current JDK with jEnv:
jenv add $(/usr/libexec/java_home)
To see a list of the available commands, type jenv in a terminal window:
jenv
brew install kubernetes-cli
brew cask install minikube
By default, Minikube uses a virtual machine manager. If you do not need VirtualBox, install hyperkit, which provides a minimal virtual machine manager.

brew install hyperkit
To install Helm with Homebrew, run this command in a terminal window:

brew install kubernetes-helm
To install Skaffold with Homebrew, run this command in a terminal window:

brew install skaffold

https://sourabhbajaj.com/mac-setup/BashCompletion/
brew search completion
And you can install them using brew install commands, for example:

$ brew install docker-completion
You can also manually add a bash completion file into /usr/local/etc/bash_completion.d

brew cask install iterm2
brew cask install google-chrome-canary
  • brew install git
  • brew cask install google-chrome
  • brew cask install google-chrome-canary
  • brew cask install firefox
  • brew cask install firefox-developer-edition
  • brew cask install visual-studio-code
  • brew cask install visual-studio-code-insiders
  • brew cask install intellij-idea
  • brew cask install eclipse-java
  • brew cask install postman
  • brew cask install docker
  • brew cask install spectacle
  • brew install tree
  • https://github.com/sindresorhus/quick-look-plugins

http://lightheadsw.com/caffeine/
Caffeine is a tiny program that puts an icon in the right side of your menu bar. Click it to prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers
https://github.com/Homebrew/homebrew-cask-versions
Alternate versions of Casks

brew tap homebrew/cask-versions
You can now install alternate versions of Casks.

$ brew cask install iterm2-beta
brew cask install atom-beta

https://github.com/Homebrew/homebrew-cask/issues/40371
Brew Cask Reports "Error: Cask 'avast' is unavailable: No Cask with this name exists." on Every Command
If /usr/local/Caskroom/avast exists, remove it.

for cask in $(brew search --casks); do
    brew cask info $cask;
done

brew search --casks
The man page for brew has the following information:
search --casks
Display all locally available casks (including tapped ones). No online search is performed.

https://apple.stackexchange.com/questions/256987/creating-an-icon-for-a-homebrew-installed-software-evince-mac-os-x

If linking was not successful, try to link it manually. You can link "evince" executable file to /Applications:
ln -s $(which evince) /Applications/Evince
http://www.software-architects.com/devblog/2017/05/23/Markdown-pandoc-conceptual-documents
brew install evince

Finally, I use Evince as my PDF viewer because…
  • …it does not lock the PDF file, so I can overwrite it although it is open.
  • …it auto-reloads the PDF file when it changes.
https://apple.stackexchange.com/questions/101090/list-of-all-packages-installed-using-homebrew
Running brew list will show a list of all your installed Homebrew packages.
In addition, brew cask list will provide the items installed using the Caskroom.

http://macappstore.org/the-unarchiver/
  1. brew cask install the-unarchiver
brew doctor
brew update
sudo chown -R $USER:admin /usr/local/Library/

http://stackoverflow.com/questions/26647412/homebrew-could-not-symlink-usr-local-bin-is-not-writable
sudo chown -R `whoami`:admin /usr/local/bin
For some packages, you may also need to do this to /usr/local/share.
sudo chown -R `whoami`:admin /usr/local/share
brew update && brew upgrade && brew cleanup ; say mission complete

Show what will be removed by cleanup command, but do not actually remove anything:

brew cleanup -ns

Clean the "Cellar" removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache. Additionally, scrub the cache, removing downloads for even the latest versions of formula, which are downloaded, but not installed:

brew cleanup -s

GNU stow 是管理符号链接(symlink)的一个小公举。主要用于 symlink 你的 dotfiles 如 emacs,git,fish/zsh 的配置文件。安装只需要
brew install stow
安装了 stow 之后,我们可以开始 symlink 一些 dotfiles 了。完整使用 stow 和 dotfiles 的流程可以参考https://github.com/jcouyang/dotfiles
当你的 dotfiles 都妥妥的 symlink 到 ~/dotfiles 后,push 到 github 上就再也不怕换电脑了。
brew cask install sublime-text
brew cask install macdown
MacDown 是 Markdown 编辑器。由于 Mou 一直不支持代码高亮,我就转向了 MacDown。完美支持 GFM
我特别喜欢 Markdown,我用 Makdown 来写文章(包括本文),写幻灯片(reveal.js)。Markdown 可以让我专注于内容本身,而无需花精力在排版和样式上。
在打开终端后,你是怎么进入项目的工作目录?是cd xxx⌃R还是用别名?
z 工具可以帮你快速进入目录。比如在我的 Mac 上运行z cask就会进入/usr/local/Library/Taps/caskroom/homebrew-cask/Casks目录。
这货的安装非常方便,甚至都不需要下载任何东西,因为它已经整合在了 Oh My Zsh 中。编辑~/.zshrc文件,在plugins=(git)这行中加上z变成plugins=(git z),然后运行source ~/.zshrc重新加载配置文件,就可以使用 z 了。
替代品有 autojump。autojump 需要使用 brew 安装。
brew cask install cheatsheet
CheatSheet 能够显示当前程序的快捷键列表,默认的快捷键是长按⌘。
而 brew-cask 提供了自动安装和卸载功能,能够自动从官网上下载并安装 JDK 8。
brew cask install java
如果你需要安装 JDK 7 或者 JDK 6,可以使用homebrew-cask-versions
brew tap caskroom/versions
brew cask install java6
JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home java -version
其中JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home可以用JAVA_HOME=`/usr/libexec/java_home -v 1.6`这种更加通用的方式代替。
brew update && brew upgrade brew-cask
https://gist.github.com/kevinelliott/3135044
http://blog.csdn.net/chszs/article/details/50558059
第一步:更新Homebrew自身
# brew update
第二步:找出已过期的软件包(即已经有更新版本的软件包)
# brew outdated
第三步:升级所有过期软件包
# brew upgrade
或者是升级指定的过期软件包
# brew upgrade $FORMULA

5)卸载掉旧的软件包
默认情况下,Homebrew不会自动卸载掉旧的软件包,故随着时间的积累,电脑中会积累起很多老版本的软件包,甚至是同一个软件包的多个老版本,那么要移除这些软件包的老版本,只需这么做:

第一种:清除指定软件包的所有老版本
# brew cleanup $FORMULA
第二种:清除所有软件包的所有老版本
# brew cleanup
第三种:查看哪些软件包要被清除
# brew cleanup -n
6)对于Homebrew来说,如果没有卸载掉软件包的所有版本,那么Homebrew会继续尝试安装这个软件包的最新版本。要想彻底卸载某个软件包,需要执行命令:
# brew uninstall formula_name --force

Homebrew + cask

https://freemacsoft.net/appcleaner/
AppCleaner is a small application which allows you to thoroughly uninstall unwanted apps.
Installing an application distributes many files throughout your System using space of your Hard Drive unnecessarily.
AppCleaner finds all these small files and safely deletes them.


Simply drop an application onto the AppCleaner window. It will find for the related files and you can delete them by clicking the delete button.

https://dev.to/therealdanvega/new-macbook-setup-for-developers-2nma
To remove applications I like installing AppCleaner. This will make sure that the application and any related files will be removed.

https://www.cheatsheetapp.com/CheatSheet/
Just hold the ⌘-Key a bit longer to get a list of all active short cuts of the current application. It's as simple as that.


Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts