logo

Fish and pipestatus

Fish and $pipestatus Note: This morning I answered a Reddit post about $pipestatus, and after learning that there’s not a lot of good information out there, I thought making a blog post might be helpful for other future Fish users wanting to know more about using Fish’s $pipestatus. What’s an exit status? In Fish, like other shells, you can tell whether a command failed via its return value, sometimes called an exit code or an exit status.
6 minutes to read

Finding common bigrams

Find common bigrams Bigrams are 2-letter combos. When designing a keyboard layout, it’s common to optimize for comfort and speed by analyzing bigrams. Here’s a simple shell script to do a quick-and-dirty bigram analysis. Start with a corpus Download Shai’s corpus for Colemak: cd ~/Downloads curl -fsSLo corpus.txt.xz https://colemak.com/pub/corpus/iweb-corpus-samples-cleaned.txt.xz Extract the .txt file: unxz corpus.txt.xz Split into individual words Separate that corpus into individual words, one per lined, and all lowecase letters:
One minute to read

Using awk to colorize go output

From my StackOverflow answer on the subject of colorizing Golang test run output: I like piping to a simple awk script to colorize output from other shell commands. That way, you can customize with whatever colors/patterns suit you. You want to colorize an output unique to your project? Go for it. Simply save this awk script to ./bin/colorize in your project, chmod u+x ./bin/colorize, and customize to your needs: #!/usr/bin/awk -f # colorize - add color to go test output # usage: # go test .
One minute to read

Zsh - splitting a string into an array

Zsh - splitting a string into an array Intro There are a ton of different ways to split up a string in Zsh. This post attempts to show them with examples to help you build your own. I write Zsh scripts all the time, and still reference back to this guide, so there you go. Using the split parameter expansion ${(s/x/)foo} From the Zsh docs on Parameter Expansion Flags (yeah - I know… how would anyone ever find that if they didn’t know where to look!
3 minutes to read

zstyle primer

From my StackOverflow answer on the subject of Zstyles: When it comes to learning about the Zsh zstyle, it’s hard to find a lot of good examples that describe what zstyles are used for and how to use them. The Zsh documentation notoriously obtuse. To learn about zstyle, I recommend spending some time looking at how Prezto uses it, as well as reading the docs and trying some things in an interactive Zsh session.
3 minutes to read