From a8044811af174a70f7e8181ab8de8685a8ee2186 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Fri, 5 Dec 2025 13:24:49 +0100 Subject: [PATCH] feat(bash): pass n dots to `..` function to cd n parents up (#72) Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/72 --- .bash_aliases | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.bash_aliases b/.bash_aliases index 87876f4..7b56603 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -94,6 +94,20 @@ lll () { } .. () { + # Count the number of dots in the first argument + local count=$(echo "$1" | grep -o "\." | wc -l) + + # Check if count is greater than zero + if [ "$count" -gt 0 ]; then + # Construct the path to go up n directories + local path="$(printf '../%.0s' $(seq 1 $count))" + + # Change the directory + cd $path || echo "Failed to change directory." + l + return + fi + cd .. && l }