- fname: Generate random, human-friendly names
- python-easter-eggs: Curated list of all the easter eggs and hidden jokes in Python
Interesting Links
- Why GNU grep is fast
- Why ripgrep is faster
Tip of the Week
Using named pipes:
Processes can pipe output to other processes, e.g. ps | grep vim | wc -l
, or files, e.g. pgrep vim > /tmp/vim_pids
. If the processes need to communicate between users, for example, or are separated for any reason, you can use a named pipe.
# create the named pipe in an appropriate location
mkfifo /tmp/fifo
# for demonstration purposes, simple output to stdout
tail -f /tmp/fifo | tr ' ' '-'
# now begin the source process in another shell
while :; do date > /tmp/fifo; sleep 1; done
You’ll witness the input into /tmp/fifo
as the output, transformed by tr
. You can start and stop either process at any time, and the named pipe will remain.
Continue reading
- f3: Fight Flash Fraud
- vite: Next generation frontend tooling
Interesting Links
- Homebrew 4.0
- Mainframes are still a big thing
- Docker Compose: What’s New, What’s Changing, What’s Next
Tip of the Week
Using the GitHub CLI tool, gh
, you can create and edit gists. However, to update a gist, you are required to open the file in your set editor. But we can get around this by using the VISUAL
environment variable, and the tee
program.
Part 1: EDITOR
and VISUAL
In historical content, EDITOR
would be a lightweight editor (e.g. ed
) and VISUAL
would be a full-fledged editor (e.g. vi
). Nowadays, you can set them both to the same (e.g. vim
, emacs
), and you may even opt to set VISUAL
to a GUI app (e.g. code
for VSCode). The shell will open the appropriate program when applicable. Side note: this is similar for the PAGER
variable as well, e.g. set it to bat
instead of less
.
Part 2: Piping with tee
The tee
programs lets us split output, to stdout but also to a file. Some examples:
% date >&1 # a verbose way to show redirection to stdout
% date >&2 # redirection to stderr
% date > /tmp/date # output to a file
% date >> /tmp/date # append output to a file
% date | tee /tmp/date # output to stdout _and_ a file
% date | tee -a /tmp/date # stdout and append to a file
# pipe to stdout but also pipe to additional commands
% date +%F_%T | tee /dev/tty | tr -d ":-" | tr "_" "-"
2023-02-16_21:18:58
20230216-211858
Part 3: Putting it Together
Since gh
supports VISUAL
, we set it to tee
so that reading in a file pipes the file contents into gh
without ever opening an editor. The final > /dev/null
sinkholes the file contents since we don’t need to actually see it in stdout.
VISUAL=tee gh gist edit GIST < /path/to/file > /dev/null
Continue reading
- fzf-marks: Plugin to manage bookmarks in bash and zsh
- yt-dlp: A youtube-dl fork with additional features and fixes
Interesting Links
- 14 Rust Tools for Linux Terminal Dwellers
- 5 great Perl scripts to keep in your sysadmin toolbox
- Open source’s impact on the world’s 100 million developers
Tip of the Week
When you have a process that is stuck or won’t respond, a good rule of thumb for escalating kill
s:
kill -15
(TERM
)
kill -2
(INT
)
kill -9
(KILL
)
The first two options give the misbehaving program a chance to quit gracefully and cleanup after itself. A -9
may leave artifacts behind (lock files, temp files, etc).
You can list all of the signals with kill -l
. A function to show the signals and their number:
while read -r sig; do
printf "%s %s\n" "$(kill -l $sig)" "$sig"
done <<< $(kill -l | tr ' ' '\n') | column
Bonus:
- Find a process PID with
pgrep <process>
- To kill all processes that match a name:
pkill -<num> <process>
Continue reading