mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
Add 'bu' function to CD up faster
This commit is contained in:
30
plugins/bu/bu.plugin.sh
Normal file
30
plugins/bu/bu.plugin.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user