diff --git a/configs/shells/zsh/.zshrc b/configs/shells/zsh/.zshrc index 26de500..0df886b 100644 --- a/configs/shells/zsh/.zshrc +++ b/configs/shells/zsh/.zshrc @@ -21,6 +21,9 @@ export PATH="$HOME/bin:$PATH" export PATH="$EWCONFIG_ROOT/scripts:$PATH" export PATH="$HOME/.local/bin:$PATH" +# I want to be able to load my custom python modules +export PYTHONPATH="$EWCONFIG_ROOT/python_modules:$PYTHONPATH" + # Configure a sane default editor if type -p nvim > /dev/null; then export EDITOR="nvim" diff --git a/configs/ssh/config b/configs/ssh/config index ab276b1..4758a3c 100644 --- a/configs/ssh/config +++ b/configs/ssh/config @@ -84,5 +84,5 @@ Host td-prod td-prod2 td-prod3 td-prod4 # Personal Infra Host oci-arm - HostName oci-arm.ip.ewp.fyi + HostName oci-arm.vpn.ewp.fyi User ubuntu diff --git a/scripts/sh2img b/scripts/sh2img new file mode 100755 index 0000000..126306a --- /dev/null +++ b/scripts/sh2img @@ -0,0 +1,47 @@ +#! /usr/bin/env python +import sys +import os +import subprocess +import argparse +from pathlib import Path +from rich.console import Console +from rich.syntax import Syntax +from datetime import datetime + +def main() -> int: + # Read the arguments + ap = argparse.ArgumentParser(prog="sh2img", description="Generate images from shell commands") + ap.add_argument("command", help="The command to execute", nargs="+") + ap.add_argument("--shell", "-s", help="The shell to use") + args = ap.parse_args() + + # Figure out if we are root + is_root = os.geteuid() == 0 + shell_char = "#" if is_root else "$" + + # Set up the console + console = Console(record=True) + + # Print out the arguments as a command being executed + console.print(f"{shell_char} {' '.join(args.command)}", style="white", highlight=False) + if args.shell: + args.command = [args.shell, "-c", " ".join(args.command)] + + # Execute the program, capturing all output together in one string + output = subprocess.run(args.command, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + output = output.stdout.decode("utf-8").strip() + + console.width = min(max(len(line) for line in output.splitlines()), 150) + + # Print the output + console.print(output, highlight=False) + + # Save to a file + out_file = Path("~/Pictures/sh2img").expanduser() / f"{datetime.now().timestamp()}.svg" + out_file.parent.mkdir(parents=True, exist_ok=True) + console.save_svg(out_file, title=args.command[0]) + + return 0 + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file