Tool recommendations and Bash Snippets

September 13, 2019
While reading links from an article on dotfiles in the first issue of

Paged Out

 I came across a tool I hadn't seen.
I like reading about other people's tools and their dotfiles, so here are some tools and bash snippets I think are useful.

I run a bash shell, with tmux and vim.

Tool recommendations

No particular order, and just a random sampling of the first few things filtered by how recently I used them.

Facebook Path Picker

Can take the output of git status or something, and let you pick some of the files, and then open it in an editor.

Diff So Fancy

Better git diffs. Shows what in a line changed, and clear file headers.


"the ultimate pipe plumber", you pipe some data in and it interactively write stuff to pipe it to.

jq (and xq/yq)

jq is a command line json parser.
xq/yq are just xml->json or yaml->json parsers that automatically call jq.


We want to get the latest rasbian image.

The [raspberry pi download RSS]( feed looks like this:

<?xml version='1.0' encoding='UTF-8' ?>
<rss version="2.0" xmlns:dc="">
        <title>Raspberry Pi Root Filesystem Downloads</title>
        <description>The latest root filesystems for the Raspberry Pi computer!</description>

> curl | xq '[[] | select(.title | contains("raspbian_lite"))] | .[-1]'
  "title": "raspbian_lite-2019-07-12",
  "link": ""



Run regex on filenames.
Example: rename all .txt files to .md

rename ‘s/txt/md/’ *.txt

NCurses Disk Usage shows disk usage.

Bash snippets

  • [Shebang line]( says how to execute this file, it’s for more than just bash. Please use one.
  • Second line makes sure that the script executes from the directory it is stored in.
  • set -e causes bash to exit on any non-zero status.
  • set -u causes bash to exit on undefined variables.
    • For more on those, see


cd $(dirname "$0")
set -eu
  • Take command line flags and parse them, have a help function.
  • Also how to use true/false, as they don’t exist in bash but if you use them like this it will work.
  • getopt can do some fancier things, see `man getopt`
help () {
    echo "Usage: gsource FILE [LINE NUMBER]"
    echo "Link to the online git file, with optional line number"
    echo "  -h, --help       display this help and exit"

# getopt short options go together, long options have commas
TEMP=`getopt -o hd:f --long help,dir,force -n '' -- "$@"`
if [ $? != 0 ] ; then
    echo "Something wrong with getopt" >&2
    exit 1
eval set -- "$TEMP"

while true ; do
    case "$1" in
        -h|--help) help; exit 0; shift ;;
        -d|--dir) dir=$2 ; shift 2 ;;
        -f|--force) force=true ; shift ;;
        --) shift ; break ;;
        *) echo "Internal error, unexpected argument '$0'!" ; exit 1 ;;

if [ "$force" = true ]; then
  echo "force was true or whatever"
  • y/n prompt
  • press any key to continue prompt
read -r -p "some yes/no question [Y/n] " response
case "$response" in
    echo "Alright setup your own key"
    echo "Alright good luck"

read -n 1 -s -r -p "Press any key to continue"


Just run it:


Hope you learned something, and I hope you share other things with me.

Feel free to look at

my dotfiles