Addet dots() bash function and corresponding aliases for easier upward navigation in directories.

This commit is contained in:
Sebastian Lenzlinger 2024-12-10 12:49:56 +01:00
parent 10e160cbce
commit d8d3a77113

View File

@ -101,3 +101,28 @@ goto() {
cd -- "$(dirname "$(fd $1 $HOME /bin /usr/local /usr /etc | fzy)")" cd -- "$(dirname "$(fd $1 $HOME /bin /usr/local /usr /etc | fzy)")"
} }
# Easier cd'ing (aliases here because they depend on dots() function being available)
dots() {
# Count number of dots
local depth=$(echo -n "$1" | tr -cd '.' | wc -c)
# if no dots, stay in current directory
if [ "depth" -eq 0 ]; then
depth=1
fi
for _ in $(seq 1 "$depth"); do
cd ..
done
}
# aliases for even easier navigation
alias ..='dots ..'
alias ...='dots ...'
alias ....='dots ....'
alias .....='dots .....'
alias ......='dots ......'