diff --git a/bash/.bash_functions b/bash/.bash_functions index a34e3f3..a945105 100644 --- a/bash/.bash_functions +++ b/bash/.bash_functions @@ -298,13 +298,13 @@ function ta() { # Image magick ====================================================== function magika() { if [[ "$1" == "a" || "$1" == "av1" ]]; then - magick convert "$2" "${2%.*}.avif" + magick "$2" "${2%.*}.avif" elif [[ "$1" == "i" ]]; then shift magick identify "$@" elif [[ "$1" == "c" ]]; then shift - magick convert "$@" + magick "$@" else magick "$@" fi @@ -337,5 +337,21 @@ function truecolor () { source ~/.bash_prompt } +# Navigate to the project root ====================================== +rooter() { + local current_dir="$PWD" + + while [[ "$current_dir" != "/" ]]; do + if [[ -d "$current_dir/.git" ]]; then + cd "$current_dir" + return 0 + else + current_dir="$(dirname "$current_dir")" + fi + done + + echo "No .git directory found above cwd." >&2 + return 1 +} # vim: set ft=bash ff=unix: