-
-
Notifications
You must be signed in to change notification settings - Fork 765
Add theme: umu #735
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
UMU618
wants to merge
1
commit into
ohmybash:master
Choose a base branch
from
UMU618:master
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.
+145
−0
Open
Add theme: umu #735
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,141 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Base on pzq | ||
|
|
||
| OMB_PROMPT_CONDAENV_FORMAT='(%s)' | ||
| OMB_PROMPT_VIRTUALENV_FORMAT='(%s)' | ||
| OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} | ||
|
|
||
| # ----------------------------------------------------------------- COLOR CONF | ||
| D_DEFAULT_COLOR="$_omb_prompt_white" | ||
| D_INTERMEDIATE_COLOR="$_omb_prompt_bold_white" | ||
| D_NUMBER_COLOR="$_omb_prompt_bold_navy" | ||
| D_USER_COLOR="$_omb_prompt_teal" | ||
| D_SUPERUSER_COLOR="$_omb_prompt_brown" | ||
| D_MACHINE_COLOR="$_omb_prompt_green" | ||
| D_DIR_COLOR="$_omb_prompt_bold_olive" | ||
| D_GIT_DEFAULT_COLOR="$_omb_prompt_white" | ||
| D_GIT_BRANCH_COLOR="$_omb_prompt_teal" | ||
| D_GIT_PROMPT_COLOR="$_omb_prompt_brown" | ||
| D_SCM_COLOR="$_omb_prompt_bold_olive" | ||
| D_BRANCH_COLOR="$_omb_prompt_teal" | ||
| D_CHANGES_COLOR="$_omb_prompt_white" | ||
| D_TIME_COLOR="$_omb_prompt_white" | ||
| D_DOLLOR_COLOR="$_omb_prompt_bold_brown" | ||
| D_CMDFAIL_COLOR="$_omb_prompt_brown" | ||
| D_VIMSHELL_COLOR="$_omb_prompt_teal" | ||
|
|
||
| # ------------------------------------------------------------------ FUNCTIONS | ||
| case $TERM in | ||
| xterm*) | ||
| TITLEBAR='\[\e]0;\w\e\\\]' | ||
| ;; | ||
| *) | ||
| TITLEBAR="" | ||
| ;; | ||
| esac | ||
|
|
||
| function is_vim_shell { | ||
| if [[ ${VIMRUNTIME-} ]]; then | ||
| _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " | ||
| fi | ||
| } | ||
|
|
||
| function mitsuhikos_lastcommandfailed { | ||
| local status=$? | ||
| if ((status != 0)); then | ||
| _omb_util_print " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$code ${D_DEFAULT_COLOR}" | ||
| fi | ||
| } | ||
|
|
||
| # vcprompt for scm instead of oh-my-bash default | ||
| function demula_vcprompt { | ||
| if [[ ${VCPROMPT_EXECUTABLE-} ]]; then | ||
| local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" | ||
| $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" | ||
| fi | ||
| } | ||
|
|
||
| # checks if the plugin is installed before calling battery_charge | ||
| function safe_battery_charge { | ||
| if _omb_util_function_exists battery_charge; then | ||
| battery_charge | ||
| fi | ||
| } | ||
|
|
||
| function prompt_git { | ||
| local branchName='' | ||
|
|
||
| # Check if the current directory is in a Git repository. | ||
| if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then | ||
| # Get the short symbolic ref. | ||
| # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit | ||
| # Otherwise, just give up. | ||
| branchName=$( | ||
| _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null || | ||
| _omb_prompt_git rev-parse --short HEAD 2> /dev/null || | ||
| _omb_util_print '(unknown)'); | ||
|
|
||
| _omb_util_print "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} " | ||
| else | ||
| return | ||
| fi | ||
| } | ||
|
|
||
| function limited_pwd { | ||
| # Max length of PWD to display | ||
| local MAX_PWD_LENGTH=20 | ||
|
|
||
| # Replace $HOME with ~ if possible | ||
| local RELATIVE_PWD=${PWD/#$HOME/\~} | ||
|
|
||
| local offset=$((${#RELATIVE_PWD}-MAX_PWD_LENGTH)) | ||
|
|
||
| if ((offset > 0)); then | ||
| local truncated_symbol='...' | ||
| local TRUNCATED_PWD=${RELATIVE_PWD:offset:MAX_PWD_LENGTH} | ||
| _omb_util_put "${truncated_symbol}/${TRUNCATED_PWD#*/}" | ||
| else | ||
| _omb_util_put "${RELATIVE_PWD}" | ||
| fi | ||
| } | ||
|
|
||
| # -------------------------------------------------------------- PROMPT OUTPUT | ||
| function _omb_theme_PROMPT_COMMAND { | ||
| local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) | ||
| local SAVE_CURSOR='\[\e7' | ||
| local RESTORE_CURSOR='\e8\]' | ||
| local MOVE_CURSOR_RIGHTMOST='\e['${COLUMNS:-9999}'C' | ||
| local MOVE_CURSOR_5_LEFT='\e[5D' | ||
| local THEME_CLOCK_FORMAT="%Y-%m-%dT%H:%M:%S.%N%:::z" | ||
| # Replace $HOME with ~ if possible | ||
| local RELATIVE_PWD=${PWD/#$HOME/\~} | ||
|
|
||
| local python_venv | ||
| _omb_prompt_get_python_venv | ||
|
|
||
| PS1=${TITLEBAR}$python_venv$'\n' | ||
| if [[ $OSTYPE == linux-gnu ]]; then | ||
| PS1+="${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}" | ||
| PS1+="$(safe_battery_charge)${RESTORE_CURSOR}" | ||
| PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}" | ||
|
Comment on lines
+106
to
+121
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. Battery output inside [] On Linux, the theme opens a Bash non-printing escape block (\[ ... \]) and inserts battery_charge output before closing it; since battery_charge prints visible glyphs, Bash will miscompute prompt length leading to wrapping/cursor glitches. Agent Prompt
|
||
| else | ||
| PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}" | ||
| fi | ||
| PS1+="@ ${D_MACHINE_COLOR}\h ${D_DEFAULT_COLOR}" | ||
| PS1+="${D_DIR_COLOR}${RELATIVE_PWD} ${D_INTERMEDIATE_COLOR}" | ||
| PS1+=$(prompt_git) | ||
| PS1+=${D_TIME_COLOR}[$(clock_prompt)] | ||
| PS1+=${LAST_COMMAND_FAILED} | ||
| PS1+=$(demula_vcprompt) | ||
| PS1+=$(is_vim_shell) | ||
| if [[ $OSTYPE != linux-gnu ]]; then | ||
| PS1+=$(safe_battery_charge) | ||
| fi | ||
| PS1+=$'\n'"${D_DOLLOR_COLOR}$ ${D_DEFAULT_COLOR}" | ||
|
|
||
| PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" | ||
| } | ||
|
|
||
| # Runs prompt (this bypasses oh-my-bash $PROMPT setting) | ||
| _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. Exit code uses $code
🐞 Bug✓ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools