Skip to content

Instantly share code, notes, and snippets.

@Satal
Last active September 19, 2026 12:21
Show Gist options
  • Select an option

  • Save Satal/07db78bfc4d714f9c940af08593959ea to your computer and use it in GitHub Desktop.

Select an option

Save Satal/07db78bfc4d714f9c940af08593959ea to your computer and use it in GitHub Desktop.
A function that will make a directory and then change directory into it
# This goes at the end of .bashrc
# mkcd <dir> — make a directory (and any parents) and cd into it
mkcd() {
if [ $# -ne 1 ]; then
echo "Usage: mkcd <directory>" >&2
return 1
fi
mkdir -p -- "$1" && cd -- "$1"
}
complete -d mkcd
# clonecd <url> [dir] [git clone options] — clone a repo and cd into it
clonecd() {
if [ $# -lt 1 ]; then
echo "Usage: clonecd <repository-url> [directory] [git clone options]" >&2
return 1
fi
local url="$1" dir
shift
if [ $# -gt 0 ] && [ "${1#-}" = "$1" ]; then
dir="$1"
shift
else
dir=$(basename -- "${url%/}" .git)
dir="${dir##*:}"
fi
git clone "$@" -- "$url" "$dir" && cd -- "$dir"
}
# lazygit <message...> — stage everything, commit and push in one go
# Based on https://stackoverflow.com/a/23328996/465404
# (Shadows the lazygit TUI if that is ever installed; rename this if so.)
lazygit() {
if [ $# -eq 0 ]; then
echo "Usage: lazygit <commit message>" >&2
return 1
fi
git rev-parse --is-inside-work-tree >/dev/null || return 1
git add -A || return 1
if git diff --cached --quiet; then
echo "lazygit: nothing to commit" >&2
return 1
fi
git commit -m "$*" || return 1
if git rev-parse --abbrev-ref '@{u}' >/dev/null 2>&1; then
git push
else
git push -u origin HEAD
fi
}
convert_to_mp3() {
if [ -z "$1" ]; then
echo "Usage: convert_to_mp3 <input_file>"
return 1
fi
local input_file="$1"
local filename="${input_file%.*}"
local output_file="${filename}.mp3"
docker run --rm -v "$(pwd):/data" jrottenberg/ffmpeg -i "/data/$input_file" "/data/$output_file"
}
transcribe_audio() {
if [ -z "$1" ]; then
echo "Usage: transcribe_audio <input_file> [model]"
echo "Models: tiny, base, small, medium, large (default: base)"
return 1
fi
local input_file="$1"
local model="${2:-base}"
whisper "$input_file" --model "$model" --language en --output_format txt --output_dir .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment