Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cdb() {
- if [ -d "$PWD/$1" ]; then
- command cd "$1"
- return
- fi
- if [ "$1" = '-' ]; then
- command cd -
- return
- fi
- START_DIR="$PWD"
- while [[ $PWD != '/' && $PWD != **"/$1" ]]; do
- command cd ..;
- done
- if [ "$PWD" = '/' ]; then
- command cd "$START_DIR"
- command cd "$1"
- fi
- }
- alias cd=cdb
Add Comment
Please, Sign In to add comment