cli(21/0)
Send files safely to anyone in the world
What if you need to send sensitive information to a person on the other side of the planet? What if they need to send something to you? Here we’ll explore a simple options available to you. Email Many email providers, such as Outlook and Gmail, encrypt sent email traffic by default. If both the sender and receiver email providers support TLS (Transport-Level Security), such as when one Outlook account emails another, then your message cannot be read if intercepted in-transit.…
Use the default tools
I know this will be controversial, but it’s best to learn and use the most basic tool for a given task. I’m thinking specifically of technology. Let me give you some examples: In web development, learn to write websites in HTML/CSS with only a text editor. In sysadmin work, use systemd and crontab from a terminal CLI. Here are a few reasons why: Ubiquity TODO: add more Knowledge is Power TODO: add more…
Stage hunks in git
Like Pawel I’ve been tethered to source control GUIs because I didn’t know how to stage code hunks in the same file into different commits. But no longer! The answer is so simple I can’t believe I didn’t search for it earlier. git add -p name_of_file.txt How easy is that?
Run CLI commands in python
Python is a great language. Sometimes, however, you need to interact directly with the operating system. Like in this case, when I needed to run a few Git commands, or if I’d written a Rustlang CLI. Turns out, a pretty simple problem to solve. def try_run_cmd(cmds: List[str], cwd: str) -> Tuple[str, str]: output = None try: output = subprocess.run(cmds, capture_output=True, check=True, cwd=cwd) except CalledProcessError as e: return None, f"{e} : {e.…
Create developer setups with tmux and justfile
After learning how to save and restore a tmux session, I began to wonder if I couldn’t leverage tmux for a more project-specific use. To my joyful surprise, that’s even simpler than using the plugin. All the pieces of a tmux session can be generated from the command line, complete with options to configure them just so. To organize the command list I use my favorite command runner, Justfile. Here’s an example taken from my chaos-theme repository:…
Save and restore a tmux session
As the number of running commands has increased from one to four, I’ve needed a better way to manage all the running terminals. I’ve always wanted to give tmux a try, and this was the perfect opportunity. But it takes a little time to run all the commands across different Git repositories so that my entire environment is ready for local development. What I needed was a way to save my session, and that’s exactly what the tmux-resurrect plugin does.…
Configure fish shell for python
In software tools I gravitate towards simplicity, then ubiquity. The fish shell has those priorities in the perfect order. But if you use it for working with Python virtualenvs, you’ll find it’s not ready. This is probably because virtualenv has poor support for anything but bash, but I don’t know for sure. The problem lies in the activation script. While you’re average shell can just run venv/bin/activate and you’re in, fish has two obstacles.…
Benchmark your web service with ab
Time to test your web service with more than a single request? Let’s use ab! Here’s a silly example. ab -n 1000 -c 100 localhost:3000/healthcheck This runs 1,000 requests at a rate of approx. 100 at a time. It runs on a single thread so it’s not technically 100 at the same time, but rather in bursts of 100. You’ll get a nifty breakdown of requests success/failure and the distribution of response times in milliseconds.…
Read logs with journalctl
journalctl is one of the best tools I’ve learned to use often when debugging my set of chaos services running Podman via systemd on my Raspberry Pi. Lots still to learn, but here are a few tidbits. Find out what your options are If you print out the journalctl results with no filters it can be way overwhelming. But figuring out what field to filter can seem impossible. For example, specific services will include their own fields.…
Set remote fish prompt
I enjoy using the fish prompt, and fish_config is brilliant. But if I want to swap my remote terminal to another prompt but don’t want to open a hole in my firewall to run the config web page, it’s not obvious how I can do that. So, for posterity, here’s what you do. All the starter prompts are located at the following path. Execute them as a script and, boom, now your prompt will be set to that default.…
Disable startup programs with launchctl
From time to time on MacOS I end up with a program that decides it’s so important that it deserves to open a GUI every time I log in. Annoying. These programs seem to deliberately enjoy keeping their settings out of the normal setup so that I cannot uncheck “Open at Login” in the right-click menu and disable it. But there’s a CLI for that. To see all the programs (and there’s a lot), you can run the launchctl tool.…
Create animations with imagemagick
I’ve considered the tool imagemagick on multiple occasions (it does practically anything you could imagine with images), but finally downloaded and tested it out. Here’s how I created a useless gif animation. First, generate two gifs. convert -pointsize 20 -page 50x20 label:Open -append open.gif; \ convert -pointsize 20 -page 50x20 label:Close -append close.gif Next, combine them together into an animation. convert -delay 100 -page 50x20 open.gif -page 50x20 close.gif -loop 0 animation.…
Favorite CLI Tools
Inspired by Ibraheem Ahmed’s modern Unix commands, here’s a list of my favorite CLI tools. There’s a lot of cross-over with Ibraheem’s list. Bat While navigating the file system I often want to look at the contents of a file but don’t need to open it in an editor. The traditional tool cat achieves this by printing the contents to the console. bat improves the experience with line numbers, spacing, syntax highlighting and even git symbols.…
Install a friendly terminal shell
If you’re unfamiliar with a terminal command line or tired of using bash, you’ll benefit from installing another shell. There are a number of options, but the fish shell is the simplest to install and use. Simple doesn’t mean basic - it’s elegant and wonderful. Install Fish First, install fish. On MacOs the command is: brew install fish ℹ️ For an exhaustive install manual, see this cookbook. Jorge's cookbook…
Visualize open source data
img.tall-chart { display: block; margin-left: auto; margin-right: auto; width: 50%; } Did you know that datasette is a mature tool to display and inspect sqlite databases via your browser? And did you know that Open Data Inception collects thousands of data sets published across the globe? Let’s see what we can do with this information. We’re going to use datasette, Vega, and a subset of open source data published by the Cook County Medical Examiner COVID-19 Related Deaths to grasp how COVID-19 has affected Cook County, Illinois.…
Self documenting makefile
My favorite build tool is make. It’s ironic that I’ve written little clang code given that the tool was created to manage building all those C libraries with header and source files. But whenever I see a Makefile I get excited. The tool doesn’t do much, at least for my use-case. It explicitly defines build dependencies and codifies the available commands in a Git repository. Do I need more from a build tool?…
Debug a program with strace
Here’s a fun little debugging story. I’d begun to use keychain to manage ssh keys across processes. Before keychain, ssh-agent processes would multiply because each script that needed access to an ssh key would spawn its own ssh-agent process. But then I found this error. When I ran eval `/usr/bin/keychain –agents ssh –eval my_rsa`while logged into my shell, the keychain process correctly applied the ssh key to my user’s ssh-agent process.…
Store secret text in the cloud
I was updating my resume the other day when something creepy happened. Dropbox, where my resume sits, showed me an advertisement for resume assistance. If it’s not clear why this creeped me out, consider: to know the file was a resume, Dropbox needs to scan the entire document. It wasn’t called ‘resume’. the scan is sophisticated enough to accurately determine the contents of what I’ve written. at least some of this data is shared with the owner of the advertisement.…
Detect file changes with entr
How have I never heard of entr? This amazing CLI makes it possible to run my custom build scripts on file change, just like many of my favorite tools. Thanks for sharing Julia! I organize various commands with a Makefile that executes Bash scripts. Some tasks, like running a test suite, should be run every time I make a change. If you have a similar configuration as I do, you can simply run the following in your terminal and it’ll execute your test suite on every change!…
Double entry accounting with ledger CLI
If you’d asked me at the start of my MBA program what courses I’d enjoy most, accounting would not have made the top five. This book and an engaged professor (thank you Clarke!) launched accounting to my top three. Frampton and Robilliard’s Color Accounting revolutionized the way I conceive of the flow of capital. Their imagery and definitions exposed me to the fascinating business story that the movement of capital tells and how double-entry accounting documents that story with precision and simplicity.…
Grocery shopping with computer vision
My wife and I share a grocery list so that either of us could pick up the week’s groceries. For common items, we get into a routine: pick up milk, bread, eggs. But when our needs deviate and we need a specific type of bread or a specific brand of cornbread, there’s a lot more information needed to choose the correct items. For instance, we need to specify the store where the item is sold, what brand, what type, and what quantity.…