rwxrob-dot/scripts/mvlast
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

30 lines
517 B
Bash
Executable File

#!/usr/bin/env bash
readonly CHA=$'\033[38;2;128;255;0m'
readonly RED=$'\033[38;2;255;0;0m'
readonly RESET=$'\033[0m'
newest () {
local IFS=$'\n'
local -a f=($(ls -1 --color=never -trd ${1:-.}/*))
echo "${f[-1]}"
}
lastdown () {
if [[ -z "$DOWNLOADS" ]];then
echo "DOWNLOADS env variable not set"
exit 1
fi
echo "$(newest $DOWNLOADS)"
}
main () {
local from=$(lastdown)
local to="$PWD/$1"
mv "${from}" "${to}"
echo "${RED}From: ${from}"
echo "${CHA}To: ${to}${RESET}"
}
main "$@"