1
0
Fork 0
mirror of https://gitlab.com/dwt1/dotfiles.git synced 2023-02-13 20:55:19 -05:00

Replaced navigation aliases with up() function

This commit is contained in:
Steven Hall 2021-03-09 22:13:12 -08:00
parent b5929750bc
commit 6cc985f5ca

23
.bashrc
View file

@ -106,11 +106,24 @@ ex ()
alias doas="doas --"
# navigation
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
up () {
local d=""
local limit="$1"
# Default to limit of 1
if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
limit=1
fi
for ((i=1;i<=limit;i++)); do
d="../$d"
done
# perform cd. Show error if cd fails
if ! cd "$d"; then
echo "Couldn't go up $limit dirs.";
fi
}
# vim and emacs
alias vim="nvim"