21 lines
484 B
Bash
21 lines
484 B
Bash
# Up, the Plugin
|
|
# Author: Peter Hurford
|
|
# https://github.com/peterhurford/up.zsh
|
|
|
|
up(){ # Go up X directories (default 1)
|
|
if [[ "$#" -ne 1 ]]; then
|
|
cd ..
|
|
elif ! [[ $1 =~ '^[0-9]+$' ]]; then
|
|
echo "Error: up should be called with the number of directories to go up. The default is 1."
|
|
else
|
|
local d=""
|
|
limit=$1
|
|
for ((i=1 ; i <= limit ; i++))
|
|
do
|
|
d=$d/..
|
|
done
|
|
d=$(echo $d | sed 's/^\///')
|
|
cd $d
|
|
fi
|
|
}
|