-
-
Notifications
You must be signed in to change notification settings - Fork 761
add new theme pino #721
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
Tealk
wants to merge
7
commits into
ohmybash:master
Choose a base branch
from
Tealk:feature/theme_pino
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
add new theme pino #721
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dd7e4d1
add(theme)pino
Tealk 15c33f7
fix Unsafe file sourcing
Tealk dc5447e
fix Explicitly handle function failure exit codes
Tealk 26e1c1c
switch to framework container function
Tealk cb69479
add time
Tealk 79c43b9
use _omb_prompt_get_python_venv
Tealk 6576043
added suggestion
Tealk 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,145 @@ | ||
| #! bash oh-my-bash.module | ||
|
|
||
| SCM_THEME_PROMPT_PREFIX="${_omb_prompt_bold_red}" | ||
| SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_normal}" | ||
| SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_red}✗${_omb_prompt_normal}" | ||
| SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" | ||
| SCM_GIT_CHAR="" | ||
| OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} | ||
| OMB_PROMPT_VIRTUALENV_FORMAT=" ${_omb_prompt_bold_purple}(%s)${_omb_prompt_normal}" | ||
| OMB_PROMPT_CONDAENV_FORMAT=" ${_omb_prompt_bold_purple}(%s)${_omb_prompt_normal}" | ||
|
|
||
| # ICONS ======================================================================= | ||
|
|
||
| icon_start="${_omb_prompt_bold_purple}╭─${_omb_prompt_normal}" | ||
| icon_middle="${_omb_prompt_bold_purple}├─${_omb_prompt_normal}" | ||
| icon_end="${_omb_prompt_bold_purple}╰─${_omb_prompt_normal}" | ||
| icon_prompt="${_omb_prompt_bold_purple}>_${_omb_prompt_normal}" | ||
|
|
||
| # FUNCTIONS =================================================================== | ||
|
|
||
| scm_prompt() { | ||
| printf 'on %s' "$(scm_prompt_info)" | ||
| } | ||
|
|
||
| segment_distro() { | ||
| local dbx_name="$1" | ||
| [[ -r /etc/os-release ]] || return 0 | ||
|
|
||
| local NAME VERSION_ID | ||
|
|
||
| while IFS='=' read -r key value; do | ||
| value="${value#\"}" | ||
| value="${value%\"}" | ||
| value="${value#\'}" | ||
| value="${value%\'}" | ||
|
|
||
| case "${key}" in | ||
| NAME) | ||
| NAME="${value}" | ||
| ;; | ||
| VERSION_ID) | ||
| VERSION_ID="${value}" | ||
| ;; | ||
| esac | ||
| done < <(grep -E '^(NAME|VERSION_ID)=' /etc/os-release 2>/dev/null) | ||
|
|
||
| local name="${NAME:-Linux}" | ||
| local ver="${VERSION_ID:-}" | ||
|
|
||
| name="${name%% *}" | ||
|
|
||
| local dbx_norm name_norm ver_norm | ||
| dbx_norm="${dbx_name//[^[:alnum:]]/}" | ||
| dbx_norm="${dbx_norm,,}" | ||
| name_norm="${name//[^[:alnum:]]/}" | ||
| name_norm="${name_norm,,}" | ||
| ver_norm="${ver//[^[:alnum:]]/}" | ||
| ver_norm="${ver_norm,,}" | ||
|
|
||
| local out="" | ||
|
|
||
| if [[ -n ${dbx_name} && ${dbx_norm} == *"${name_norm}"* ]]; then | ||
| if [[ -n ${ver} && ${dbx_norm} != *"${ver_norm}"* ]]; then | ||
| out="${_omb_prompt_bold_teal}${ver}${_omb_prompt_normal}" | ||
| fi | ||
| else | ||
| if [[ -n ${ver} ]]; then | ||
| out="${_omb_prompt_bold_teal}${name} ${ver}${_omb_prompt_normal}" | ||
| else | ||
| out="${_omb_prompt_bold_teal}${name}${_omb_prompt_normal}" | ||
| fi | ||
| fi | ||
|
|
||
| [[ -n ${out} ]] && printf '%s' "${out}" | ||
| } | ||
|
|
||
| # PROMPT OUTPUT =============================================================== | ||
|
|
||
| _omb_theme_PROMPT_COMMAND() { | ||
| local seg_user="${_omb_prompt_bold_navy}\u${_omb_prompt_normal}" | ||
| local seg_host="${_omb_prompt_bold_olive}\h${_omb_prompt_normal}" | ||
|
|
||
| local python_venv; _omb_prompt_get_python_venv | ||
|
|
||
| local seg_path=" ${_omb_prompt_bold_green}\w${_omb_prompt_normal}" | ||
|
|
||
| local left_side="${icon_start}${seg_user}@${seg_host}:${python_venv}${seg_path}" | ||
|
|
||
| local save_cursor='\001\033[s\002' | ||
| local move_right='\001\033[9999C\002' | ||
| local restore_cursor='\001\033[u\002' | ||
| local move_left_8='\001\033[8D\002' | ||
|
|
||
| local time_str="${_omb_prompt_bold_cyan}\t${_omb_prompt_normal}" | ||
|
|
||
| # Headline | ||
| local line_header="${left_side}${save_cursor}${move_right}${move_left_8}${time_str}${restore_cursor}\n" | ||
|
|
||
| # Distrobox (optional) | ||
| local container_name="" | ||
| local detection_method="" | ||
|
|
||
| if [[ -n ${DISTROBOX_NAME:-} ]]; then | ||
| container_name="${DISTROBOX_NAME}" | ||
| detection_method="DISTROBOX_NAME" | ||
| elif [[ -n ${DBX_CONTAINER_NAME:-} ]]; then | ||
| container_name="${DBX_CONTAINER_NAME}" | ||
| detection_method="DBX_CONTAINER_NAME" | ||
| elif [[ -r /run/.containerenv ]]; then | ||
| container_name=$(awk -F= '$1=="name"{gsub(/"/,"",$2); print $2}' /run/.containerenv 2>/dev/null) | ||
| detection_method="containerenv" | ||
| elif [[ -f /.dockerenv ]]; then | ||
| container_name=$(hostname 2>/dev/null) | ||
| detection_method="dockerenv" | ||
| fi | ||
|
|
||
| local line_container="" | ||
| if [[ -n ${container_name} ]]; then | ||
| local seg_distro="" | ||
| seg_distro=$(segment_distro "${container_name}") | ||
|
|
||
| line_container="${icon_middle}${_omb_prompt_bold_purple}container:${_omb_prompt_normal} ${_omb_prompt_bold_teal}${container_name}${_omb_prompt_normal}" | ||
|
|
||
| if [[ -n ${seg_distro} ]]; then | ||
| line_container+=" ${seg_distro}" | ||
| fi | ||
|
|
||
| line_container+=$'\n' | ||
| fi | ||
|
|
||
| # VCS/Git (optional) | ||
| local scm_char | ||
| scm_char=$(scm_char) | ||
| local line_vcs="" | ||
|
|
||
| if [[ ${scm_char} != "${SCM_NONE_CHAR}" ]]; then | ||
| line_vcs="${icon_middle}$(scm_prompt)\n" | ||
| fi | ||
|
|
||
| # Prompt | ||
| local line_prompt="${icon_end}${icon_prompt}" | ||
| PS1="${line_header}${line_container}${line_vcs}${line_prompt}" | ||
| } | ||
|
|
||
| _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.
Uh oh!
There was an error while loading. Please reload this page.