|
@@ -5,19 +5,6 @@
|
5
|
5
|
ffoo import pretty
|
6
|
6
|
|
7
|
7
|
DEFAULT_TARGET=$HOME
|
8
|
|
-TRY_RELPATH=true
|
9
|
|
-
|
10
|
|
-PY_SCRIPT="
|
11
|
|
-import os.path
|
12
|
|
-import sys
|
13
|
|
-src, dst = sys.argv[1:]
|
14
|
|
-r = os.path.relpath(src, dst)
|
15
|
|
-a = os.path.abspath(src)
|
16
|
|
-if len(a) < len (r):
|
17
|
|
- print a
|
18
|
|
-else:
|
19
|
|
- print r
|
20
|
|
-"
|
21
|
8
|
|
22
|
9
|
usage() {
|
23
|
10
|
usage_is "[-t|--target TARGET] [SOURCE] [NAME]"
|
|
@@ -30,34 +17,12 @@ expand_tilde() {
|
30
|
17
|
perl -pe "s|^[[:space:]]*~|$HOME|"
|
31
|
18
|
}
|
32
|
19
|
|
33
|
|
-maybe_relpath() {
|
34
|
|
- local src="$1"
|
35
|
|
- local dst="$2"
|
36
|
|
- $TRY_RELPATH || { echo "$src"; return 0; }
|
37
|
|
- {
|
38
|
|
- echo 'import os.path'
|
39
|
|
- echo 'import sys'
|
40
|
|
- echo 'src, dst = sys.argv[1:]'
|
41
|
|
- echo 'r = os.path.relpath(src, dst)'
|
42
|
|
- echo 'a = os.path.abspath(src)'
|
43
|
|
- echo 'if len(a) < len (r):'
|
44
|
|
- echo ' print a'
|
45
|
|
- echo 'else:'
|
46
|
|
- echo ' print r'
|
47
|
|
- } | python "$src" "$dst"
|
48
|
|
-}
|
49
|
|
-
|
50
|
20
|
link() {
|
51
|
21
|
local src=$1
|
52
|
22
|
local dst=$2
|
53
|
|
- debug -v src dst
|
54
|
|
- if $TRY_RELPATH;
|
55
|
|
- then
|
56
|
|
- src=$(python <(echo "$PY_SCRIPT") "$src" "$(dirname $dst)")
|
57
|
|
- fi
|
58
|
23
|
think "linking $src to $dst"
|
59
|
24
|
rm -f $dst
|
60
|
|
- ln -s $src $dst
|
|
25
|
+ ln -sr $src $dst
|
61
|
26
|
}
|
62
|
27
|
|
63
|
28
|
load() {
|