c
This commit is contained in:
+3
-12
@@ -7,22 +7,13 @@ def cli_decode(base64_encoded_script: str) -> str:
|
||||
def source_now(base64_encoded_script: str) -> str:
|
||||
return f"source <({cli_decode(base64_encoded_script)})"
|
||||
|
||||
better_env = """
|
||||
better_env = r'''
|
||||
export TERM=xterm
|
||||
export PS1="\[\e[0;32m\]\u@\h (\$(ip route get 8.8.8.8 | sed -n '/src/{s/.*src \([^ ]*\).*/\\1/p;q}')):\w\$ \[\e[0m\]"
|
||||
export PS1="\[\e[0;32m\]\u@\h (\$(ip route get 8.8.8.8 | sed -n '/src/{s/.*src \([^ ]*\).*/\1/p;q}')):\w\$ \[\e[0m\]"
|
||||
|
||||
alias tl='_tl_func() {
|
||||
LAST_MODIFIED_FILE=$(find . -maxdepth 1 -type f -printf "%T@ %p\\0" | sort -znr | head -zn1 | cut -d" " -f2- --zero-terminated);
|
||||
if [ -n "$LAST_MODIFIED_FILE" ]; then
|
||||
echo "Tailing: "$LAST_MODIFIED_FILE";
|
||||
tail -f "$LAST_MODIFIED_FILE" "$@";
|
||||
else
|
||||
echo "No files found in the current directory to tail.";
|
||||
fi
|
||||
}; _tl_func'
|
||||
|
||||
echo "Bash customizations sourced successfully!"
|
||||
"""
|
||||
'''
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import gzip
|
||||
import pyperclip
|
||||
import io
|
||||
import base64
|
||||
from . import utils
|
||||
from . import better_bash
|
||||
|
||||
console = Console()
|
||||
|
||||
@@ -94,6 +96,30 @@ def decode_dir(
|
||||
console.print(f"[red]An unexpected error occurred during decode: {e}[/red]")
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
@wrap_app.command("env", short_help="Compress and encode bash environment script for sourcing.")
|
||||
def env():
|
||||
"""
|
||||
Compresses the bash environment script and copies a source command to clipboard.
|
||||
"""
|
||||
console.print("[blue]Compressing bash environment script...[/blue]")
|
||||
|
||||
try:
|
||||
# Compress and encode the better_env script
|
||||
compressed_encoded = utils.compress_and_encode(better_bash.better_env)
|
||||
|
||||
# Create the source command
|
||||
source_command = better_bash.source_now(compressed_encoded)
|
||||
|
||||
# Copy to clipboard
|
||||
pyperclip.copy(source_command)
|
||||
|
||||
console.print("[green]Source command copied to clipboard![/green]")
|
||||
console.print(f"[dim]Command: {source_command}[/dim]")
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"[red]An unexpected error occurred: {e}[/red]")
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
# Add the encode subcommand to the wrap app
|
||||
wrap_app.add_typer(encode_app, name="encode")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user