A collection of bash shell functions and utilities focused on performance and practical daily use. These scripts avoid expensive subshells where possible and provide consistent visual feedback.
git clone https://github.com/YOUR_GITHUB_USERNAME/shell-and-scripting-helpers.git
cd shell-and-scripting-helpers
./install-meAdd to your ~/.bashrc (for macOS ~/.bash_profile), -or- or add to taste,
to any script you wish to use a particular function in:
source ~/.qfuncs.sh # functions that are useful for scripting
source ~/.emojis.sh # emoji shortcode support
source ~/.colours.sh # ANSI colours, using human readable variable names
[[ $- == *i* ]] && source ~/.clifuncs.sh # useful interactive (terminal) functions
# (only load for interactive shells)- Package manager: Homebrew (macOS) or APT (Linux - assuming Debian/Ubuntu family)
Bash 5 is standard in modern Linux and Windows Subsystem for Linux, but macOS comes with an older version, so upgrade if necessary.
macOS:
brew install bashThe install-me script:
- Detects your operating system and package manager
- Checks for Bash 5+ compatibility
- Scans for missing dependencies and offers to install them
- Creates symlinks in your
$HOMEdirectory for all script files
ripgrep- fast recursive text searchfd- modern, fastfindalternativebat- replacement forcatwith syntax highlightingtldr- simplified quick and dirty help/man page alternativeyt-dlp- YouTube downloaderlsd- modernlswith colorstrash- safe file deletionfzf- fuzzy finder- coreutils - more powerful versions of
cp,mv, andrm,rsync, and more (standard on modern Linux, available via Homebrew on macOS)
- macOS: Uses Homebrew
- Linux: Uses
apt(Debian/Ubuntu). Other distributions require manual dependency installation. - Windows: via WSL (Windows Subsystem for Linux)
Performance-optimized functions for common tasks:
die()- Error handlingwarn(),info()- Standardized messaging (outputs to stderr, safe for piping)qbase()- Fast basename/dirname without subshellsfullpath()- Resolve absolute paths using built-in shell functionality (fast)timestamp(),datestamp()- Date/time utilitiesconfirm_continue()- Interactive confirmation promptsshow_cmd_execute,confirm_cmd_execute- Command execution/confirmation- more …
Associative array mapping GitHub emoji shortcodes to Unicode:
echo "${moji[thumbs_up]}" # 👍
# or
moji thumbs_upANSI escape sequences mapped to human readable variable names.
Command-line tools and aliases:
mkcd()- Make directory and cd into ittrash()- Safe file deletionrgg(),rgw(),rw()- Ripgrep wrappershelp()- Enhanced help using tldr and bat- Git aliases:
s(status),commit(),pull(), etc.
info "Starting process..."
warn "This might take a while"
dodgy_command || die "Something went wrong"
show_cmd_execute ls -l /some/pathqbase "/path/to/file.txt" basename dirname
fullpath "relative/path" resultconfirm_continue "Delete files?" || exit 1
# or
confirm_cmd_execute rm file- Performance: Avoid subshells which slow down execution
- Consistency: user output goes to stderr to preserve pipes
- Safety: Input validation and confirmation prompts
- Portability: Works on macOS and Linux with graceful degradation
macOS:
brew install ripgrep fd bat tldr yt-dlp lsd trash fzf coreutilsDebian/Ubuntu:
sudo apt install ripgrep fd-find bat tldr yt-dlp lsd trash-cli fzf- Functions requiring specific tools will fail gracefully if dependencies are missing
- On macOS, git status functions require
gstatfrom coreutils - Linux users with non-APT package managers need to install dependencies manually
- Fork the repository
- Create a feature branch
- Test on both macOS and Linux
- Ensure bash 5+ compatibility
- Submit a pull request
MIT License