Skip to content

Instantly share code, notes, and snippets.

View deanhouseholder's full-sized avatar
Hacking away

Dean Householder deanhouseholder

Hacking away
View GitHub Profile
deanhouseholder /
Created March 23, 2022 20:45
Bash function to check for git updates in the current repo with nice output
# Check to see if there are new commits on the current branch
function check() {
# Check if in a git repo
git status &>/dev/null
test $? -ne 0 && printf "Not a git repo\n" && return 1
# Fetch latest commits from git remote
printf "\n${details}Checking for latest git changes...$n"
git fetch &>/dev/null
deanhouseholder /
Created January 20, 2022 00:59
Bash enhanced extraction of common filetypes
## Extract function with progress bars where possible
# Syntax is:
# e [filename]
# Install "pv" and "funzip" packages for progress bars
function e() {
# Exit the function if the file is not found
if [[ ! -f "$1" ]]; then
printf "\n\e[31mERROR: Couldn't find file to extract.\e[0m\n"
return 1
deanhouseholder /
Created January 20, 2022 00:54
Enhanced apt functions for use with fzf (fuzzy finder)
# Bash shortcuts for enhancing apt with fzf (on Debian Linux)
if [[ -x "$(type -fP apt)" ]]; then # Only load if apt is present
# fzf start service(s)
function start() {
printf "Generating list of stopped running services\r"
service --status-all 2>&1 | grep '\[ \- \]' | awk '{print $4}' \
| fzf --tac -0 -m --prompt="Choose service(s) to start: " \
| while read service; do
printf "Starting $service\e[K\n"
deanhouseholder /
Created January 20, 2022 00:51
Bash enhanced 'cd' replacement
# Replace cd functionality to use pushd instead. If file is given, open in default editor.
# You can define an array of keyword-based pre-defined directories which will work anywhere
# Examples:
# "cd bin" will take you to ~/bin/
# "cd logs" will take you to /var/log/apache2/
# Setup:
# Inside your script, define them in this manner:
# cd_array=(
# 'bin'='/root/bin'
deanhouseholder /
Created January 20, 2022 00:44
Bash shortcuts for Docker
## Docker Shortcuts
# Docker Aliases
if [[ "$bash_on_windows" -eq 1 ]]; then
# This bash is running on Windows so use docker.exe
[[ -x "$(type -fP winpty)" ]] && alias docker='winpty docker.exe' || alias docker='docker.exe'
alias docker-compose='docker-compose.exe'
alias docker-machine='docker-machine.exe'
alias da='docker attach'
deanhouseholder /
Last active January 19, 2024 15:48
Bash Search Function
# Recursive File Contents Search function
# $1 = Search string (or -i to see list of ignored filetypes)
# $2 = (optional) File pattern (ex: *.js) (default is: *)
# $3 = (optional) Set to 1 for case-insensitive search (default is: 0 (case-sensitive))
# $4 = (optional) Comma-separated list of directories to ignore (format is: ".git,vendor,node_modules,bin")
# Bug: Backslashes are not displaying in results. (ex: "\n" shows up as "n")
function search(){
# Define Vars
local sep=$'\x01' # Obscure ascii character not likely to appear in files
local col_spacing=3

Keybase proof

I hereby claim:

  • I am deanhouseholder on github.
  • I am deanhouseholder ( on keybase.
  • I have a public key whose fingerprint is 25ED 952C C482 99B7 1DF4 1820 A49E 89BC 1143 4A13

To claim this, I am signing this object:

# Usage: sudo apt-get install -yqq curl; curl -L -s | sudo bash
#alias sagi="apt-get install --yes --quiet" # normall sudo apt-get, but this is already root
#alias sagid="apt-get install --yes --quiet --download-only" # same as above