Skip to content

Commit 1317ff8

Browse files
committed
*
1 parent 3279a23 commit 1317ff8

File tree

8 files changed

+111
-113
lines changed

8 files changed

+111
-113
lines changed

examples/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "better-tmux/examples",
33
"version": "1.0.0",
44
"private": true,
5-
"scripts": {},
65
"type": "module",
76
"dependencies": {
87
"@types/react": "^18.3.3",

packages/cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"module": "index.js",
44
"type": "module",
55
"scripts": {
6-
"rs:dev": "pnpm rescript build -w",
7-
"dev": "bun src/Main.res.js --file ../../examples/index.tsx"
6+
"dev": "pnpm rescript build -w",
7+
"run": "bun src/Main.res.js --file ../../examples/index.tsx"
88
},
99
"dependencies": {
1010
"@rescript/core": "1.4.0",

packages/cli/src/Main.res

+1-106
Original file line numberDiff line numberDiff line change
@@ -1,106 +1 @@
1-
module Env = {
2-
@set
3-
external setTheme: (Bun.Env.t, string) => unit = "BETTER_TMUX_THEME"
4-
}
5-
6-
let createRoot = exec => {
7-
let root: Reconcilier.root = {
8-
mount: tree => {
9-
let body = Parser.make(tree)
10-
exec(body)
11-
},
12-
}
13-
14-
root
15-
}
16-
17-
module Roots = {
18-
let statusLeft = createRoot(body => Tmux.exec(SetGlobal(StatusLeft(body))))
19-
let statusRight = createRoot(body => Tmux.exec(SetGlobal(StatusRight(body))))
20-
let activeWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusCurrentFormat(body))))
21-
let normalWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusFormat(body))))
22-
}
23-
24-
type windowType = [
25-
| #active
26-
| #normal
27-
]
28-
29-
type windowParams = {
30-
@as("type") type_: windowType,
31-
number: string,
32-
name: string,
33-
}
34-
35-
type window = windowParams => TmuxJsx.element
36-
37-
type config = {
38-
theme: option<string>,
39-
statusLeft: option<TmuxJsx.element>,
40-
statusRight: option<TmuxJsx.element>,
41-
window: option<window>,
42-
}
43-
type mod = {default: config}
44-
45-
type flags<'value> = {file: 'value}
46-
47-
module Window = {
48-
let render = (window: window) => {
49-
Reconcilier.render(
50-
window({
51-
type_: #active,
52-
name: "#W",
53-
number: "#I",
54-
}),
55-
Roots.activeWindow,
56-
)
57-
58-
Reconcilier.render(
59-
window({
60-
type_: #normal,
61-
name: "#W",
62-
number: "#I",
63-
}),
64-
Roots.normalWindow,
65-
)
66-
}
67-
}
68-
69-
@val external import_: string => promise<mod> = "import"
70-
71-
let run = async () => {
72-
73-
let options: flags<BunX.flag> = {
74-
file: {type_: "string"},
75-
}
76-
77-
let {values}: BunX.parseArgs<flags<string>> = BunX.parseArgs({
78-
args: Bun.argv,
79-
options,
80-
strict: true,
81-
allowPositionals: true,
82-
})
83-
84-
let path = Path.resolve([values.file])
85-
let {default: config} = await import_(path)
86-
87-
Env.setTheme(Bun.env, config.theme->Option.getOr("catppuccin-mocha"))
88-
89-
switch config.statusLeft {
90-
| None => ()
91-
| Some(statusLeft) => Reconcilier.render(statusLeft, Roots.statusLeft)
92-
}
93-
94-
switch config.statusRight {
95-
| None => ()
96-
| Some(statusRight) => Reconcilier.render(statusRight, Roots.statusRight)
97-
}
98-
99-
switch config.window {
100-
| None => ()
101-
| Some(window) => Window.render(window)
102-
}
103-
104-
}
105-
106-
run()->ignore
1+
Runner.run()->ignore
File renamed without changes.

packages/cli/src/core/Runner.res

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
module Env = {
2+
@set
3+
external setTheme: (Bun.Env.t, string) => unit = "BETTER_TMUX_THEME"
4+
}
5+
6+
let createRoot = exec => {
7+
let root: Reconcilier.root = {
8+
mount: tree => {
9+
let body = Parser.make(tree)
10+
exec(body)
11+
},
12+
}
13+
14+
root
15+
}
16+
17+
module Roots = {
18+
let statusLeft = createRoot(body => Tmux.exec(SetGlobal(StatusLeft(body))))
19+
let statusRight = createRoot(body => Tmux.exec(SetGlobal(StatusRight(body))))
20+
let activeWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusCurrentFormat(body))))
21+
let normalWindow = createRoot(body => Tmux.exec(SetGlobal(WindowStatusFormat(body))))
22+
}
23+
24+
type windowType = [
25+
| #active
26+
| #normal
27+
]
28+
29+
type windowParams = {
30+
@as("type") type_: windowType,
31+
number: string,
32+
name: string,
33+
}
34+
35+
type window = windowParams => TmuxJsx.element
36+
37+
type config = {
38+
theme: option<string>,
39+
statusLeft: option<TmuxJsx.element>,
40+
statusRight: option<TmuxJsx.element>,
41+
window: option<window>,
42+
}
43+
type mod = {default: config}
44+
45+
type flags<'value> = {file: 'value}
46+
47+
module Window = {
48+
let render = (window: window) => {
49+
Reconcilier.render(
50+
window({
51+
type_: #active,
52+
name: "#W",
53+
number: "#I",
54+
}),
55+
Roots.activeWindow,
56+
)
57+
58+
Reconcilier.render(
59+
window({
60+
type_: #normal,
61+
name: "#W",
62+
number: "#I",
63+
}),
64+
Roots.normalWindow,
65+
)
66+
}
67+
}
68+
69+
@val external import_: string => promise<mod> = "import"
70+
71+
let run = async () => {
72+
73+
let options: flags<BunX.flag> = {
74+
file: {type_: "string"},
75+
}
76+
77+
let {values}: BunX.parseArgs<flags<string>> = BunX.parseArgs({
78+
args: Bun.argv,
79+
options,
80+
strict: true,
81+
allowPositionals: true,
82+
})
83+
84+
let path = Path.resolve([values.file])
85+
let {default: config} = await import_(path)
86+
87+
Env.setTheme(Bun.env, config.theme->Option.getOr("catppuccin-mocha"))
88+
89+
switch config.statusLeft {
90+
| None => ()
91+
| Some(statusLeft) => Reconcilier.render(statusLeft, Roots.statusLeft)
92+
}
93+
94+
switch config.statusRight {
95+
| None => ()
96+
| Some(statusRight) => Reconcilier.render(statusRight, Roots.statusRight)
97+
}
98+
99+
switch config.window {
100+
| None => ()
101+
| Some(window) => Window.render(window)
102+
}
103+
104+
}

packages/lib/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "better-tmux",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"exports": {
55
".": {
66
"types": "./dist/index.d.ts",
@@ -17,7 +17,8 @@
1717
},
1818
"type": "module",
1919
"scripts": {
20-
"build": "tsc -p tsconfig.json"
20+
"build": "tsc -p tsconfig.json",
21+
"dev": "tsc -p tsconfig.json --watch"
2122
},
2223
"dependencies": {
2324
"@types/node": "^20.14.9",

packages/lib/src/hooks/use-theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let catppuccinLatte = {
5151

5252
export function useTheme(): ThemePalette {
5353
const theme = process.env.BETTER_TMUX_THEME
54-
console.log(theme)
54+
5555
switch (theme) {
5656
case 'catppuccin-mocha': return catppuccinMocha
5757
case 'catppuccin-macchiato': return catppuccinMacchiato

turbo.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"dependsOn": ["^build"]
66
},
77
"dev": {
8-
"dependsOn": ["^dev"],
98
"persistent": true,
109
"cache": false
1110
}

0 commit comments

Comments
 (0)