How to Set Date Time from Mac Command Line / / No Comments Working on a web extension that ships to an app store and isn’t immediately modifiable, like a website, can be difficult. Since you cannot immediately deploy updates, you sometimes need to bake in hardcoded date-based logic. Testing future dates can be difficult if you don’t know how to quickly change the date on your local machine. To change the current date on your Mac, execute the following from command line: # Date Format: MMDDYYYY sudo date -I 06142024 This command does not modify time, only the current date. Using the same command to reset to current date is easy as well! The post How to Set Date Time from Mac Command Line appeared first on David Walsh Blog. David Walsh... more → Posted in: JavaScript Tagged with: Command, date, from, line, time
How to Get Mac Battery Level from Command Line / / No Comments 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 Tagged with: battery, Command, from, Level, line
How to Blur Faces in a Video from Command Line / / No Comments 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 Tagged with: Blur, Command, faces, from, line, video
Restart Mac From Command Line / / No Comments 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 Tagged with: Command, from, line, Restart
How to Get a Base64 Version of a File From Command Line / / No Comments 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 Tagged with: Base64, Command, file, from, line, version
How to Open a Tor Brave Window from Command Line / / No Comments 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 Tagged with: Brave, Command, from, line, open, Window
How to Open an App from Anywhere on Mac Command Line / / No Comments 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 Tagged with: Anywhere, Command, from, line, open
Locate Empty Directories from Command Line / / No Comments 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 Tagged with: Command, Directories, Empty, from, line, locate