Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on Bash Completion

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Installation

Ubuntu / Debian

wajig install bash-completion

macOS

brew install bash-completion

Develop Bash Completion

Auto Generate Bash Completion Scripts

  1. The cobra library in GoLang supports auto …

Tips on "sed"

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Alternatives

  1. sad is a simpler alternative to sed. sad is implemented in Rust and has built-in integration of fzf, which makes it easy to visually inspect changes.

  2. For complicated text substitutions …

Tips on Shell Commands

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

explainshell.com

  1. command-not-found - Suggest installation of packages in interactive bash sessions

  2. nohup, disown

  3. nautilus-open-terminal

Configuration

https://github.com/thoughtbot/til/blob/master/bash/bash_profile_vs_bashrc.md#:~:text=bashrc%20is%20sourced%20on%20every …

Bash Equivalent of the ifmain Pattern in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/usr/bin/env bash

function install_icon.usage() {
    cat << EOF
NAME
    /scripts/sys/install_icon.sh - Download and install icon to /usr/local/bin/.
SYNTAX 
    /scripts/sys/install_icon.sh [-h]
EOF
}

function install_icon …

Get OS and Architecture Information in Shell

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Command Description
uname -a The full info of the machine.
uname The type of OS, e.g., Linux, Darwin, etc.
uname -m The architecture of the machine, e.g., x86_64, etc …