|
@@ -2,7 +2,6 @@
|
2
|
2
|
|
3
|
3
|
. $(ffoom path)
|
4
|
4
|
|
5
|
|
-ffoo import misc
|
6
|
5
|
ffoo import pretty
|
7
|
6
|
|
8
|
7
|
DEFAULT_TARGET=$HOME
|
|
@@ -25,6 +24,30 @@ usage() {
|
25
|
24
|
usage_is "[-f|--force] [-t|--target TARGET] [SOURCE] [NAME]"
|
26
|
25
|
}
|
27
|
26
|
|
|
27
|
+expand_tilde() {
|
|
28
|
+ #
|
|
29
|
+ # Exchange "~" for home
|
|
30
|
+ #
|
|
31
|
+ perl -pe "s|^[[:space:]]*~|$HOME|"
|
|
32
|
+}
|
|
33
|
+
|
|
34
|
+maybe_relpath() {
|
|
35
|
+ local src="$1"
|
|
36
|
+ local dst="$2"
|
|
37
|
+ $TRY_RELPATH || { echo "$src"; return 0; }
|
|
38
|
+ {
|
|
39
|
+ echo 'import os.path'
|
|
40
|
+ echo 'import sys'
|
|
41
|
+ echo 'src, dst = sys.argv[1:]'
|
|
42
|
+ echo 'r = os.path.relpath(src, dst)'
|
|
43
|
+ echo 'a = os.path.abspath(src)'
|
|
44
|
+ echo 'if len(a) < len (r):'
|
|
45
|
+ echo ' print a'
|
|
46
|
+ echo 'else:'
|
|
47
|
+ echo ' print r'
|
|
48
|
+ } | python "$src" "$dst"
|
|
49
|
+}
|
|
50
|
+
|
28
|
51
|
link() {
|
29
|
52
|
local src=$1
|
30
|
53
|
local dst=$2
|