Add PYTHONPATH to load custom python modules and
update ssh config for oci-arm
This commit is contained in:
parent
27d0e90036
commit
03987e23cb
@ -21,6 +21,9 @@ export PATH="$HOME/bin:$PATH"
|
|||||||
export PATH="$EWCONFIG_ROOT/scripts:$PATH"
|
export PATH="$EWCONFIG_ROOT/scripts:$PATH"
|
||||||
export PATH="$HOME/.local/bin:$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
|
# Configure a sane default editor
|
||||||
if type -p nvim > /dev/null; then
|
if type -p nvim > /dev/null; then
|
||||||
export EDITOR="nvim"
|
export EDITOR="nvim"
|
||||||
|
@ -84,5 +84,5 @@ Host td-prod td-prod2 td-prod3 td-prod4
|
|||||||
|
|
||||||
# Personal Infra
|
# Personal Infra
|
||||||
Host oci-arm
|
Host oci-arm
|
||||||
HostName oci-arm.ip.ewp.fyi
|
HostName oci-arm.vpn.ewp.fyi
|
||||||
User ubuntu
|
User ubuntu
|
||||||
|
47
scripts/sh2img
Executable file
47
scripts/sh2img
Executable file
@ -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())
|
Loading…
x
Reference in New Issue
Block a user