HOMEBREW – MAINTENANCE

Keeping macOS clean: this is my osx/brew/[…] update CLI command

https://medium.com/@waxzce/keeping-macos-clean-this-is-my-osx-brew-update-cli-command-6c8f12dc1731

Common Problems / Solutions

Update all software

[code] softwareupdate -l [/code]
brew update-reset && brew update

This is a fix-all that will reset the state of all your taps, ensuring the problem isn’t an outdated setup on your side.

HomeBrew Maintenance

To list all the software/lib installed by brew [code]$ brew list[/code]

Edit zsh

[code]nano ~/.zshrc[/code]

HomeBrew Maintenance


To list all the software/lib installed by brew 
[code]$ brew list[/code] to update an app 
[code]$ sudo brew update appname[/code] am I editing? to see issues 
[code]$ brew doctor[/code] to update brew itself 
[code]$ sudo brew update[/code] list outdated software/lib 
[code]$ sudo brew outdated[/code] update all the outdated software/lib 
[code]$ sudo brew upgrade[/code] to cleanup 
[code]brew cleaup[/code]

I’m using OSX most of the time (you know, developer AND sales, plus being CEO) and this is the script I use to update it all the time, can be useful for some…

Remove Cask
brew uninstall –cask < name >
#!/bin/bash
brew update
brew upgrade
brew cleanup -s
brew cask cleanup
#now diagnotic
brew doctor
brew missing
apm upgrade -c false
/opt/bin/updateCCTF.sh && terminal-notifier -message “git pull done :-)” -title “CCTF up to date”
echo “you can hit mas upgrade to upgrade theses apps from the app store:”
mas outdated
echo “install with: mas upgrade”
npm update -g
echo “did you think to launch gem update “
echo “and pip ? pip freeze — local | grep -v ‘^-e’ | cut -d = -f 1 | xargs pip install -U “

Ok, now I’ll explain it, line after each line:

brew update

Brew is the mainstream package manager for macOS, it provides all GNU softwares (many macOS tools like sed are outdated, GPL 2VS3 apple…), and many other CLI tools (I use it for mongoDB, redis, php, git, elixir…). If you don’t use it, it’s weird, you need to have it. The update command will update the local base of available packages and versions, to be able to know what is updatable.

brew upgrade

It actually installs new version of outdated packages

brew cleanup -s

By default, brew keeps all versions of the software, and you can link the one you want. This allow you to keep only linked versions (by default, the last) and save some disk space.

brew cask cleanup

brew cask is a brew extension for GUI and binary packages, some software are installed with it for simplicity of updates. This cleanup is cache cleanup for unfinished download. So, disk space savior.

brew doctor
brew missing

Will show you any problem with your brew installation, it will help a lot to maintain a healthy system all the time.

apm upgrade -c false

I use Atom as main text editor and IDE. The apm command is a CLI package manager for atom plugins. Very helpful. This command upgrades all packages it can, no questions asked.

/opt/bin/updateCCTF.sh && terminal-notifier -message “git pull done :-)” -title “CCTF up to date”

This is Clever Cloud specific, we use a git based wiki as internal documentation, and we all keep an up-to-date version of it. Because it contains all we need (except credentials of course) to relaunch the whole infrastructure. Better to get manual with me all times

terminal-notifier is able to easily print notification on macOS notification system (you can use homebrew to install it)

echo “you can hit mas upgrade to upgrade theses apps from the app store:”
mas outdated
echo “install with: mas upgrade”

The mac app store UI is so SLOW, buggy and unfriendly that I use mas to manage my software installed using the appstore. It’s a friendly CLI you can install via homebrew. I do not automatically install updates to prevent software restart in middle of something. But this way I will launch it if there is some outdated software.

npm update -g

This will update all the npm global installed binaries, like grunt, lessc or Clever Cloud CLI (I know we need a proper homebrew tap and package, it’s on the task list of someone on the team).

echo “did you think to launch gem update

Reminder to launch a global installed gem update (rake, bundler…)…

echo “and pip ? pip freeze — local | grep -v ‘^-e’ | cut -d = -f 1 | xargs pip install -U “

Yeah, pip needs a proper pip upgrade command. I agree. Basically it’s used to upgrade VirtualEnv…

<hr> https://medium.com/better-programming/12-terminal-tips-and-tricks-using-macos-and-homebrew-4e89c2ccb2fb

12 Terminal Tips and Tricks Using macOS and HomeBrew

Terminal is a simple command-line system that provides an interface for you to control the underlying system of your macOS with code. Within the terminal, you can do lots of cool things such as download applications, play Tetris, , and much more. If you’re new to the terminal, here’s a user guide from Apple to get you started.

Installing Homebrew

Now that you know a bit about what Homebrew is, let’s get to the installation.

A quick way to open terminal is with cmd + space, then type terminal, hit enter, and it’ll pop up.

To install Homebrew, you have to first install Xcode tools or you can choose to install the full-blown version of Xcode.

Install Xcode tools

$ xcode-select — install

Install homebrew

$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

Some homebrew commands

$ brew --version # display version
$ brew help  # print help info
$ brew doctor # checking for problems

Now that you have Homebrew in your macOS, it’s time to get into the tips and tricks.

1. Cask

Cask brings simplicity and speed to installing and managing GUI applications on macOS. In simple terms, it’s a way to install applications on your Mac without the hassle of googling it and installing it online.

$ brew install cask
  • List apps: brew search —- casks
  • Search apps: brew search (app_name)
  • Install: brew cask install (app_name)
  • Update: brew cask upgrade
  • Help: brew cask help
Homebrew/homebrew-caskHomebrew Cask extends Homebrew and brings its elegance, simplicity, and speed to the installation and management of GUI…github.com

2. Youtube-dl

Youtube-dl is a command-line program used to download YouTube videos or videos from any platform in high resolution. There are also tons of other functionalities you can experiment with and you can check them out at their GitHub repository below.

$ brew install youtube-dl
  • Install ffmpeg: brew install youtube-dl ffmpeg
  • Download highest-res: youtube-dl -f bestvideo+bestaudio 'link'
  • Help:youtube-dl —- help
ytdl-org/youtube-dlyoutube-dl – download videos from youtube.com or other video platforms To install it right away for all UNIX users…github.com

3. Speedtest

Speedtest-cli is a command-line interface for testing internet bandwidth. It allows you to test against specific servers and even provides you with a URL so you can brag about your internet speed to your friends.

$ brew install speedtest-cli
  • Run: [code]speedtest-cli[/code]
sivel/speedtest-cliCommand-line interface for testing internet bandwidth using speedtest.net speedtest-cli works with Python 2.4-3.7 pip…github.com

4. Imagemagick

Imagemagick is a multifunctional tool that can be used to convert one image format to another (e.g. JPEG to PNG). It can also be used to add borders, effects, as well as resizing. Browse for more uses with convert help.

$ brew install imagemagick
  • Add border (sample): convert testing.png -border 1x1 -bordercolor black result.png
  • Add effect (sample): convert testing.png -charcoal 2 example.png
  • Resize (sample): convert testing.png -resize 1920 (or x1080) example.png
  • Help: convert help
ImageMagickFeatures and Capabilities * News * Community Use ImageMagick to create, edit, compose, or convert bitmap images. It can…imagemagick.org

5. mas

mas is a Mac App Store command-line interface that lets you install Mac apps from the App Store directly from the command line.

You can search for apps, install all existing updates, print the version number of an app in the store, and more. There’s even a fun option called lucky that will install the very first search result. Try it if you dare.

$ brew install mas
  • List all apps: mas list
  • Search for apps: mas search Xcode
  • Install apps: mas install 497799835 (the version number of the app)
  • Pending update apps: mas outdated
  • Update apps: mas upgrade
mas-cli/masA simple command-line interface for the Mac App Store. Designed for scripting and automation. Homebrew is the preferred…github.com

6. wifi-password

wifi-password does exactly what its name suggests, which is displaying the Wi-Fi password of the network you’re currently connected to. After inputting your Keychain authentication, the password shows up in bright green.

$ brew install wifi-password
  • Run: wifi-password
nvm-sh/nvmnvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any…github.com

7. Midnight-commander

Midnight-commander is a tool that amalgamates the functionality of the finder and command line, creating an interactive file manager in the terminal. Inside Midnight-commander, you can navigate your directory structure using clicks or the keyboard arrow.

$ brew install midnight-commander
  • Run: mc
Midnight CommanderCurrent version is: 4.8.24; what’s new. Coming soon: 4.8.25; what’s new. Our release guidelines. GNU Midnight Commander…www.midnight-commander.org

8. Zsh

Zsh, or Z shell, is a Unix shell with appealing colors used as an interactive login shell and command interpreter for shell scripting. Read more about its uses on GitHub.

$ brew install zsh
  • Setting Zsh as default shell: chsh -s /bin/zsh
ZshThis site provides an index to Zsh information and archives. Zsh is a shell designed for interactive use, although it…www.zsh.org

9. htop

htop is an interactive system monitor, process viewer, and process manager for Unix, and it is said to be a successor to the Unix program top. It shows the updated list of processes running on your Mac and is ordered by the amount of CPU usage.

$ brew install htop
  • Run: sudo htop
htop – an interactive process viewer for UnixThis is htop, an interactive process viewer for Unix systems. It is a text-mode application (for console or X…hisham.hm

10. tree

tree is a tool that lists out the content of directories in a folder in a tree-like format. This useful trick is a life-saver for those who want a quick visual representation of a project’s file structure.

$ brew install tree
  • Run: tree
The Tree Command for Linux HomepageDescription: Tree is a recursive directory listing command that produces a depth indented listing of files, which is…mama.indstate.edu

11. archey

archey displays your system information inside the terminal along with a text-based retro-style Apple icon.

$ brew install archey
  • Run: archey
  • Color: archey -c
  • Black and white: archey -b
Archey-osxEAn archey script for osXaobihann.github.io

12. trash

trash is a simple program that moves files or folders to the trash.

$ brew install trash
  • Run: trash [-vlesyF] &lt;file&gt; [&lt;file&gt; …]
  • Help: trash —- help
trashThis page uses some Javascript; please turn it on in your browser. This is a small command-line program for OS X that…hasseg.org

Action Plan

Now that you’ve read about these tips and tricks and hopefully tested out each and every one of them, there are more to come. Besides the commands listed above, Homebrew has a plethora of other tricks up its sleeve that you can try out. So don’t hesitate to experiment with them. Who knows? You might discover something useful that can make your coding sessions more productive.

An extra tip if you spend a lot of time on the terminal is to download iTerm 2. It is said to be better and more customizable than Terminal.

To browse for more Homebrew commands, check out their great website below! Test out each and every command and have fun experimenting with it.

Or you can check out this Homebrew cheatsheet.Homebrew FormulaeHomebrew’s package indexformulae.brew.sh

I hope you found this article useful and learned about using Homebrew in your day-to-day coding adventures.

Scroll to Top