nercone-shell 0.2.7__py3-none-any.whl → 0.2.8__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.
nercone_shell/__main__.py CHANGED
@@ -30,13 +30,18 @@ NERSH_HISTORY_PATH = Path(os.environ.get("NERSH_HISTORY_PATH", str(Path(NERSH_PA
30
30
  NERSH_CONFIG: dict = {}
31
31
  NERSH_CONFIG_PATH = Path(os.environ.get("NERSH_CONFIG_PATH", str(Path(NERSH_PATH, "config.json"))))
32
32
  NERSH_CONFIG_DEFAULT: dict = {
33
- "show_version": True,
34
- "override_env": {
35
- "SHELL": f"{shutil.which('nersh')}"
33
+ "customization": {
34
+ "show_version": True,
35
+ "override_env": {
36
+ "SHELL": f"{shutil.which('nersh')}"
37
+ },
38
+ "autoruns": [
39
+ f"{Path(NERSH_PATH, 'autostart.sh')}"
40
+ ]
36
41
  },
37
- "autoruns": [
38
- f"{Path(NERSH_PATH, 'autostart.sh')}"
39
- ]
42
+ "compatibility": {
43
+ "report_invisible_characters": False
44
+ }
40
45
  }
41
46
 
42
47
  class NershCompleter:
@@ -158,8 +163,10 @@ def reset():
158
163
  def reload():
159
164
  global ENVIRONMENT
160
165
  load_config()
166
+ pwd = ENVIRONMENT.get("PWD")
161
167
  ENVIRONMENT |= os.environ
162
- ENVIRONMENT |= NERSH_CONFIG.get("override_env", {})
168
+ ENVIRONMENT |= {"PWD": pwd}
169
+ ENVIRONMENT |= NERSH_CONFIG.get("customization", {}).get("override_env", {})
163
170
 
164
171
  def load_config() -> dict:
165
172
  global NERSH_CONFIG
@@ -169,7 +176,7 @@ def load_config() -> dict:
169
176
  f.write(json.dumps(NERSH_CONFIG_DEFAULT, indent=4) + "\n")
170
177
  with NERSH_CONFIG_PATH.open("r") as f:
171
178
  NERSH_CONFIG |= json.loads(f.read())
172
- for p in NERSH_CONFIG.get("autoruns", []):
179
+ for p in NERSH_CONFIG.get("customization", {}).get("autoruns", []):
173
180
  if not Path(p).is_file():
174
181
  with Path(p).open("w") as f:
175
182
  f.write("\n")
@@ -261,9 +268,9 @@ def main() -> int:
261
268
  else:
262
269
  readline.parse_and_bind("tab: complete")
263
270
  readline.set_completer_delims(' \t\n;')
264
- if NERSH_CONFIG.get("show_version", True):
271
+ if NERSH_CONFIG.get("customization", {}).get("show_version", True):
265
272
  show_version()
266
- for p in NERSH_CONFIG.get("autoruns", []):
273
+ for p in NERSH_CONFIG.get("customization", {}).get("autoruns", []):
267
274
  if Path(p).is_file():
268
275
  with Path(p).open("r") as f:
269
276
  run_script(f.read())
@@ -275,8 +282,8 @@ def main() -> int:
275
282
  run_script(NERSH_AUTORUN)
276
283
  if NERSH_HISTORY_PATH.is_file():
277
284
  readline.read_history_file(NERSH_HISTORY_PATH)
278
- RL_PROMPT_START_IGNORE = '\001'
279
- RL_PROMPT_END_IGNORE = '\002'
285
+ RL_PROMPT_START_IGNORE = "\001" if NERSH_CONFIG.get("compatibility", {}).get("report_invisible_characters", False) else ""
286
+ RL_PROMPT_END_IGNORE = "\002" if NERSH_CONFIG.get("compatibility", {}).get("report_invisible_characters", False) else ""
280
287
  color_green = f"{RL_PROMPT_START_IGNORE}{ModernColor.color('green')}{RL_PROMPT_END_IGNORE}"
281
288
  color_reset = f"{RL_PROMPT_START_IGNORE}{ModernColor.color('reset')}{RL_PROMPT_END_IGNORE}"
282
289
  while True:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nercone-shell
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Modern shell for Developers
5
5
  Author: Nercone
6
6
  Author-email: Nercone <nercone@diamondgotcat.net>
@@ -60,3 +60,35 @@ pip3 install nercone-shell --upgrade --break-system-packages
60
60
  ```
61
61
  pip3 install nercone-shell --upgrade
62
62
  ```
63
+
64
+ ## Configuration
65
+ The configuration file is usually located at `~/.nercone/nercone-shell/config.json`.
66
+ If the file does not exist when Nersh starts, it will be automatically created.
67
+
68
+ The following is the default configuration file:
69
+ ```
70
+ {
71
+ "customization": {
72
+ "show_version": true,
73
+ "override_env": {
74
+ "SHELL": "None"
75
+ },
76
+ "autoruns": [
77
+ "<path to home directory>/.nercone/nercone-shell/autostart.sh"
78
+ ]
79
+ },
80
+ "compatibility": {
81
+ "report_invisible_characters": false
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Customization
87
+ These settings customize the behavior of Nersh.
88
+ - `show_version`: Sets whether to display version information at startup.
89
+ - `override_env`: Sets the environment variables you want to set at startup in dictionary format.
90
+ - `autoruns`: Sets the shell scripts you want to run at startup in array format.
91
+
92
+ ### Compatibility
93
+ This setting allows Nersh to function properly in special environments.
94
+ - `report_invisible_characters`: A Boolean value that enables reporting of invisible characters to readline, which is necessary in some environments, such as Linux without a GUI (TUI only).
@@ -0,0 +1,6 @@
1
+ nercone_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ nercone_shell/__main__.py,sha256=NSz6WNnNFaglY2x2E0-lacZXHhMVUpd1kVYLtNtvLKM,10435
3
+ nercone_shell-0.2.8.dist-info/WHEEL,sha256=YUH1mBqsx8Dh2cQG2rlcuRYUhJddG9iClegy4IgnHik,79
4
+ nercone_shell-0.2.8.dist-info/entry_points.txt,sha256=STrGlvrPc2Rr5ktWVfiZ_5Lr7i1GcfOMvsTxL6768sw,55
5
+ nercone_shell-0.2.8.dist-info/METADATA,sha256=waPwLosYQ2ilAlBP2_QMxdeliMHbOpcLv8AD7aM4H64,2438
6
+ nercone_shell-0.2.8.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- nercone_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- nercone_shell/__main__.py,sha256=5ItTAypPFb-AK94Eo_ZvglIjJrGiPYfWJrqK24N3IaI,9956
3
- nercone_shell-0.2.7.dist-info/WHEEL,sha256=YUH1mBqsx8Dh2cQG2rlcuRYUhJddG9iClegy4IgnHik,79
4
- nercone_shell-0.2.7.dist-info/entry_points.txt,sha256=STrGlvrPc2Rr5ktWVfiZ_5Lr7i1GcfOMvsTxL6768sw,55
5
- nercone_shell-0.2.7.dist-info/METADATA,sha256=8e4rcnmbxGpD1VUySdLSdeuKkyjHT_DeP0nxBA10m6Y,1286
6
- nercone_shell-0.2.7.dist-info/RECORD,,