mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-12 05:45:59 +01:00
feat(bash): pass n dots to .. function to cd n parents up
This commit is contained in:
parent
2fa3e8475d
commit
4033dfaf80
1 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue