Skip to content

Commit b7e3446

Browse files
committed
feat(global-options): added support for many global options
1 parent 206ed82 commit b7e3446

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

packages/cli/src/core/Config.res

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,31 @@ type status = {
1616
bg?: string,
1717
left?: TmuxJsx.element,
1818
right?: TmuxJsx.element,
19+
position?: string,
20+
}
21+
22+
type options = {
23+
terminalOverrides?: string,
24+
escapeTime?: int,
25+
paneBaseIndex?: int,
26+
statusKeys?: string,
27+
setTitles?: string,
28+
setTitlesString?: string,
29+
modeKeys?: string,
30+
prefix?: string,
31+
baseIndex?: int,
32+
historyLimit?: int,
33+
defaultTerminal?: string,
34+
mouse?: string,
35+
renumberWindows?: string,
36+
aggressiveResize?: string,
1937
}
2038

2139
type config = {
2240
theme?: string,
2341
status?: status,
2442
window?: window,
43+
options?: options,
2544
}
2645

2746
type mod = {default: config}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let tap = (opt, fn) => opt->Option.map(value => fn(value))->ignore
2+
3+
let execute = (options: Config.options) => {
4+
options.mouse->tap(v => Tmux.exec(SetGlobal(Mouse(v))))
5+
options.terminalOverrides->tap(v => Tmux.exec(SetGlobal(TerminalOverrides(v))))
6+
options.escapeTime->tap(v => Tmux.exec(SetGlobal(EscapeTime(v))))
7+
options.paneBaseIndex->tap(v => Tmux.exec(SetGlobal(PaneBaseIndex(v))))
8+
options.statusKeys->tap(v => Tmux.exec(SetGlobal(StatusKeys(v))))
9+
options.modeKeys->tap(v => Tmux.exec(SetGlobal(ModeKeys(v))))
10+
options.setTitles->tap(v => Tmux.exec(SetGlobal(SetTitles(v))))
11+
options.setTitlesString->tap(v => Tmux.exec(SetGlobal(SetTitlesString(v))))
12+
options.prefix->tap(v => Tmux.exec(SetGlobal(Prefix(v))))
13+
options.baseIndex->tap(v => Tmux.exec(SetGlobal(BaseIndex(v))))
14+
options.historyLimit->tap(v => Tmux.exec(SetGlobal(HistoryLimit(v))))
15+
options.defaultTerminal->tap(v => Tmux.exec(SetGlobal(DefaultTerminal(v))))
16+
options.renumberWindows->tap(v => Tmux.exec(SetGlobal(RenumberWindows(v))))
17+
options.aggressiveResize->tap(v => Tmux.exec(SetGlobal(AggressiveResize(v))))
18+
}
19+

packages/cli/src/core/Runner.res

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ let run = async () => {
2020
| Some(file) => {
2121
let path = Path.resolve([file])
2222
let {default: config} = await Config.import_(path)
23-
23+
2424
Renderer.render(config)
25+
26+
switch config.options {
27+
| None => ()
28+
| Some(options) => GlobalOptions.execute(options)
29+
}
2530
}
2631
}
2732

packages/cli/src/core/Tmux.res

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,23 @@ type options =
33
| StatusBg(string)
44
| StatusLeft(string)
55
| StatusRight(string)
6+
| StatusPosition(string)
67
| WindowStatusCurrentFormat(string)
78
| WindowStatusFormat(string)
9+
| TerminalOverrides(string)
10+
| EscapeTime(int)
11+
| PaneBaseIndex(int)
12+
| StatusKeys(string)
13+
| ModeKeys(string)
14+
| SetTitles(string)
15+
| SetTitlesString(string)
16+
| Prefix(string)
17+
| BaseIndex(int)
18+
| HistoryLimit(int)
19+
| DefaultTerminal(string)
20+
| Mouse(string)
21+
| RenumberWindows(string)
22+
| AggressiveResize(string)
823

924
type command = SetGlobal(options)
1025

@@ -13,8 +28,23 @@ let parseOptions = options => switch options {
1328
| StatusBg(value) => `status-bg "${value}"`
1429
| StatusLeft(value) => `status-left "${value}"`
1530
| StatusRight(value) => `status-right "${value}"`
31+
| StatusPosition(value) => `status-position "${value}"`
1632
| WindowStatusCurrentFormat(value) => `window-status-current-format "${value}"`
1733
| WindowStatusFormat(value) => `window-status-format "${value}"`
34+
| TerminalOverrides(value) => `terminal-overrides "${value}"`
35+
| EscapeTime(value) => `escape-time "${value->Int.toString}"`
36+
| PaneBaseIndex(value) => `pane-base-index "${value->Int.toString}"`
37+
| StatusKeys(value) => `status-keys "${value}"`
38+
| ModeKeys(value) => `mode-keys "${value}"`
39+
| SetTitles(value) => `set-titles ${value}`
40+
| SetTitlesString(value) => `set-titles-string "${value}"`
41+
| Prefix(value) => `prefix "${value}"`
42+
| BaseIndex(value) => `base-index "${value->Int.toString}"`
43+
| HistoryLimit(value) => `history-limit "${value->Int.toString}"`
44+
| DefaultTerminal(value) => `default-terminal "${value}"`
45+
| Mouse(value) => `mouse "${value}"`
46+
| RenumberWindows(value) => `renumber-windows ${value}`
47+
| AggressiveResize(value) => `aggressive-resize ${value}`
1848
}
1949

2050
let parse = command => switch command {

0 commit comments

Comments
 (0)