minor
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# snippet to parse args in apply-color scripts
|
# snippet for apply-color scripts
|
||||||
|
|
||||||
[ -z "$1" ] && exit 1
|
[ -z "$1" ] && exit 1
|
||||||
palette="$1"
|
palette="$1"
|
||||||
@@ -22,7 +22,8 @@ function color_ansi {
|
|||||||
local g=$((16#${colorHex:2:2}))
|
local g=$((16#${colorHex:2:2}))
|
||||||
local b=$((16#${colorHex:4:2}))
|
local b=$((16#${colorHex:4:2}))
|
||||||
|
|
||||||
echo "\033[38;2;${r};${g};${b}m"
|
# 24-bit true color ANSI escape code
|
||||||
|
printf "\033[38;2;%d;%d;%dm" $r $g $b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,32 @@ path=$(dirname "$(readlink -f "$0")")
|
|||||||
|
|
||||||
file="$path"/../posh_theme.omp.json
|
file="$path"/../posh_theme.omp.json
|
||||||
|
|
||||||
targetTypes='["os", "session", "status"]'
|
targetTypes=("os" "session" "status")
|
||||||
|
|
||||||
python3 <<EOF
|
if ! python3 - "$file" "$colorHex" "${targetTypes[@]}"; then {
|
||||||
|
log_error "Failed to edit ${file}"
|
||||||
|
exit 1
|
||||||
|
} fi <<EOF
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
data = None
|
data = None
|
||||||
|
file = sys.argv[1]
|
||||||
|
colorHex = sys.argv[2]
|
||||||
|
targetTypes = sys.argv[3:]
|
||||||
|
|
||||||
with open("$file", "r") as f:
|
with open(file, "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
def processSegments(segments):
|
def processSegments(segments):
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
if "type" in segment and segment["type"] in $targetTypes:
|
if "type" in segment and segment["type"] in targetTypes:
|
||||||
if "foreground" in segment:
|
if "foreground" in segment:
|
||||||
segment["foreground"] = "#$colorHex"
|
segment["foreground"] = f"#{colorHex}"
|
||||||
|
|
||||||
def processTransientPrompt(transientPrompt):
|
def processTransientPrompt(transientPrompt):
|
||||||
if "foreground" in transientPrompt:
|
if "foreground" in transientPrompt:
|
||||||
transientPrompt["foreground"] = "#$colorHex"
|
transientPrompt["foreground"] = f"#{colorHex}"
|
||||||
|
|
||||||
def process(obj):
|
def process(obj):
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
@@ -44,7 +50,7 @@ with open("$file", "r") as f:
|
|||||||
process(data)
|
process(data)
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
with open("$file", "w") as f:
|
with open(file, "w") as f:
|
||||||
json.dump(data, f, indent=4)
|
json.dump(data, f, indent=4)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user