nercone-shell 0.3.7__tar.gz → 0.4.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nercone-shell
3
- Version: 0.3.7
3
+ Version: 0.4.0
4
4
  Summary: Modern shell for Developers
5
5
  Author: Nercone
6
6
  Author-email: Nercone <nercone@diamondgotcat.net>
@@ -68,7 +68,7 @@ nersh
68
68
  ```
69
69
 
70
70
  ## Configuration
71
- The configuration file is usually located at `~/.nercone/nercone-shell/config.json`.
71
+ The configuration file is usually located at `~/.nersh/config.json`.
72
72
  If the file does not exist when Nersh starts, it will be automatically created.
73
73
 
74
74
  The following is the default configuration file:
@@ -81,7 +81,7 @@ The following is the default configuration file:
81
81
  "SHELL": "None"
82
82
  },
83
83
  "autoruns": [
84
- "<path to home directory>/.nercone/nercone-shell/autostart.sh"
84
+ "<path to home directory>/.nersh/autostart.sh"
85
85
  ]
86
86
  },
87
87
  "compatibility": {
@@ -101,14 +101,17 @@ These settings customize the behavior of Nersh.
101
101
  - `autoruns`: Sets the shell scripts you want to run at startup in array format.
102
102
 
103
103
  ### Compatibility
104
- This setting allows Nersh to function properly in special environments.
104
+ These settings allows Nersh to function properly in special environments.
105
105
  - `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).
106
106
 
107
107
  ### Experimental
108
108
  The Experimental setting is used to enable experimental features.
109
109
  It enables new features that are incomplete, have many bugs, or have unfixable bugs.
110
110
  Some features are difficult to completely disable, so they are effectively disabled. (Bugs in external libraries/modules, etc.)
111
-
112
111
  - `command_history` The readline command history feature.
113
112
  - It was marked as an experimental feature because there were frequent issues with the layout collapsing when retracing the history.
114
113
  - Since cannot to find a way to disable the history feature in the readline module, it is effectively disabled by clearing the history after each input.
114
+
115
+ ---
116
+
117
+ ![PyPI - Version](https://img.shields.io/pypi/v/nercone-shell)
@@ -53,7 +53,7 @@ nersh
53
53
  ```
54
54
 
55
55
  ## Configuration
56
- The configuration file is usually located at `~/.nercone/nercone-shell/config.json`.
56
+ The configuration file is usually located at `~/.nersh/config.json`.
57
57
  If the file does not exist when Nersh starts, it will be automatically created.
58
58
 
59
59
  The following is the default configuration file:
@@ -66,7 +66,7 @@ The following is the default configuration file:
66
66
  "SHELL": "None"
67
67
  },
68
68
  "autoruns": [
69
- "<path to home directory>/.nercone/nercone-shell/autostart.sh"
69
+ "<path to home directory>/.nersh/autostart.sh"
70
70
  ]
71
71
  },
72
72
  "compatibility": {
@@ -86,14 +86,17 @@ These settings customize the behavior of Nersh.
86
86
  - `autoruns`: Sets the shell scripts you want to run at startup in array format.
87
87
 
88
88
  ### Compatibility
89
- This setting allows Nersh to function properly in special environments.
89
+ These settings allows Nersh to function properly in special environments.
90
90
  - `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).
91
91
 
92
92
  ### Experimental
93
93
  The Experimental setting is used to enable experimental features.
94
94
  It enables new features that are incomplete, have many bugs, or have unfixable bugs.
95
95
  Some features are difficult to completely disable, so they are effectively disabled. (Bugs in external libraries/modules, etc.)
96
-
97
96
  - `command_history` The readline command history feature.
98
97
  - It was marked as an experimental feature because there were frequent issues with the layout collapsing when retracing the history.
99
98
  - Since cannot to find a way to disable the history feature in the readline module, it is effectively disabled by clearing the history after each input.
99
+
100
+ ---
101
+
102
+ ![PyPI - Version](https://img.shields.io/pypi/v/nercone-shell)
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "nercone-shell"
7
- version = "0.3.7"
7
+ version = "0.4.0"
8
8
  description = "Modern shell for Developers"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  authors = [
@@ -28,10 +28,10 @@ except AttributeError:
28
28
  try:
29
29
  VERSION: str = version("nercone-shell")
30
30
  except PackageNotFoundError:
31
- VERSION: str = "0.0.0"
31
+ VERSION: str = "(version unknown)"
32
32
  ENVIRONMENT: dict = {}
33
- NERSH_AUTORUN: str = os.environ.get("NERSH_AUTORUN", None)
34
- NERSH_PATH = Path(os.environ.get("NERSH_PATH", str(Path(Path("~").expanduser(), ".nercone", "nercone-shell"))))
33
+ NERSH_AUTORUN: str | None = os.environ.get("NERSH_AUTORUN", None)
34
+ NERSH_PATH = Path(os.environ.get("NERSH_PATH", str(Path(Path("~").expanduser(), ".nersh"))))
35
35
  NERSH_HISTORY_PATH = Path(os.environ.get("NERSH_HISTORY_PATH", str(Path(NERSH_PATH, "history.txt"))))
36
36
  NERSH_CONFIG: dict = {}
37
37
  NERSH_CONFIG_PATH = Path(os.environ.get("NERSH_CONFIG_PATH", str(Path(NERSH_PATH, "config.json"))))
@@ -40,10 +40,10 @@ NERSH_CONFIG_DEFAULT: dict = {
40
40
  "show_version": True,
41
41
  "accent_color": "blue",
42
42
  "override_env": {
43
- "SHELL": f"{shutil.which('nersh')}"
43
+ "SHELL": f"{shutil.which('nersh') or 'nersh'}"
44
44
  },
45
- "autoruns": [
46
- f"{Path(NERSH_PATH, 'autostart.sh')}"
45
+ "autorun": [
46
+ f"{Path(NERSH_PATH, 'autorun.sh')}"
47
47
  ]
48
48
  },
49
49
  "compatibility": {
@@ -162,11 +162,11 @@ def shorten_path(path: str) -> str:
162
162
  return path_str
163
163
 
164
164
  def show_version():
165
- print(f"Nersh v{VERSION}")
165
+ print(f"Nersh {VERSION}")
166
166
 
167
167
  def reset():
168
168
  global ENVIRONMENT, NERSH_CONFIG
169
- ENVIRONMENT = {"PWD": f"{Path(Path("~").expanduser())}"}
169
+ ENVIRONMENT = {"PWD": f"{Path('~').expanduser()}"}
170
170
  NERSH_CONFIG = {}
171
171
  reload()
172
172
 
@@ -202,14 +202,17 @@ def run_line(command: str) -> int:
202
202
  cmd = args[0]
203
203
  if cmd == "version":
204
204
  show_version()
205
+ return 0
205
206
  elif cmd == "reset":
206
207
  reset()
208
+ return 0
207
209
  elif cmd == "reload":
208
210
  reload()
211
+ return 0
209
212
  elif cmd == "cd":
210
213
  target = " ".join(args[1:])
211
214
  if not target:
212
- ENVIRONMENT["PWD"] = f"{Path("~").expanduser()}"
215
+ ENVIRONMENT["PWD"] = f"{Path('~').expanduser()}"
213
216
  target = os.path.expanduser(target)
214
217
  target_path = Path(target)
215
218
  if not target_path.is_absolute():
@@ -218,12 +221,16 @@ def run_line(command: str) -> int:
218
221
  resolved_path = target_path.resolve()
219
222
  if resolved_path.is_dir():
220
223
  ENVIRONMENT["PWD"] = str(resolved_path)
224
+ return 0
221
225
  elif resolved_path.exists():
222
226
  print(f"Not a directory: {target}")
227
+ return 1
223
228
  else:
224
229
  print(f"Not exist: {target}")
230
+ return 1
225
231
  except FileNotFoundError:
226
232
  print(f"Not exist: {target}")
233
+ return 1
227
234
  elif cmd == "export":
228
235
  content = command.strip()[6:].strip()
229
236
  if "=" in content:
@@ -235,6 +242,7 @@ def run_line(command: str) -> int:
235
242
  if not content:
236
243
  for k, v in ENVIRONMENT.items():
237
244
  print(f"{k}={v}")
245
+ return 0
238
246
  elif cmd == "source" or cmd == ".":
239
247
  if len(args) < 2:
240
248
  print(f"{cmd}: filename argument required")
@@ -242,7 +250,7 @@ def run_line(command: str) -> int:
242
250
  target = args[1]
243
251
  target_path = Path(os.path.expanduser(target))
244
252
  if not target_path.is_absolute():
245
- target_path = Path(ENVIRONMENT.get("PWD")) / target_path
253
+ target_path = Path(ENVIRONMENT.get("PWD", Path("~").expanduser())) / target_path
246
254
  if target_path.is_file():
247
255
  try:
248
256
  with target_path.open("r") as f:
@@ -255,6 +263,7 @@ def run_line(command: str) -> int:
255
263
  else:
256
264
  print(f"nersh: {target}: No such file")
257
265
  return 1
266
+ return 0
258
267
  elif cmd == "exit":
259
268
  if NERSH_CONFIG.get("experimental", {}).get("command_history", False):
260
269
  readline.write_history_file(str(NERSH_HISTORY_PATH))
@@ -270,18 +279,18 @@ def run_script(script: str):
270
279
  for line in script.split('\n'):
271
280
  run_line(line)
272
281
 
273
- def main() -> int:
282
+ def main():
274
283
  reset()
275
284
  completer = NershCompleter()
276
285
  readline.set_completer(completer.complete)
277
- if 'libedit' in readline.__doc__:
286
+ if 'libedit' in str(readline.__doc__):
278
287
  readline.parse_and_bind("bind ^I rl_complete")
279
288
  else:
280
289
  readline.parse_and_bind("tab: complete")
281
290
  readline.set_completer_delims(' \t\n;')
282
291
  if NERSH_CONFIG.get("customization", {}).get("show_version", True):
283
292
  show_version()
284
- for p in NERSH_CONFIG.get("customization", {}).get("autoruns", []):
293
+ for p in NERSH_CONFIG.get("customization", {}).get("autorun", []):
285
294
  if Path(p).is_file():
286
295
  with Path(p).open("r") as f:
287
296
  run_script(f.read())
@@ -297,9 +306,9 @@ def main() -> int:
297
306
  try:
298
307
  RL_PROMPT_START_IGNORE = "\001" if NERSH_CONFIG.get("compatibility", {}).get("report_invisible_characters", False) else ""
299
308
  RL_PROMPT_END_IGNORE = "\002" if NERSH_CONFIG.get("compatibility", {}).get("report_invisible_characters", False) else ""
300
- color_accent = f"{RL_PROMPT_START_IGNORE}{ModernColor.color(NERSH_CONFIG.get('customization', {}).get('accent_color', 'blue'))}{RL_PROMPT_END_IGNORE}"
301
- color_reset = f"{RL_PROMPT_START_IGNORE}{ModernColor.color('reset')}{RL_PROMPT_END_IGNORE}"
302
- run_line(input(f"{color_accent}{getpass.getuser().lower()}{color_reset}@{hostname.lower()} {color_accent}{shorten_path(ENVIRONMENT.get('PWD', f'{Path('~').expanduser()}'))}{color_reset}> "))
309
+ color_accent = f"{RL_PROMPT_START_IGNORE}{ModernColor.from_name(NERSH_CONFIG.get('customization', {}).get('accent_color', 'blue'))}{RL_PROMPT_END_IGNORE}"
310
+ color_reset = f"{RL_PROMPT_START_IGNORE}{ModernColor.from_name('reset')}{RL_PROMPT_END_IGNORE}"
311
+ run_line(input(f"{color_accent}{getpass.getuser().lower()}{color_reset}@{hostname.lower()} {color_accent}{shorten_path(ENVIRONMENT.get('PWD', str(Path('~').expanduser())))}{color_reset}> "))
303
312
  if not NERSH_CONFIG.get("experimental", {}).get("command_history", False):
304
313
  readline.clear_history()
305
314
  except KeyboardInterrupt: