I have the following git alias function that moves files into a directory using git mv of those files and then does the git commit :
[alias]
mv-into-dir = "!mvIntoDIR() { \
cd ${GIT_PREFIX:-.}; \
allArgsButLast=\"${@:1:$#-1}\"; \
lastArg=\"${@: -1}\"; \
git mv -v $allArgsButLast $lastArg/; \
git commit -uno $allArgsButLast $lastArg -m \"Moved $allArgsButLast into $lastArg/\"; \
}; mvIntoDIR"
It seems fine :
$ git config alias.mv-into-dir
!mvIntoDIR() { cd ${GIT_PREFIX:-.}; allArgsButLast="${@:1:$#-1}"; lastArg="${@: -1}"; git mv -v $allArgsButLast $lastArg/; git commit -uno $allArgsButLast $lastArg -m "Moved $allArgsButLast into $lastArg/"; }; mvIntoDIR
$
But when I run it, I get a 1: Bad substitution error :
$ git mv-into-dir .conkyrc.back tmp
mvIntoDIR() { cd ${GIT_PREFIX:-.}; allArgsButLast="${@:1:$#-1}"; lastArg="${@: -1}"; git mv -v $allArgsButLast $lastArg/; git commit -uno $allArgsButLast $lastArg -m "Moved $allArgsButLast into $lastArg/"; }; mvIntoDIR: 1: Bad substitution
$