-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
executable file
·113 lines (101 loc) · 2.08 KB
/
index.mjs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env zx
const arch = await os.arch();
const currentPath = await $`pwd`;
const homeDir = await os.homedir();
const configList = [
{
from: "/tmux/.tmux.conf",
target: "/.tmux.conf",
},
{
from: "/fish/starship.toml",
target: "/.config/starship.toml",
},
{
from: "/fish/m1.fish",
target: "/.config/fish/config.fish",
},
{
from: "/alacritty/alacritty.yml",
target: "/.alacritty.yml",
},
{
from: "/kitty/kitty.conf",
target: "/.config/kitty/kitty.conf",
},
{
from: "/.gitconfig",
target: "/.gitconfig",
},
{
from: "/nvim",
target: "/.config/nvim",
},
{
from: "/zsh/.zshrc",
target: "/.zshrc",
},
{
from: "/lazygit/config.yml",
target: "/Library/Application Support/lazygit/config.yml",
},
{
from: "/zsh/.p10k.zsh",
target: "/.p10k.zsh",
},
{
from: "/wezterm/wezterm.lua",
target: "/.config/wezterm/wezterm.lua",
},
{
from: "/zellij/config.kdl",
target: "/.config/zellij/config.kdl",
},
{
from: "/sketchybar",
target: "/.config",
},
{
from: "/borders",
target: "/.config",
},
{
from: "/aerospace/.aerospace.toml",
target: "/.aerospace.toml",
},
];
async function createDir() {
console.log(chalk.yellow("👉🏻 create dir"));
await $`mkdir -p ${homeDir}/.config`;
await $`mkdir -p ${homeDir}/.config/wezterm`;
await $`mkdir -p ${homeDir}/.config/zellij`;
await $`mkdir -p ${homeDir}/.config/fish`;
console.log(chalk.yellow("🍭 finish"));
}
async function clean() {
console.log(chalk.yellow("👉🏻 clean"));
await Promise.all([
...configList.map((config) => $`rm -f ${homeDir}${config.target}`),
// $`rm -rf ~/.config/nvim`,
// $`rm -rf ~/.local/share/nvim`,
]);
console.log(chalk.yellow("🍭 finish"));
}
async function sync() {
console.log(chalk.yellow("👉🏻 sync"));
await Promise.all(
configList.map(
(config) =>
$`ln -sf ${currentPath}${config.from} ${homeDir}${config.target}`
)
);
console.log(chalk.yellow("🍭 finish"));
}
try {
await clean();
await createDir();
await sync();
} catch (p) {
console.log(`Exit code: ${p.exitCode}`);
console.log(`Error: ${p.stderr}`);
}