machineconfig 7.38__py3-none-any.whl → 7.44__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/jobs/installer/installer_data.json +34 -0
- machineconfig/profile/create_links.py +2 -1
- machineconfig/profile/create_links_export.py +43 -11
- machineconfig/profile/create_shell_profile.py +64 -124
- machineconfig/profile/mapper.toml +4 -0
- machineconfig/scripts/linux/wrap_mcfg +1 -1
- machineconfig/scripts/python/croshell.py +4 -4
- machineconfig/scripts/python/define.py +1 -1
- machineconfig/scripts/python/env_manager/path_manager_tui.py +1 -1
- machineconfig/scripts/python/explore.py +49 -0
- machineconfig/scripts/python/helpers_devops/cli_config.py +27 -31
- machineconfig/scripts/python/helpers_devops/cli_config_dotfile.py +12 -9
- machineconfig/scripts/python/helpers_devops/cli_nw.py +7 -6
- machineconfig/scripts/python/helpers_devops/cli_repos.py +11 -10
- machineconfig/scripts/python/helpers_devops/cli_self.py +5 -7
- machineconfig/scripts/python/helpers_devops/cli_share_file.py +137 -0
- machineconfig/scripts/python/helpers_devops/cli_share_server.py +62 -166
- machineconfig/scripts/python/helpers_repos/cloud_repo_sync.py +34 -15
- machineconfig/scripts/python/helpers_repos/count_lines_frontend.py +1 -1
- machineconfig/scripts/python/machineconfig.py +7 -0
- machineconfig/scripts/python/terminal.py +20 -3
- machineconfig/scripts/windows/mounts/mount_ssh.ps1 +1 -1
- machineconfig/scripts/windows/wrap_mcfg.ps1 +5 -0
- machineconfig/settings/helix/config.toml +14 -0
- machineconfig/settings/lf/linux/exe/lfcd.sh +1 -0
- machineconfig/settings/lf/linux/exe/previewer.sh +3 -2
- machineconfig/settings/shells/bash/init.sh +2 -1
- machineconfig/settings/shells/nushell/config.nu +1 -31
- machineconfig/settings/shells/nushell/init.nu +100 -34
- machineconfig/settings/shells/wt/settings.json +10 -2
- machineconfig/settings/yazi/init.lua +36 -0
- machineconfig/settings/yazi/keymap.toml +52 -0
- machineconfig/settings/yazi/shell/yazi_cd.sh +8 -0
- machineconfig/settings/yazi/yazi.toml +8 -0
- machineconfig/setup_linux/web_shortcuts/interactive.sh +10 -10
- machineconfig/setup_windows/web_shortcuts/interactive.ps1 +10 -10
- machineconfig/utils/code.py +1 -1
- machineconfig/utils/links.py +3 -2
- machineconfig/utils/ssh.py +1 -1
- {machineconfig-7.38.dist-info → machineconfig-7.44.dist-info}/METADATA +1 -1
- {machineconfig-7.38.dist-info → machineconfig-7.44.dist-info}/RECORD +44 -41
- {machineconfig-7.38.dist-info → machineconfig-7.44.dist-info}/entry_points.txt +1 -0
- machineconfig/scripts/python/helpers_repos/secure_repo.py +0 -15
- {machineconfig-7.38.dist-info → machineconfig-7.44.dist-info}/WHEEL +0 -0
- {machineconfig-7.38.dist-info → machineconfig-7.44.dist-info}/top_level.txt +0 -0
|
@@ -69,6 +69,23 @@
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
"appName": "timg",
|
|
74
|
+
"repoURL": "CMD",
|
|
75
|
+
"doc": "👁️ terminal image previewer.",
|
|
76
|
+
"fileNamePattern": {
|
|
77
|
+
"amd64": {
|
|
78
|
+
"linux": "sudo apt install timg",
|
|
79
|
+
"windows": null,
|
|
80
|
+
"macos": "brew install timg"
|
|
81
|
+
},
|
|
82
|
+
"arm64": {
|
|
83
|
+
"linux": "sudo apt install timg",
|
|
84
|
+
"windows": null,
|
|
85
|
+
"macos": "brew install timg"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
72
89
|
{
|
|
73
90
|
"appName": "diskonaut",
|
|
74
91
|
"repoURL": "https://github.com/imsnif/diskonaut",
|
|
@@ -1735,6 +1752,23 @@
|
|
|
1735
1752
|
}
|
|
1736
1753
|
}
|
|
1737
1754
|
},
|
|
1755
|
+
{
|
|
1756
|
+
"appName": "miniserve",
|
|
1757
|
+
"repoURL": "https://github.com/svenstaro/miniserve",
|
|
1758
|
+
"doc": "📂 A small, self-contained file server with directory listings",
|
|
1759
|
+
"fileNamePattern": {
|
|
1760
|
+
"amd64": {
|
|
1761
|
+
"linux": "miniserve-{version}-x86_64-unknown-linux-musl",
|
|
1762
|
+
"darwin": "miniserve-{version}-x86_64-apple-darwin",
|
|
1763
|
+
"windows": "miniserve-{version}-x86_64-pc-windows-msvc.exe"
|
|
1764
|
+
},
|
|
1765
|
+
"arm64": {
|
|
1766
|
+
"linux": "miniserve-{version}-aarch64-unknown-linux-musl",
|
|
1767
|
+
"darwin": "miniserve-{version}-aarch64-apple-darwin",
|
|
1768
|
+
"windows": "miniserve-{version}-aarch64-pc-windows-msvc.exe"
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
},
|
|
1738
1772
|
{
|
|
1739
1773
|
"appName": "cloudreve",
|
|
1740
1774
|
"repoURL": "https://github.com/cloudreve/Cloudreve",
|
|
@@ -13,6 +13,7 @@ from rich.table import Table
|
|
|
13
13
|
|
|
14
14
|
from machineconfig.utils.path_extended import PathExtended
|
|
15
15
|
from machineconfig.utils.links import symlink_map, copy_map
|
|
16
|
+
from machineconfig.profile.create_links_export import ON_CONFLICT_STRICT
|
|
16
17
|
from machineconfig.utils.source_of_truth import LIBRARY_ROOT, CONFIG_ROOT
|
|
17
18
|
|
|
18
19
|
import platform
|
|
@@ -79,7 +80,7 @@ def read_mapper() -> MapperFileData:
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
def apply_mapper(mapper_data: dict[str, list[ConfigMapper]],
|
|
82
|
-
on_conflict:
|
|
83
|
+
on_conflict: ON_CONFLICT_STRICT,
|
|
83
84
|
method: Literal["symlink", "copy"]
|
|
84
85
|
):
|
|
85
86
|
operation_records: list[OperationRecord] = []
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
|
|
2
2
|
import typer
|
|
3
|
-
from typing import Optional, Literal, Annotated
|
|
3
|
+
from typing import Optional, Literal, Annotated, TypeAlias
|
|
4
4
|
|
|
5
|
+
ON_CONFLICT_LOOSE: TypeAlias = Literal[
|
|
6
|
+
"throw-error", "t",
|
|
7
|
+
"overwrite-self-managed", "os",
|
|
8
|
+
"backup-self-managed", "bs",
|
|
9
|
+
"overwrite-default-path", "od",
|
|
10
|
+
"backup-default-path", "bd"
|
|
11
|
+
]
|
|
12
|
+
ON_CONFLICT_STRICT: TypeAlias = Literal["throw-error", "overwrite-self-managed", "backup-self-managed", "overwrite-default-path", "backup-default-path"]
|
|
13
|
+
ON_CONFLICT_MAPPER: dict[str, ON_CONFLICT_STRICT] = {
|
|
14
|
+
"t": "throw-error",
|
|
15
|
+
"os": "overwrite-self-managed",
|
|
16
|
+
"bs": "backup-self-managed",
|
|
17
|
+
"od": "overwrite-default-path",
|
|
18
|
+
"bd": "backup-default-path"
|
|
19
|
+
}
|
|
5
20
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
|
|
22
|
+
def main_public_from_parser(method: Annotated[Literal["symlink", "s", "copy", "c"], typer.Option(..., "--method", "-m", help="Method to use for setting up the config file.")],
|
|
23
|
+
on_conflict: Annotated[ON_CONFLICT_LOOSE, typer.Option(..., "--on-conflict", "-o", help="Action to take on conflict")] = "throw-error",
|
|
24
|
+
which: Annotated[Optional[str], typer.Option(..., "--which", "-w", help="Specific items to process (default: all)")] = None,
|
|
25
|
+
interactive: Annotated[bool, typer.Option(..., "--interactive", "-i", help="Run in interactive mode")] = False):
|
|
10
26
|
"""Terminology:
|
|
11
27
|
SOURCE = Self-Managed-Config-File-Path
|
|
12
28
|
TARGET = Config-File-Default-Path
|
|
@@ -24,19 +40,28 @@ def main_public_from_parser(method: Annotated[Literal["symlink", "copy"], typer.
|
|
|
24
40
|
else:
|
|
25
41
|
items_chosen = which.split(",")
|
|
26
42
|
items_objections: dict[str, list[ConfigMapper]] = {item: mapper_full[item] for item in items_chosen if item in mapper_full}
|
|
27
|
-
|
|
43
|
+
if len(items_objections) == 0:
|
|
44
|
+
typer.echo("[red]Error:[/] No valid items selected.")
|
|
45
|
+
typer.Exit(code=1)
|
|
46
|
+
return
|
|
28
47
|
from machineconfig.profile.create_links import apply_mapper
|
|
29
48
|
from machineconfig.profile.create_helper import copy_assets_to_machine
|
|
30
49
|
copy_assets_to_machine(which="settings") # config files live here and will be linked to.
|
|
31
|
-
|
|
50
|
+
method_map: dict[str, Literal["symlink", "copy"]] = {
|
|
51
|
+
"s": "symlink",
|
|
52
|
+
"symlink": "symlink",
|
|
53
|
+
"c": "copy",
|
|
54
|
+
"copy": "copy",
|
|
55
|
+
}
|
|
56
|
+
method = method_map[method]
|
|
57
|
+
apply_mapper(mapper_data=items_objections, on_conflict=ON_CONFLICT_MAPPER[on_conflict], method=method)
|
|
32
58
|
|
|
33
59
|
|
|
34
|
-
def main_private_from_parser(method: Annotated[Literal["symlink", "copy"], typer.Option(..., help="Method to use for linking files")],
|
|
35
|
-
on_conflict: Annotated[
|
|
60
|
+
def main_private_from_parser(method: Annotated[Literal["symlink", "s", "copy", "c"], typer.Option(..., help="Method to use for linking files")],
|
|
61
|
+
on_conflict: Annotated[ON_CONFLICT_LOOSE, typer.Option(..., help="Action to take on conflict")] = "throw-error",
|
|
36
62
|
which: Annotated[Optional[str], typer.Option(..., help="Specific items to process")] = None,
|
|
37
63
|
interactive: Annotated[bool, typer.Option(..., help="Run in interactive mode")] = False):
|
|
38
64
|
from machineconfig.profile.create_links import ConfigMapper, read_mapper
|
|
39
|
-
|
|
40
65
|
mapper_full = read_mapper()["private"]
|
|
41
66
|
if which is None:
|
|
42
67
|
assert interactive is True
|
|
@@ -51,4 +76,11 @@ def main_private_from_parser(method: Annotated[Literal["symlink", "copy"], typer
|
|
|
51
76
|
items_objections: dict[str, list[ConfigMapper]] = {item: mapper_full[item] for item in items_chosen if item in mapper_full}
|
|
52
77
|
|
|
53
78
|
from machineconfig.profile.create_links import apply_mapper
|
|
54
|
-
|
|
79
|
+
method_map: dict[str, Literal["symlink", "copy"]] = {
|
|
80
|
+
"s": "symlink",
|
|
81
|
+
"symlink": "symlink",
|
|
82
|
+
"c": "copy",
|
|
83
|
+
"copy": "copy",
|
|
84
|
+
}
|
|
85
|
+
method = method_map[method]
|
|
86
|
+
apply_mapper(mapper_data=items_objections, on_conflict=ON_CONFLICT_MAPPER[on_conflict], method=method)
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
"""shell"""
|
|
2
2
|
|
|
3
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
4
|
-
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
5
3
|
from pathlib import Path
|
|
6
|
-
import platform
|
|
7
|
-
import os
|
|
8
|
-
import subprocess
|
|
9
|
-
from rich.console import Console
|
|
10
|
-
from rich.panel import Panel
|
|
11
4
|
|
|
12
5
|
|
|
13
|
-
system = platform.system()
|
|
14
|
-
sep = ";" if system == "Windows" else ":" # PATH separator, this is special for PATH object, not to be confused with PathExtended.sep (normal paths), usually / or \
|
|
15
|
-
PATH = os.environ["PATH"].split(sep)
|
|
16
|
-
console = Console()
|
|
17
|
-
BOX_WIDTH = 100 # Define BOX_WIDTH or get it from a config
|
|
18
|
-
|
|
19
6
|
|
|
20
7
|
def get_shell_profile_path() -> Path:
|
|
8
|
+
import platform
|
|
9
|
+
import subprocess
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.panel import Panel
|
|
12
|
+
system = platform.system()
|
|
13
|
+
console = Console()
|
|
21
14
|
if system == "Windows":
|
|
22
15
|
result = subprocess.run(["pwsh", "-Command", "$PROFILE"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=False)
|
|
23
16
|
if result.returncode == 0 and result.stdout.strip():
|
|
@@ -37,8 +30,34 @@ def get_shell_profile_path() -> Path:
|
|
|
37
30
|
return profile_path
|
|
38
31
|
|
|
39
32
|
|
|
33
|
+
def get_nu_shell_profile_path() -> Path:
|
|
34
|
+
import platform
|
|
35
|
+
from rich.console import Console
|
|
36
|
+
from rich.panel import Panel
|
|
37
|
+
system = platform.system()
|
|
38
|
+
console = Console()
|
|
39
|
+
if system == "Windows":
|
|
40
|
+
profile_path = Path.home().joinpath(r"AppData\Roaming\nushell")
|
|
41
|
+
elif system == "Linux":
|
|
42
|
+
profile_path = Path.home().joinpath(".config/nushell")
|
|
43
|
+
elif system == "Darwin":
|
|
44
|
+
profile_path = Path.home().joinpath("Library/Application Support/nushell")
|
|
45
|
+
else:
|
|
46
|
+
raise ValueError(f"""Not implemented for this system {system}""")
|
|
47
|
+
console.print(Panel(f"""🐚 NU SHELL PROFILE | Working with path: `{profile_path}`""", title="[bold cyan]Nu Shell Profile[/bold cyan]", border_style="cyan"))
|
|
48
|
+
return profile_path
|
|
49
|
+
|
|
50
|
+
|
|
40
51
|
def create_default_shell_profile() -> None:
|
|
41
52
|
shell_profile_path = get_shell_profile_path()
|
|
53
|
+
import platform
|
|
54
|
+
import subprocess
|
|
55
|
+
from rich.console import Console
|
|
56
|
+
from rich.panel import Panel
|
|
57
|
+
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
58
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
59
|
+
system = platform.system()
|
|
60
|
+
console = Console()
|
|
42
61
|
if not shell_profile_path.exists():
|
|
43
62
|
console.print(Panel(f"""🆕 PROFILE | Profile does not exist at `{shell_profile_path}`. Creating a new one.""", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
44
63
|
shell_profile_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -79,117 +98,38 @@ def create_default_shell_profile() -> None:
|
|
|
79
98
|
console.print(Panel("✅ Profile updated successfully", title="[bold blue]Profile[/bold blue]", border_style="blue"))
|
|
80
99
|
|
|
81
100
|
|
|
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
|
-
|
|
114
|
-
# console.print(Panel("🔄 Adding sources to shell profile", title="[bold blue]Sources[/bold blue]", border_style="blue"))
|
|
115
|
-
|
|
116
|
-
# if choice is None:
|
|
117
|
-
# choice_obj = choose_from_options(msg="Which patch to add?", options=sources + ["all", "none(EXIT)"], default="none(EXIT)", multi=True)
|
|
118
|
-
# if isinstance(choice_obj, str):
|
|
119
|
-
# if choice_obj == "all":
|
|
120
|
-
# choice = choice_obj
|
|
121
|
-
# elif choice_obj == "none(EXIT)":
|
|
122
|
-
# return
|
|
123
|
-
# else:
|
|
124
|
-
# sources = [choice_obj]
|
|
125
|
-
# else: # isinstance(choice_obj, list):
|
|
126
|
-
# sources = choice_obj
|
|
127
|
-
# elif choice == "none(EXIT)":
|
|
128
|
-
# return
|
|
129
|
-
|
|
130
|
-
# if isinstance(profile_path, str):
|
|
131
|
-
# profile_path_obj = PathExtended(profile_path)
|
|
132
|
-
# else:
|
|
133
|
-
# profile_path_obj = get_shell_profile_path()
|
|
134
|
-
# profile = profile_path_obj.read_text(encoding="utf-8")
|
|
135
|
-
|
|
136
|
-
# for a_file in sources:
|
|
137
|
-
# tmp = a_file.replace("REPO_ROOT", REPO_ROOT.as_posix()).replace("LIBRARY_ROOT", LIBRARY_ROOT.as_posix())
|
|
138
|
-
# file = PathExtended(tmp).collapseuser() # this makes the shell profile interuseable across machines.
|
|
139
|
-
# file = file.as_posix() if system == "Linux" else str(file)
|
|
140
|
-
# if file not in profile:
|
|
141
|
-
# if system == "Windows":
|
|
142
|
-
# profile += f"\n. {file}"
|
|
143
|
-
# console.print(f"➕ Added PowerShell source: {file}")
|
|
144
|
-
# elif system == "Linux":
|
|
145
|
-
# profile += f"\nsource {file}"
|
|
146
|
-
# console.print(f"➕ Added Bash source: {file}")
|
|
147
|
-
# else:
|
|
148
|
-
# raise ValueError(f"Not implemented for this system {system}")
|
|
149
|
-
# else:
|
|
150
|
-
# console.print(f"⏭️ Source already present: {file}")
|
|
151
|
-
|
|
152
|
-
# profile_path_obj.write_text(profile, encoding="utf-8")
|
|
153
|
-
# console.print(Panel("✅ Shell profile updated with sources", title="[bold blue]Sources[/bold blue]", border_style="blue"))
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# def main_add_patches_to_shell_profile(profile_path: Optional[str], choice: Optional[str]) -> None:
|
|
157
|
-
# patches: list[str] = [item.as_posix() for item in PathExtended(LIBRARY_ROOT).joinpath(f"profile/patches/{system.lower()}").search()]
|
|
158
|
-
|
|
159
|
-
# console.print(Panel("🩹 Adding patches to shell profile", title="[bold blue]Patches[/bold blue]", border_style="blue"))
|
|
160
|
-
|
|
161
|
-
# if choice is None:
|
|
162
|
-
# choice_chosen = choose_from_options(msg="Which patch to add?", options=list(patches) + ["all", "none(EXIT)"], default="none(EXIT)", multi=False)
|
|
163
|
-
# assert isinstance(choice_chosen, str), f"Choice must be a string or a list of strings, not {type(choice)}"
|
|
164
|
-
# choice = choice_chosen
|
|
165
|
-
# if choice == "none(EXIT)":
|
|
166
|
-
# return None
|
|
167
|
-
# elif str(choice) == "all":
|
|
168
|
-
# console.print("📌 Adding all patches to profile")
|
|
169
|
-
# else:
|
|
170
|
-
# patches = [choice]
|
|
171
|
-
# console.print(f"📌 Adding selected patch: {choice}")
|
|
172
|
-
|
|
173
|
-
# profile_path_obj = PathExtended(profile_path) if isinstance(profile_path, str) else get_shell_profile_path()
|
|
174
|
-
# profile = profile_path_obj.read_text(encoding="utf-8")
|
|
175
|
-
|
|
176
|
-
# for patch_path in patches:
|
|
177
|
-
# patch_path_obj = PathExtended(patch_path)
|
|
178
|
-
# patch = patch_path_obj.read_text(encoding="utf-8")
|
|
179
|
-
# if patch in profile:
|
|
180
|
-
# console.print(f"⏭️ Patch already present: {patch_path_obj.name}")
|
|
181
|
-
# else:
|
|
182
|
-
# profile += "\n" + patch
|
|
183
|
-
# console.print(f"➕ Added patch: {patch_path_obj.name}")
|
|
184
|
-
|
|
185
|
-
# if system == "Linux":
|
|
186
|
-
# res = Terminal().run("cat /proc/version").op
|
|
187
|
-
# if "microsoft" in res.lower() or "wsl" in res.lower():
|
|
188
|
-
# profile += "\ncd ~" # this is to make sure that the current dir is not in the windows file system, which is terribly slow and its a bad idea to be there anyway.
|
|
189
|
-
# console.print("📌 WSL detected - adding 'cd ~' to profile to avoid Windows filesystem")
|
|
190
|
-
|
|
191
|
-
# profile_path_obj.write_text(profile, encoding="utf-8")
|
|
192
|
-
# console.print(Panel("✅ Shell profile updated with patches", title="[bold blue]Patches[/bold blue]", border_style="blue"))
|
|
101
|
+
def create_nu_shell_profile() -> None:
|
|
102
|
+
from rich.console import Console
|
|
103
|
+
from rich.panel import Panel
|
|
104
|
+
from machineconfig.utils.source_of_truth import CONFIG_ROOT
|
|
105
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
106
|
+
console = Console()
|
|
107
|
+
nu_profile_path = get_nu_shell_profile_path()
|
|
108
|
+
config_dir = nu_profile_path
|
|
109
|
+
config_file = config_dir.joinpath("config.nu")
|
|
110
|
+
if not config_dir.exists():
|
|
111
|
+
console.print(Panel(f"""🆕 NU SHELL CONFIG | Config directory does not exist at `{config_dir}`. Creating a new one.""", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
112
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
113
|
+
if not config_file.exists():
|
|
114
|
+
console.print(Panel(f"""🆕 NU SHELL CONFIG | config.nu file does not exist at `{config_file}`. Creating a new one.""", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
115
|
+
config_file.write_text("", encoding="utf-8")
|
|
116
|
+
config_content = config_file.read_text(encoding="utf-8")
|
|
117
|
+
from machineconfig.profile.create_helper import copy_assets_to_machine
|
|
118
|
+
copy_assets_to_machine("settings")
|
|
119
|
+
copy_assets_to_machine("scripts")
|
|
120
|
+
init_script = PathExtended(CONFIG_ROOT).joinpath("settings/shells/nushell/init.nu")
|
|
121
|
+
source_line = f"""use {str(init_script)}"""
|
|
122
|
+
was_config_updated = False
|
|
123
|
+
if source_line in config_content:
|
|
124
|
+
console.print(Panel("🔄 NU SHELL CONFIG | Skipping init script sourcing - already present in config.nu", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
125
|
+
else:
|
|
126
|
+
console.print(Panel("📝 NU SHELL CONFIG | Adding init script sourcing to config.nu", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
127
|
+
config_content += "\n" + source_line + "\n"
|
|
128
|
+
was_config_updated = True
|
|
129
|
+
if was_config_updated:
|
|
130
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
131
|
+
config_file.write_text(config_content, encoding="utf-8")
|
|
132
|
+
console.print(Panel("✅ Nu shell config updated successfully", title="[bold cyan]Nu Shell Config[/bold cyan]", border_style="cyan"))
|
|
193
133
|
|
|
194
134
|
|
|
195
135
|
if __name__ == "__main__":
|
|
@@ -100,11 +100,15 @@ config = {this = '~/.config/rofi/config.rasi', to_this = 'CONFIG_ROOT/settings/r
|
|
|
100
100
|
yazi = {this = '~/AppData/Roaming/yazi/config/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/yazi.toml'}
|
|
101
101
|
keymap = {this = '~/AppData/Roaming/yazi/config/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/keymap.toml'}
|
|
102
102
|
theme = {this = '~/AppData/Roaming/yazi/config/theme.toml', to_this = 'CONFIG_ROOT/settings/yazi/theme.toml'}
|
|
103
|
+
init = {this = '~/AppData/Roaming/yazi/config/init.lua', to_this = 'CONFIG_ROOT/settings/yazi/init.lua'}
|
|
104
|
+
|
|
105
|
+
|
|
103
106
|
|
|
104
107
|
[yazi_linux]
|
|
105
108
|
yazi = {this = '~/.config/yazi/yazi.toml', to_this = 'CONFIG_ROOT/settings/yazi/yazi.toml'}
|
|
106
109
|
keymap = {this = '~/.config/yazi/keymap.toml', to_this = 'CONFIG_ROOT/settings/yazi/keymap.toml'}
|
|
107
110
|
theme = {this = '~/.config/yazi/theme.toml', to_this = 'CONFIG_ROOT/settings/yazi/theme.toml'}
|
|
111
|
+
init = {this = '~/.config/yazi/init.lua', to_this = 'CONFIG_ROOT/settings/yazi/init.lua'}
|
|
108
112
|
|
|
109
113
|
[lf_windows]
|
|
110
114
|
config = {this = '~/AppData/Local/lf/lfrc', to_this = 'CONFIG_ROOT/settings/lf/windows/lfrc'}
|
|
@@ -27,7 +27,7 @@ wrap_in_shell_script() {
|
|
|
27
27
|
|
|
28
28
|
if [[ -f "$OP_PROGRAM_PATH" ]]; then
|
|
29
29
|
printf "%b\n" "${GREEN}🚀 Taking over from python script @ ${OP_PROGRAM_PATH}${RESET}"
|
|
30
|
-
bat --style=
|
|
30
|
+
bat --style=full --theme=OneHalfDark --paging=never "$OP_PROGRAM_PATH"
|
|
31
31
|
printf "%b\n" "${GREEN}▶ Running...${RESET}"
|
|
32
32
|
. "$OP_PROGRAM_PATH"
|
|
33
33
|
status=$?
|
|
@@ -130,7 +130,7 @@ def croshell(
|
|
|
130
130
|
fire_line = f"uv run --python 3.14 --with visidata,pyarrow vd {str(file_obj)}"
|
|
131
131
|
elif marimo:
|
|
132
132
|
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""--with marimo --project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
133
|
-
else: requirements = """--python 3.14 --with "marimo,machineconfig[plot]>=7.
|
|
133
|
+
else: requirements = """--python 3.14 --with "marimo,machineconfig[plot]>=7.40" """
|
|
134
134
|
fire_line = f"""
|
|
135
135
|
cd {str(pyfile.parent)}
|
|
136
136
|
uv run --python 3.14 --with "marimo" marimo convert {pyfile.name} -o marimo_nb.py
|
|
@@ -138,14 +138,14 @@ uv run {requirements} marimo edit --host 0.0.0.0 marimo_nb.py
|
|
|
138
138
|
"""
|
|
139
139
|
elif jupyter:
|
|
140
140
|
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""--project "{str(Path.home().joinpath("code/machineconfig"))}" --with jupyterlab """
|
|
141
|
-
else: requirements = """--with "machineconfig[plot]>=7.
|
|
141
|
+
else: requirements = """--with "machineconfig[plot]>=7.40" """
|
|
142
142
|
fire_line = f"uv run {requirements} jupyter-lab {str(nb_target)}"
|
|
143
143
|
elif vscode:
|
|
144
144
|
fire_line = f"""
|
|
145
145
|
cd {str(pyfile.parent)}
|
|
146
146
|
uv init --python 3.14
|
|
147
147
|
uv venv
|
|
148
|
-
uv add "machineconfig[plot]>=7.
|
|
148
|
+
uv add "machineconfig[plot]>=7.40"
|
|
149
149
|
# code serve-web
|
|
150
150
|
code --new-window {str(pyfile)}
|
|
151
151
|
"""
|
|
@@ -153,7 +153,7 @@ code --new-window {str(pyfile)}
|
|
|
153
153
|
if interpreter == "ipython": profile = f" --profile {ipython_profile} --no-banner"
|
|
154
154
|
else: profile = ""
|
|
155
155
|
if Path.home().joinpath("code/machineconfig").exists(): ve_line = f"""--project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
156
|
-
else: ve_line = """--python 3.14 --with "machineconfig[plot]>=7.
|
|
156
|
+
else: ve_line = """--python 3.14 --with "machineconfig[plot]>=7.40" """
|
|
157
157
|
# ve_path_maybe, ipython_profile_maybe = get_ve_path_and_ipython_profile(Path.cwd())
|
|
158
158
|
# --python 3.14
|
|
159
159
|
fire_line = f"uv run {ve_line} {interpreter} {interactivity} {profile} {str(pyfile)}"
|
|
@@ -5,10 +5,10 @@ Minimalist programs that only print scripts without frills so it can be sourced
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
import typer
|
|
8
|
-
import platform
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def define_scripts():
|
|
11
|
+
import platform
|
|
12
12
|
if platform.system() != "Linux":
|
|
13
13
|
raise RuntimeError("This command is only supported on Linux systems.")
|
|
14
14
|
from machineconfig.setup_linux import INTERACTIVE as script_path
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def machineconfig_lf():
|
|
6
|
+
# from machineconfig.scripts.python.helpers_msearch import FZFG_LINUX_PATH, FZFG_WINDOWS_PATH
|
|
7
|
+
import platform
|
|
8
|
+
if platform.system() == "Linux":
|
|
9
|
+
script = """
|
|
10
|
+
tmp="$(mktemp)"
|
|
11
|
+
lf -last-dir-path="$tmp" "$@"
|
|
12
|
+
if [ -f "$tmp" ]; then
|
|
13
|
+
dir="$(cat "$tmp")"
|
|
14
|
+
rm -f "$tmp"
|
|
15
|
+
if [ -d "$dir" ]; then
|
|
16
|
+
if [ "$dir" != "$(pwd)" ]; then
|
|
17
|
+
cd "$dir"
|
|
18
|
+
fi
|
|
19
|
+
fi
|
|
20
|
+
fi
|
|
21
|
+
"""
|
|
22
|
+
elif platform.system() == "Windows":
|
|
23
|
+
script = r"""
|
|
24
|
+
$tmp = [System.IO.Path]::GetTempFileName()
|
|
25
|
+
~\AppData\Local\Microsoft\WindowsApps\lf.exe -last-dir-path="$tmp" $args
|
|
26
|
+
if (Test-Path -PathType Leaf "$tmp")
|
|
27
|
+
{
|
|
28
|
+
$dir = Get-Content "$tmp"
|
|
29
|
+
Remove-Item -Force "$tmp"
|
|
30
|
+
if (Test-Path -PathType Container "$dir")
|
|
31
|
+
{
|
|
32
|
+
if ("$dir" -ne "$pwd")
|
|
33
|
+
{
|
|
34
|
+
Set-Location "$dir"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
"""
|
|
39
|
+
else:
|
|
40
|
+
raise RuntimeError("Unsupported platform")
|
|
41
|
+
|
|
42
|
+
from machineconfig.utils.code import exit_then_run_shell_script
|
|
43
|
+
exit_then_run_shell_script(script=script, strict=False)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
app = typer.Typer(add_completion=False, no_args_is_help=True)
|
|
48
|
+
app.command(name="lf", help="machineconfig lf wrapper.", no_args_is_help=False)(machineconfig_lf)
|
|
49
|
+
app()
|
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
from typing import Literal, Annotated
|
|
3
|
+
from typing import Literal, Annotated
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import typer
|
|
6
6
|
import machineconfig.scripts.python.helpers_devops.cli_config_dotfile as dotfile_module
|
|
7
|
+
import machineconfig.profile.create_links_export as create_links_export
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
def
|
|
10
|
-
on_conflict: Annotated[Literal["throw-error", "overwrite-self-managed", "backup-self-managed", "overwrite-default-path", "backup-default-path"], typer.Option(..., "--on-conflict", "-o", help="Action to take on conflict")] = "throw-error",
|
|
11
|
-
which: Annotated[Optional[str], typer.Option(..., "--which", "-w", help="Specific items to process")] = None,
|
|
12
|
-
interactive: Annotated[bool, typer.Option(..., "--interactive", "-ia", help="Run in interactive mode")] = False):
|
|
13
|
-
"""🔗 Manage private configuration files."""
|
|
14
|
-
import machineconfig.profile.create_links_export as create_links_export
|
|
15
|
-
create_links_export.main_private_from_parser(method=method, on_conflict=on_conflict, which=which, interactive=interactive)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def public(method: Annotated[Literal["symlink", "copy"], typer.Option(..., "--method", "-m", help="Method to use for setting up the config file.")],
|
|
19
|
-
on_conflict: Annotated[Literal["throw-error", "overwrite-default-path", "backup-default-path"], typer.Option(..., "--on-conflict", "-o", help="Action to take on conflict")] = "throw-error",
|
|
20
|
-
which: Annotated[Optional[str], typer.Option(..., "--which", "-w", help="Specific items to process")] = None,
|
|
21
|
-
interactive: Annotated[bool, typer.Option(..., "--interactive", "-ia", help="Run in interactive mode")] = False):
|
|
22
|
-
"""🔗 Manage public configuration files."""
|
|
23
|
-
import machineconfig.profile.create_links_export as create_links_export
|
|
24
|
-
create_links_export.main_public_from_parser(method=method, on_conflict=on_conflict, which=which, interactive=interactive)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def shell():
|
|
10
|
+
def shell(which: Annotated[Literal["default", "d", "nushell", "n"], typer.Option(..., "--which", "-w", help="Which shell profile to create/configure")]="default"):
|
|
28
11
|
"""🔗 Configure your shell profile."""
|
|
29
|
-
from machineconfig.profile.create_shell_profile import create_default_shell_profile
|
|
30
|
-
|
|
12
|
+
from machineconfig.profile.create_shell_profile import create_default_shell_profile, create_nu_shell_profile
|
|
13
|
+
match which:
|
|
14
|
+
case "nushell" | "n":
|
|
15
|
+
create_nu_shell_profile()
|
|
16
|
+
return
|
|
17
|
+
case "default" | "d":
|
|
18
|
+
create_default_shell_profile()
|
|
19
|
+
return
|
|
20
|
+
typer.echo(f"[red]Error:[/] Unknown shell profile type: {which}")
|
|
31
21
|
|
|
32
22
|
|
|
33
23
|
def path():
|
|
@@ -39,7 +29,7 @@ def path():
|
|
|
39
29
|
uv_with = ["textual"]
|
|
40
30
|
uv_project_dir = None
|
|
41
31
|
if not Path.home().joinpath("code/machineconfig").exists():
|
|
42
|
-
uv_with.append("machineconfig>=7.
|
|
32
|
+
uv_with.append("machineconfig>=7.40")
|
|
43
33
|
else:
|
|
44
34
|
uv_project_dir = str(Path.home().joinpath("code/machineconfig"))
|
|
45
35
|
run_shell_script(get_uv_command_executing_python_script(python_script=path.read_text(encoding="utf-8"), uv_with=uv_with, uv_project_dir=uv_project_dir)[0])
|
|
@@ -82,23 +72,29 @@ def starship_theme():
|
|
|
82
72
|
typer.echo("❌ Please enter a valid number")
|
|
83
73
|
|
|
84
74
|
|
|
85
|
-
def copy_assets(which: Annotated[Literal["scripts", "settings", "both"], typer.Argument(..., help="Which assets to copy")]):
|
|
75
|
+
def copy_assets(which: Annotated[Literal["scripts", "s", "settings", "t", "both", "b"], typer.Argument(..., help="Which assets to copy")]):
|
|
86
76
|
"""🔗 Copy asset files from library to machine."""
|
|
87
77
|
import machineconfig.profile.create_helper as create_helper
|
|
88
78
|
match which:
|
|
89
|
-
case "both":
|
|
79
|
+
case "both" | "b":
|
|
80
|
+
create_helper.copy_assets_to_machine(which="scripts")
|
|
81
|
+
create_helper.copy_assets_to_machine(which="settings")
|
|
82
|
+
return
|
|
83
|
+
case "scripts" | "s":
|
|
90
84
|
create_helper.copy_assets_to_machine(which="scripts")
|
|
85
|
+
return
|
|
86
|
+
case "settings" | "t":
|
|
91
87
|
create_helper.copy_assets_to_machine(which="settings")
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
return
|
|
89
|
+
typer.echo(f"[red]Error:[/] Unknown asset type: {which}")
|
|
94
90
|
|
|
95
91
|
|
|
96
92
|
def get_app():
|
|
97
93
|
config_apps = typer.Typer(help="⚙️ [c] configuration subcommands", no_args_is_help=True, add_help_option=False, add_completion=False)
|
|
98
|
-
config_apps.command("private", no_args_is_help=True, help="🔗 [v] Manage private configuration files.")(
|
|
99
|
-
config_apps.command("v", no_args_is_help=True, hidden=True)(
|
|
100
|
-
config_apps.command("public", no_args_is_help=True, help="🔗 [b] Manage public configuration files.")(
|
|
101
|
-
config_apps.command("b", no_args_is_help=True, help="Manage public configuration files.", hidden=True)(
|
|
94
|
+
config_apps.command("private", no_args_is_help=True, help="🔗 [v] Manage private configuration files.")(create_links_export.main_private_from_parser)
|
|
95
|
+
config_apps.command("v", no_args_is_help=True, hidden=True)(create_links_export.main_private_from_parser)
|
|
96
|
+
config_apps.command("public", no_args_is_help=True, help="🔗 [b] Manage public configuration files.")(create_links_export.main_public_from_parser)
|
|
97
|
+
config_apps.command("b", no_args_is_help=True, help="Manage public configuration files.", hidden=True)(create_links_export.main_public_from_parser)
|
|
102
98
|
config_apps.command("dotfile", no_args_is_help=True, help="🔗 [d] Manage dotfiles.")(dotfile_module.main)
|
|
103
99
|
config_apps.command("d", no_args_is_help=True, hidden=True)(dotfile_module.main)
|
|
104
100
|
config_apps.command("shell", no_args_is_help=False, help="🔗 [s] Configure your shell profile.")(shell)
|