feat(bash): pass n dots to .. function to cd n parents up (#72)

Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/72
This commit is contained in:
Victor Westerlund 2025-12-05 13:24:49 +01:00
parent 2fa3e8475d
commit a8044811af

View file

@ -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 cd .. && l
} }