mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-11 21:36:00 +01:00
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:
parent
2fa3e8475d
commit
a8044811af
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue