mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Added taskie configuration & other stuff.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
6dafaf5b9d
commit
fc1b5bbc87
19 changed files with 744 additions and 7 deletions
49
bin/mvln
Executable file
49
bin/mvln
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
declare -a sources
|
||||
|
||||
target=$1; shift;
|
||||
|
||||
i=0
|
||||
while [ "$#" -gt 0 ]; do
|
||||
sources[$i]="$1";
|
||||
shift;
|
||||
let i=i+1;
|
||||
done
|
||||
|
||||
function move-and-link-to-folder {
|
||||
local s="$1"; shift;
|
||||
local target="$1"; shift;
|
||||
local name=$(basename "$s");
|
||||
local sdir=$(dirname "$s");
|
||||
local target_path=$(realpath -Ls --relative-to="$sdir" "$target/$name" )
|
||||
mv "$s" "$target"
|
||||
ln -sf "$target_path" "$s"
|
||||
}
|
||||
|
||||
function move-and-link {
|
||||
local s="$1"; shift;
|
||||
local target="$1"; shift;
|
||||
local sdir=$(dirname "$s");
|
||||
local target_path=$(realpath -Ls --relative-to="$sdir" "$target" )
|
||||
mv "$s" "$target"
|
||||
ln -sf "$target_path" "$s"
|
||||
}
|
||||
|
||||
if [ "$i" -gt 1 ]; then
|
||||
if [ -d "$target" ]; then
|
||||
for s in "${sources[@]}"; do
|
||||
move-and-link-to-folder "$s" "$target"
|
||||
done
|
||||
else
|
||||
echo "Target $target is not directory."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
s="${sources[0]}"
|
||||
if [ -d "$target" ]; then
|
||||
move-and-link-to-folder "$s" "$target"
|
||||
else
|
||||
move-and-link "$s" "$target"
|
||||
fi
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue