-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcp2home.sh
executable file
·34 lines (28 loc) · 953 Bytes
/
cp2home.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
exit
# TODO make it non-destructive
if [ -z $1 ]; then
targetdir=$PWD
else
targetdir=$1
fi
for f in $PWD/.[abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*; do
shortfile=${f##/*/}
if [ -h "${HOME}/${shortfile}" ]; then # file exists and is a symlink?
echo "already symlinked ${shortfile}"
elif [ -d "${HOME}/${shortfile}" ]; then # file exists and is a dir?
echo "link dir y/n ${HOME}/${shortfile}"
~/.hunix/bin/rmd ${HOME}/${shortfile}
if [ ! -d "${HOME}/${shortfile}" ]; then
cp -r -i $f $HOME/
fi
elif [ -f "${HOME}/${shortfile}" ]; then # file exists and is a file?
echo "link file y/n ${HOME}/${shortfile}"
cp -i $f $HOME/
elif [ ".svn" == "${shortfile}" ]; then
echo "ignore ${shortfile}"
else
echo "writing ${HOME}/${shortfile}"
cp -i $f $HOME/
fi
done