Deduplicating zsh Command History Automatically Once a Day

Automatically Deduplicating zsh Command History in zshrc

With daily terminal work, the same commands pile up in ~/.zsh_history over and over. History searches with peco / Ctrl-R end up full of noise, and the file tends to grow. The zshrc I use every day is part of a dotfiles repository where I keep all my dot files together under Git. This time I decided to touch that zshrc and add settings that cut down the duplicates. Deciding the requirements first Before doing any work, I settled on the following specification. [Read More]

How to Deal with Homebrew 6.0 Asking y/N on Upgrade

How to handle Homebrew 6.0's new interactive upgrade confirmation prompts

From Homebrew 6.0 onwards, running brew upgrade or brew install asks you to confirm whether to continue. Copy ==> This action will upgrade X formulae. Proceed? [y/N] Until now it went ahead automatically, so I imagine many people were caught off guard. In this article I summarize the ways to deal with it depending on the situation. Dealing with it on the spot If you do not need to change any settings in particular, all you do is type y and press Enter when the prompt appears. [Read More]

Removing Containers and Volumes for Just One Docker Compose Project

Safely Clean Up a Single Docker Compose Project

There are plenty of occasions where you clone a repository on GitHub and bring up a Docker environment temporarily to try it out. Deleting the containers and volumes that are no longer needed after testing one by one, however, is a chore. Commands such as docker system prune are convenient, but using them also deletes containers and volumes that are not running and have nothing to do with the test, which has bitten me several times. So I wrote a script that can safely remove the Docker environment of one specific project in a single shot. [Read More]

How to Reload .bashrc and .zshrc Without Logging Out

A Complete Guide to Reloading Shell Configuration Files in Linux

After editing a shell configuration file (.bashrc, .zshrc and so on) on Linux or macOS, how should you apply the changes? Many people probably think of logging out once and logging back in, but in fact there are quite a few more efficient ways. This article explains the various commands for reloading a shell configuration, what characterises each of them, and how to choose between them. 1. The source command - the most basic method The source command is the most common way to run a shell script or a configuration file in the current shell environment. With this command you can load the contents of the specified file into the current shell session without starting a new shell. [Read More]

How to Delete a File Whose Name Starts with -- (Hyphens)

How to remove things like --filename

While I was working with Hugo, either because I got an argument wrong or because I built in View mode, a directory named “–bind=192.168.1.1” ended up being created What does not work When you try to delete a file or directory that starts with – (hyphens) like this, commands such as the ones below cannot remove it Copy $ rm --bind=192.168.1.1 # naturally this is mistaken for an argument, so ☓ $ rm ”--bind=192.168.1.1” ☓ $ rm '--bind=192.168.1.1' ☓ The correct way to delete it You insert “–” (two hyphens) into the command arguments and then specify the file or directory [Read More]