mirror of
https://github.com/sebaschi/dotfiles.git
synced 2025-11-08 18:14:27 +01:00
Addet dots() bash function and corresponding aliases for easier upward navigation in directories.
This commit is contained in:
parent
10e160cbce
commit
d8d3a77113
@ -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 ......'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user