aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/md.sh
blob: cf44abb37910861757535806c7c600a48ba07755 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Set marked directory to given dir or current dir
md() {

    # Accept up to one argument
    if [ "$#" -gt 1 ] ; then
        printf >&2 'md(): Too many arguments\n'
        return 2
    fi

    # If first arg unset or empty, assume the user means the current dir
    [ -n "$1" ] || set -- "$PWD"

    # If specified path not a directory, refuse to mark it
    if ! [ -d "$1" ] ; then
        printf >&2 'md(): Not a directory\n'
        return 2
    fi

    # Save the specified path in the marked directory var
    PMD=$1
}