feat(themes): add a new theme "shxll"#755
Conversation
Review Summary by QodoAdd shxll theme with advanced prompt features
WalkthroughsDescription• Introduces new "shxll" theme with lambda character prompt • Implements command execution time tracking and display • Adds git branch status with dirty state detection • Includes Python virtual environment display support • Updates theme documentation with shxll preview Diagramflowchart LR
A["shxll Theme Module"] --> B["Prompt Command Handler"]
B --> C["Clock Display"]
B --> D["Execution Time Tracking"]
B --> E["Git Status Integration"]
B --> F["Virtual Environment Display"]
E --> G["Branch & Dirty State"]
A --> H["Theme Documentation"]
File Changes1. themes/shxll/shxll.theme.sh
|
Code Review by Qodo
1. Unsupported printf time format
|
| _omb_theme_now() { | ||
| if [[ -n ${EPOCHREALTIME-} ]]; then | ||
| local sec frac | ||
| sec=${EPOCHREALTIME%%[.,]*} | ||
| frac=${EPOCHREALTIME#*[.,]} | ||
| frac=${frac:0:3} | ||
| printf '%s%03d' "$sec" "$((10#${frac:-0}))" | ||
| else | ||
| printf '%(%s%3N)T' -1 | ||
| fi | ||
| } | ||
|
|
||
| _omb_theme_print_clock() { | ||
| local clock_now | ||
| printf -v clock_now '%(%H:%M)T' -1 | ||
|
|
||
| if [[ $__omb_theme_force_clock -eq 1 || $clock_now != $__omb_theme_last_clock ]]; then | ||
| printf '\033[90m⌞ %s ⌟\033[0m\n' "$clock_now" | ||
| __omb_theme_last_clock="$clock_now" | ||
| fi |
There was a problem hiding this comment.
1. Unsupported printf time format 🐞 Bug ☼ Reliability
_omb_theme_now / _omb_theme_print_clock use the Bash printf '%(... )T' time formatter, which is not available on older Bash versions that Oh My Bash explicitly supports (>= 3.2). On those systems, the theme will emit printf errors and the prompt can break.
Agent Prompt
### Issue description
The theme uses Bash `printf '%(... )T'` time formatting as a fallback for timing and for the clock. This is not supported on Bash versions that OMB supports (>= 3.2), so the prompt can error/break.
### Issue Context
OMB’s entrypoint explicitly supports Bash 3.2+, so themes must not depend on `printf '%(... )T'`.
### Fix Focus Areas
- themes/shxll/shxll.theme.sh[25-44]
- oh-my-bash.sh[13-22]
### Implementation notes
- Keep the fast path using `EPOCHREALTIME` when present.
- Replace the `printf '%(... )T'` fallback with a portable method (e.g., seconds-only using `$SECONDS` or `date +%s`), and gate millisecond precision behind feature detection.
- Similarly replace `printf -v clock_now '%(%H:%M)T' -1` with `clock_now=$(date +%H:%M)` (or equivalent) to support Bash 3.2/macOS.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| _omb_theme_shxll_way_prompt_scm() { | ||
| if [[ $PWD == "$__omb_theme_last_pwd" ]]; then | ||
| printf '%s' "$__omb_theme_last_git_segment" | ||
| return | ||
| fi | ||
|
|
||
| local CHAR branch dirty color segment="" dirty_state="" | ||
| CHAR=$(scm_char) | ||
|
|
||
| if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then | ||
| branch=$(git_current_branch) | ||
| dirty_state=$(git status --porcelain 2>/dev/null) | ||
|
|
||
| if [[ -n "$dirty_state" ]]; then | ||
| color="${_omb_prompt_yellow}" | ||
| else | ||
| color="${_omb_prompt_blue}" | ||
| fi | ||
|
|
||
| segment=" ϟ ${color}${branch}${_omb_prompt_normal}" | ||
| fi | ||
|
|
||
| __omb_theme_last_pwd=$PWD | ||
| __omb_theme_last_git_segment=$segment | ||
| printf '%s' "$segment" | ||
| } |
There was a problem hiding this comment.
2. Scm segment goes stale 🐞 Bug ≡ Correctness
_omb_theme_shxll_way_prompt_scm caches the git segment solely by PWD and also calls scm_char without refreshing SCM, so the prompt can show outdated or incorrect SCM info (e.g., after `git checkout/dirty changes, or after cd` to a non-repo). This can mislead users because the prompt won’t reflect current repo state.
Agent Prompt
### Issue description
The SCM segment logic can become stale/incorrect because it caches output purely by `PWD` and it uses `scm_char` without ensuring SCM state is refreshed for the current directory.
### Issue Context
Users commonly change git state (checkout, add, commit) without changing directories, so a PWD-only cache makes the prompt wrong. Also, `scm_prompt_char` only runs `scm` when the global `SCM` is empty; this theme doesn’t otherwise refresh `SCM` per prompt.
### Fix Focus Areas
- themes/shxll/shxll.theme.sh[69-94]
- lib/omb-prompt-base.sh[120-138]
### Implementation notes
- Either remove the PWD cache entirely, or include additional cache keys (e.g., git HEAD + dirty flag) so the segment updates when state changes.
- Ensure SCM state is refreshed per prompt: call `scm` (or `scm_prompt_vars` / `scm_prompt_info`) before checking SCM.
- Prefer using OMB’s existing SCM helpers (`scm_prompt_vars` / `scm_prompt_info`) instead of directly calling `git status` so behavior is consistent across themes.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| local CHAR branch dirty color segment="" dirty_state="" | ||
| CHAR=$(scm_char) | ||
|
|
||
| if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then | ||
| branch=$(git_current_branch) | ||
| dirty_state=$(git status --porcelain 2>/dev/null) | ||
|
|
||
| if [[ -n "$dirty_state" ]]; then | ||
| color="${_omb_prompt_yellow}" | ||
| else | ||
| color="${_omb_prompt_blue}" | ||
| fi | ||
|
|
||
| segment=" ϟ ${color}${branch}${_omb_prompt_normal}" | ||
| fi | ||
|
|
There was a problem hiding this comment.
3. Ps1 branch injection 🐞 Bug ⛨ Security
The theme injects git_current_branch output directly into PS1 without sanitizing/escaping, so a malicious branch name containing $()/backticks/escapes can be evaluated when Bash expands the prompt. This reintroduces the PS1 interpolation vulnerability that OMB mitigates via git_clean_branch.
Agent Prompt
### Issue description
The theme uses `git_current_branch` and inserts its output into PS1 without escaping, enabling prompt injection if the branch name contains `$()`, backticks, or escape sequences.
### Issue Context
OMB already provides `git_clean_branch` explicitly to prevent this class of PS1 interpolation vulnerability.
### Fix Focus Areas
- themes/shxll/shxll.theme.sh[75-90]
- lib/git.sh[76-85]
- lib/omb-prompt-base.sh[182-190]
### Implementation notes
- Replace `branch=$(git_current_branch)` with a sanitized alternative:
- Prefer `branch=$(git_clean_branch)` (from `lib/omb-prompt-base.sh`) when in git.
- Or, escape the branch string before embedding into PS1 using `_omb_string_escape_prompt`.
- Ensure the final string inserted into `PS1` cannot trigger command substitution or backslash prompt escapes.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.