🏃‍♂️ Usage

sibling [OPTIONS] [DIRs...]
OPTIONS
    -a, --absolute      print the directory name in the absolute path.
    -p, --progress      print the progress traversing directories.
    -t, --type <TYPE>   specifies the traversing type of siblings. Default is 'next'.
                        Available values are: 'next', 'previous', and 'random'.
    -P, --parent        print parent directory, when no more sibling directories.

    -h, --help          print this message.
    -v, --version       print version.
ARGUMENTS
    DIR                 specifies directory. If not specified, the current directory is used.

sibling prints the next directory name with 0 status code. The next directory is decided by the traversing type. Available values are: next, previous, and random, default is next.

After visiting the final directory, sibling prints nothing and exits with non-zero status code.

🆒 Utilities (bash)

The following utility functions are generated by executing sibling --init bash. Therefore, write the snippet (eval "$(sibling --init bash)") into your .bash_profile, and restart bash session.

🔡 change_directory_to_sibling

function __change_directory_to_sibling() {
    traversing_type="$1"
    if [ "$1" == "" ]; then
        traversing_type="next"
    fi
    next=$(sibling -t $traversing_type)
    status=$?
    if [ $status -ne 0 ] ; then
        echo "done ($(sibling -p -t $traversing_type))"
        cd ..
    else
        cd $next
        echo "$PWD ($(sibling -p -t $traversing_type))"
    fi
    return $status
}

cdnext

function cdnext() {
    __change_directory_to_sibling next
}

cdprev

function cdprev() {
    __change_directory_to_sibling previous
}

🔁 cdrand

function cdrand() {
    __change_directory_to_sibling random
}