From dd83284688f2e00b026a7eeb769c8ab7ade78e17 Mon Sep 17 00:00:00 2001 From: tmidi Date: Wed, 25 Jul 2018 21:47:14 -0400 Subject: [PATCH] Add 'bu' function to CD up faster --- plugins/bu/bu.plugin.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/bu/bu.plugin.sh diff --git a/plugins/bu/bu.plugin.sh b/plugins/bu/bu.plugin.sh new file mode 100644 index 0000000..0326934 --- /dev/null +++ b/plugins/bu/bu.plugin.sh @@ -0,0 +1,30 @@ +# bu.plugin.sh +# Author: Taleeb Midi +# Based on oh-my-zsh AWS plugin +# +# command 'bu [N]' Change directory up N times +# + +# Faster Change Directory up +function bu () { + 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 +} \ No newline at end of file