How to Get Mac Battery Level from Command Line

I’m a big fan of having as much information as I can get within the command line. I couldn’t go without knowing which git branch I’m on, for example. Another important piece of information I like having is my current battery percentage. To get the current battery level from command line, you can run: pmset -g batt | grep -Eo "\d+%" Since I get lost in command line for hours at a time, having the percentage present saves me the labor of shifting my eyes outside of shell. What information do you like having in your command line? The post How to Get Mac Battery Level from Command Line appeared first on David Walsh Blog. David Walsh Blog… more →
Posted in: JavaScript

How to Blur Faces in a Video from Command Line

Privacy is always incredibly important, especially with visual media where you may not have the permission of individuals in the video. If you’re filming something in public, it’s likely you’ll catch someone’s face who simply doesn’t want or need to be identified. This recently got me to thinking: what’s the easiest way to blur faces in a video via command line? The best open source utility I found for blurring faces in a video was deface. Let’s have a look at how you can use deface to blur faces in videos! Start by downloading Python-based via pip: python3 -m pip install deface With deface installed, simply provide the video name and get the output... more →
Posted in: JavaScript

Restart Mac From Command Line

Restarting and shutting down a computer remotely is a frequent task for remote system administrators. As someone that writes many shell scripts, I also find myself automating system restarts. Let’s look at a few ways to restart Mac systems from command line! Restart a Local Mac To restart a local Mac system from command line, you can execute: sudo shutdown -r now Restart a Remote Mac To restart a remote Mac system, you can execute: ssh -l {AdminSystemAddress} sudo shutdown -r now Restart at a Specific Time You can specify a restart at a specific time: # Format: sudo shutdown -r hhmm # Restart at 11:30pm local time sudo shutdown -r 2330 System restarts are good after massive updates... more →
Posted in: JavaScript

How to Get a Base64 Version of a File From Command Line

A while back I wrote an article on how to Convert Image to Data URI with JavaScript. It’s a neat trick developers can use for any number of reasons. Instead of abusing canvas, however, why not simply get the base64 data from command line? You can use base64 and pbcopy to convert a file to base64 and copy it to the clipboard: # base64 gets data, pbcopy copies to clipboard base64 -i logo.jpeg | pbcopy Once you have the file data copied in base64 format, the URL format to use the data is: # data:{mime-type};base64,{data} data:image/jpeg;base64,/9j/4AAQSkZJRgAB...... While base64 data and data URIs do look cryptic, they’re useful to avoid making requests to other files. I use them... more →
Posted in: JavaScript

How to Open a Tor Brave Window from Command Line

I love the Brave web browser for many reasons: ad blocking, Brave rewards, crypto integration, and even a Tor tab feature. I’ll often use the Tor feature but wanted to know how I could automated opening Tor windows from command line. To open a Brave Tor tab, you can use the following command: open -a "Brave Browser" --args --incognito --tor Any time I want to remotely open a Tor tab, I can do so via a shell script. Commands are such an underused but valuable utility for apps! The post How to Open a Tor Brave Window from Command Line appeared first on David Walsh Blog. David Walsh Blog… more →
Posted in: JavaScript

How to Open an App from Anywhere on Mac Command Line

Many engineers like myself live in the command line, and perform actions from command line that most others would click an icon for. I’ve always found opening apps from command line on Macs painful. You need to references the Applications directory, add .app to the name, etc. I just want to open apps by name. To open an app from any directory by its simple name, you can use the -a argument to open: open -a Cyberduck # Works regardless of case as well open -a CyBeRdUcK I love -a for a command like open. Being able to open any app by name is exactly what I want! The post How to Open an App from Anywhere on Mac Command Line appeared first on David Walsh Blog. David Walsh Blog… more →
Posted in: JavaScript

Locate Empty Directories from Command Line

As a software engineer that lives too much of his life on a computer, I like keeping my machine as clean as possible. I don’t keep rogue downloaded files and removes apps when I don’t need them. Part of keeping a clean, performant system is removing empty directories. To identify empty directories, I use the following command: find . -type d --empty To remove empty directories, we can add a --delete flag: find . -type d --empty --delete Keeping a clean machine is easy when you know the tools that can help you. find makes identifying and eliminating easy, so don’t be afraid to use it! The post Locate Empty Directories from Command Line appeared first on David Walsh Blog. David... more →
Posted in: JavaScript

Determine Default App for File Type from Command Line

One quality of life improvement any developer can make for themselves is ensuring different file types open in the app they’re most proficient in. If you know me, you know I prefer accomplishing as much as possible from the command line. The duti utility allows users to determine default file type from command line. The duti utility allows developers to query which app is the default for different file types. You can install duti with brew: brew install duti Once you have duti available, you can check on the default app for file type with the following command: ~ duti -x md Xcode.app /Applications/Xcode.app com.apple.dt.Xcode You can set the default app by using its package: duti... more →
Posted in: JavaScript
1 2