improved automatic script alias creation and switched to lookup paths for nix-shell invocations
This commit is contained in:
parent
41a1a6a5f5
commit
209294075c
7 changed files with 21 additions and 10 deletions
|
@ -128,13 +128,26 @@ alias_dictionary = {
|
|||
"s": "sudo",
|
||||
}
|
||||
|
||||
# Create aliases for scripts with the .py extension stripped
|
||||
# Create aliases for scripts with the file extension stripped
|
||||
script_path = Path("/etc/nixos/scripts")
|
||||
if script_path.exists():
|
||||
for script in script_path.glob("*.py"):
|
||||
if script.name == "__init__.py":
|
||||
for sub_dir in script_path.iterdir():
|
||||
# ignore files within the nix subdirectory, since they are just nix-shell expressions
|
||||
# if you aren't using nix, you can remove this if statement
|
||||
if sub_dir.name == "nix":
|
||||
continue
|
||||
script_name = script.name.strip(".py")
|
||||
aliases.update({script_name: [str(script)]})
|
||||
if not sub_dir.is_dir():
|
||||
c = colors.Colors
|
||||
print(f"{c.YELLOW}{c.BOLD}WARNING: The path {c.PURPLE}'{sub_dir}'{c.YELLOW} is not a directory. Skipping alias creation for this path.{c.END}")
|
||||
continue
|
||||
|
||||
extension = f".{sub_dir.name}"
|
||||
|
||||
for script in sub_dir.glob(f"*{extension}"):
|
||||
if script.name == "__init__.py":
|
||||
continue
|
||||
|
||||
script_name = script.stem
|
||||
aliases[script_name] = [str(script)]
|
||||
|
||||
aliases.update(alias_dictionary)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue