dotfiles/.local/bin/scripts/m

10 lines
401 B
Plaintext
Raw Normal View History

2021-09-18 19:58:30 +00:00
#!/bin/sh -e
# Creates the last arg as directory (or its parent if not ending in a slash)
# and moves the preceding arguments into it.
# Automatically elevates if missing permissions.
2021-10-12 11:55:22 +00:00
last=${@:$#}
2021-09-18 19:58:30 +00:00
! test -e "$1" && echo "$1 does not exist" && exit 1
2021-09-21 20:32:35 +00:00
checkaccess -w "$@" || elevate=sudo
2021-09-18 19:58:30 +00:00
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
2021-10-12 11:55:22 +00:00
$elevate mv --interactive "$@"