-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstow.tcl
executable file
·55 lines (51 loc) · 1.22 KB
/
stow.tcl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/env tclsh
#.emacs.d
set home "$::env(HOME)"
set fend {
.icons
.local/share/applications
.local/share/icons/hicolor/scalable/apps
.mozilla/firefox
bin
}
set lend [list \
__fonts:.local/share/fonts \
$home/opt/fonts \
__shell:bin/0work0 \
$home/opt/work/0work0 \
_pycharm:.local/share/icons/hicolor/scalable/apps/pycharm.svg \
$home/opt/pycharm/bin/pycharm.svg \
_pycharm:bin/pycharm \
$home/opt/pycharm/bin/pycharm.sh \
]
set stowd [file dirname $::argv0]
if {{relative} eq [file pathtype $::argv0]} {
set stowd [file normalize "[pwd]/$stowd"]
}
cd $home
exec mkdir -p {*}$fend
cd $stowd
puts {Removing absolute links}
foreach {stowed} $lend {
set dirrel [split $stowed :]
set dir [lindex $dirrel 0]
set rel [lindex $dirrel 1]
if {[catch {exec test -L $dir/$rel} res] == 0} {
exec rm $dir/$rel
}
if {[catch {exec test -L $home/$rel} res] == 0} {
exec rm $home/$rel
}
}
puts {Calling stow}
try {
exec >/dev/tty stow -v {*}[glob _*]
} on error e { puts "$e" }
puts {Restoring absolute links}
foreach {stowed toload} $lend {
set dirrel [split $stowed :]
set dir [lindex $dirrel 0]
set rel [lindex $dirrel 1]
exec ln -s $toload $dir/$rel
exec ln -s $toload $home/$rel
}