m
This commit is contained in:
+53
-4
@@ -7,12 +7,61 @@ def cli_decode(base64_encoded_script: str) -> str:
|
|||||||
def source_now(base64_encoded_script: str) -> str:
|
def source_now(base64_encoded_script: str) -> str:
|
||||||
return f"source <({cli_decode(base64_encoded_script)})"
|
return f"source <({cli_decode(base64_encoded_script)})"
|
||||||
|
|
||||||
better_env = r'''
|
# Color codes for bash prompt
|
||||||
|
def get_green_color() -> str:
|
||||||
|
"""Returns ANSI escape sequence for green text"""
|
||||||
|
return r"\[\e[0;32m\]"
|
||||||
|
|
||||||
|
def get_reset_color() -> str:
|
||||||
|
"""Returns ANSI escape sequence to reset color back to normal"""
|
||||||
|
return r"\[\e[0m\]"
|
||||||
|
|
||||||
|
# Get local IP address using hostname
|
||||||
|
def get_local_ip_command() -> str:
|
||||||
|
"""
|
||||||
|
Returns a command that gets the local IP address using hostname -I
|
||||||
|
which displays all network addresses of the host
|
||||||
|
"""
|
||||||
|
return r"hostname -I | awk '{print $1}'"
|
||||||
|
|
||||||
|
# Basic prompt components
|
||||||
|
def get_user_host() -> str:
|
||||||
|
"""Returns bash variables for username@hostname"""
|
||||||
|
return r"\u@\h"
|
||||||
|
|
||||||
|
def get_working_directory() -> str:
|
||||||
|
"""Returns bash variable for current working directory"""
|
||||||
|
return r"\w"
|
||||||
|
|
||||||
|
def get_prompt_symbol() -> str:
|
||||||
|
"""Returns the prompt symbol ($)"""
|
||||||
|
return r"\$"
|
||||||
|
|
||||||
|
# Construct the complete PS1 prompt
|
||||||
|
def build_ps1_prompt() -> str:
|
||||||
|
"""
|
||||||
|
Builds a colored bash prompt that shows:
|
||||||
|
- username@hostname in green
|
||||||
|
- local IP address in parentheses
|
||||||
|
- current working directory
|
||||||
|
- $ prompt symbol
|
||||||
|
- resets color after
|
||||||
|
"""
|
||||||
|
green = get_green_color()
|
||||||
|
reset = get_reset_color()
|
||||||
|
user_host = get_user_host()
|
||||||
|
local_ip_cmd = get_local_ip_command()
|
||||||
|
work_dir = get_working_directory()
|
||||||
|
prompt_symbol = get_prompt_symbol()
|
||||||
|
|
||||||
|
return f'{green}{user_host} ($({local_ip_cmd})):{work_dir}{prompt_symbol} {reset}'
|
||||||
|
|
||||||
|
better_env = f'''
|
||||||
export TERM=xterm
|
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="{build_ps1_prompt()}"
|
||||||
|
|
||||||
# Tail the last modified file in current directory
|
# Tail the last modified file in current directory
|
||||||
alias tl='_tl_func() {
|
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);
|
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
|
if [ -n "$LAST_MODIFIED_FILE" ]; then
|
||||||
echo "Tailing: \"$LAST_MODIFIED_FILE\"";
|
echo "Tailing: \"$LAST_MODIFIED_FILE\"";
|
||||||
@@ -20,7 +69,7 @@ alias tl='_tl_func() {
|
|||||||
else
|
else
|
||||||
echo "No files found in the current directory to tail.";
|
echo "No files found in the current directory to tail.";
|
||||||
fi
|
fi
|
||||||
}; _tl_func'
|
}}; _tl_func'
|
||||||
|
|
||||||
echo "Bash customizations sourced successfully!"
|
echo "Bash customizations sourced successfully!"
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user