diff options
Diffstat (limited to 'sh/shrc.d/md.sh')
-rw-r--r-- | sh/shrc.d/md.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sh/shrc.d/md.sh b/sh/shrc.d/md.sh new file mode 100644 index 00000000..cf44abb3 --- /dev/null +++ b/sh/shrc.d/md.sh @@ -0,0 +1,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 +} |