-
-
Notifications
You must be signed in to change notification settings - Fork 780
feat(themes): add a new theme "shxll" #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pwnfo
wants to merge
1
commit into
ohmybash:master
Choose a base branch
from
pwnfo:add-shxll-theme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| #! bash oh-my-bash.module | ||
|
|
||
| SHXLL_CHAR="λ" | ||
|
|
||
| __omb_theme_cmd_started=0 | ||
| __omb_theme_cmd_start=0 | ||
| __omb_theme_cmd_armed=1 | ||
| __omb_theme_prev_debug_trap="" | ||
|
|
||
| __omb_theme_last_clock="" | ||
| __omb_theme_force_clock=1 | ||
|
|
||
| __omb_theme_in_prompt=0 | ||
| __omb_theme_last_venv="" | ||
| __omb_theme_cached_venv="" | ||
|
|
||
| __omb_theme_prev_debug_trap_src="$(trap -p DEBUG)" | ||
| if [[ $__omb_theme_prev_debug_trap_src =~ ^trap\ --\ \'(.*)\'\ DEBUG$ ]]; then | ||
| __omb_theme_prev_debug_trap="${BASH_REMATCH[1]}" | ||
| fi | ||
| unset __omb_theme_prev_debug_trap_src | ||
|
|
||
| _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' -1x | ||
| fi | ||
| } | ||
|
|
||
| _omb_theme_print_clock() { | ||
| local clock_now | ||
| clock_now=$(date +%H:%M) | ||
|
|
||
| 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 | ||
|
|
||
| __omb_theme_force_clock=0 | ||
| } | ||
|
|
||
| _omb_theme_debug_trap() { | ||
| [[ $__omb_theme_in_prompt -eq 1 ]] && return | ||
|
|
||
| if [[ $BASH_COMMAND == clear || $BASH_COMMAND == reset || $BASH_COMMAND == cls ]]; then | ||
| __omb_theme_force_clock=1 | ||
| fi | ||
|
|
||
| if [[ $__omb_theme_cmd_armed -eq 1 && $__omb_theme_cmd_started -eq 0 ]]; then | ||
| __omb_theme_cmd_start=$(_omb_theme_now) | ||
| __omb_theme_cmd_started=1 | ||
| __omb_theme_cmd_armed=0 | ||
| fi | ||
|
|
||
| if [[ -n $__omb_theme_prev_debug_trap ]]; then | ||
| eval -- "$__omb_theme_prev_debug_trap" | ||
| fi | ||
| } | ||
|
|
||
| trap '_omb_theme_debug_trap' DEBUG | ||
|
|
||
| _omb_theme_shxll_way_prompt_scm() { | ||
| local CHAR branch dirty color | ||
| CHAR=$(scm_char) | ||
|
|
||
| if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then | ||
| branch=$(git_clean_branch) | ||
| dirty=$(git status --porcelain 2>/dev/null) | ||
|
|
||
| if [[ -n "$dirty" ]]; then | ||
| color="${_omb_prompt_yellow}" | ||
| else | ||
| color="${_omb_prompt_blue}" | ||
| fi | ||
|
|
||
| printf '%s' " ϟ ${color}${branch}${_omb_prompt_normal}" | ||
| fi | ||
| } | ||
|
Comment on lines
+67
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Scm segment goes stale _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
|
||
|
|
||
| _omb_theme_get_venv() { | ||
| local venv=${VIRTUAL_ENV-} | ||
| if [[ $venv == "$__omb_theme_last_venv" ]]; then | ||
| printf '%s' "$__omb_theme_cached_venv" | ||
| return | ||
| fi | ||
|
|
||
| local out="" | ||
| _omb_prompt_get_python_venv | ||
| out=$python_venv | ||
|
|
||
| __omb_theme_last_venv=$venv | ||
| __omb_theme_cached_venv=$out | ||
| printf '%s' "$out" | ||
| } | ||
|
|
||
| function _omb_theme_PROMPT_COMMAND { | ||
| local exit_code=$? | ||
| local scm_segment="" | ||
| local python_venv="" | ||
| local ps_username="" | ||
| local ps_path="" | ||
| local ps_user_mark="" | ||
| local status="" | ||
| local time_str="" | ||
|
|
||
| __omb_theme_in_prompt=1 | ||
|
|
||
| _omb_theme_print_clock | ||
|
|
||
| if [[ $__omb_theme_cmd_started -eq 1 ]]; then | ||
| local now elapsed_ms | ||
| now=$(_omb_theme_now) | ||
| elapsed_ms=$((now - __omb_theme_cmd_start)) | ||
|
|
||
| if ((elapsed_ms > 500)); then | ||
| time_str="${_omb_prompt_gray}${elapsed_ms}ms${_omb_prompt_normal} " | ||
| fi | ||
| fi | ||
|
|
||
| __omb_theme_cmd_started=0 | ||
|
|
||
| python_venv=$(_omb_theme_get_venv) | ||
| scm_segment=$(_omb_theme_shxll_way_prompt_scm) | ||
|
|
||
| ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}" | ||
| ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}" | ||
| ps_user_mark="${_omb_prompt_red}${SHXLL_CHAR}${_omb_prompt_normal}" | ||
|
|
||
| if [[ $exit_code -ne 0 ]]; then | ||
| status="${_omb_prompt_red}(${exit_code})${_omb_prompt_normal} " | ||
| fi | ||
|
|
||
| PS1="$python_venv$ps_username:$ps_path$scm_segment $time_str$status$ps_user_mark " | ||
|
|
||
| __omb_theme_cmd_armed=1 | ||
| __omb_theme_in_prompt=0 | ||
| } | ||
|
|
||
| OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:-false} | ||
| OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_olive}(%s)${_omb_prompt_reset_color} " | ||
|
|
||
| _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Unsupported printf time format
🐞 Bug☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools