zsh:mvln(): Refactor to fewer lines and zshisms
This commit is contained in:
@@ -358,15 +358,13 @@ mvln() {
|
|||||||
|
|
||||||
local file reg=0
|
local file reg=0
|
||||||
for file in "${@[1,-2]}"; do
|
for file in "${@[1,-2]}"; do
|
||||||
# If the target is a directory, `file` will end up in it
|
|
||||||
# NOTE: We need absolute paths here for executions like `$0 foo/bar .`
|
# NOTE: We need absolute paths here for executions like `$0 foo/bar .`
|
||||||
# TODO: When do we want/can we use relative links? Only when file is in
|
# TODO: When do we want/can we use relative links? Only when file is in
|
||||||
# current dir?
|
# current dir?
|
||||||
if [[ -d ${@[-1]} ]]; then
|
|
||||||
target="${@[-1]:A}/$(basename "$file")"
|
|
||||||
else
|
|
||||||
target="${@[-1]:A}"
|
target="${@[-1]:A}"
|
||||||
fi
|
# If the target is a directory, `file` will end up in it
|
||||||
|
[[ ! -d ${@[-1]} ]] || target+="/$file:t"
|
||||||
|
|
||||||
if ! command mv -i "$file" "${@[-1]}"; then
|
if ! command mv -i "$file" "${@[-1]}"; then
|
||||||
reg=1
|
reg=1
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user