2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2018-07-25 21:47:14 -04:00
|
|
|
# bu.plugin.sh
|
|
|
|
# Author: Taleeb Midi <taleebmidi@gmail.com>
|
|
|
|
# Based on oh-my-zsh AWS plugin
|
|
|
|
#
|
|
|
|
# command 'bu [N]' Change directory up N times
|
|
|
|
#
|
|
|
|
|
|
|
|
# Faster Change Directory up
|
2019-01-23 03:05:32 -08:00
|
|
|
# shellcheck disable=SC2034
|
2018-07-25 21:47:14 -04:00
|
|
|
function bu () {
|
2019-01-23 03:05:32 -08:00
|
|
|
function usage () {
|
|
|
|
cat <<-EOF
|
|
|
|
Usage: bu [N]
|
|
|
|
N N is the number of level to move back up to, this argument must be a positive integer.
|
|
|
|
h help displays this basic help menu.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
# reset variables
|
|
|
|
STRARGMNT=""
|
|
|
|
FUNCTIONARG=$1
|
|
|
|
# Make sure the provided argument is a positive integer:
|
|
|
|
if [[ ! -z "${FUNCTIONARG##*[!0-9]*}" ]]; then
|
|
|
|
for i in $(seq 1 $FUNCTIONARG); do
|
|
|
|
STRARGMNT+="../"
|
|
|
|
done
|
|
|
|
CMD="cd ${STRARGMNT}"
|
|
|
|
eval $CMD
|
|
|
|
else
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
}
|