From 49434ac11baa1293c9b2396be7d702feb3fdac45 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Tue, 18 Feb 2025 11:59:50 +0900 Subject: [PATCH] Change default zsh theme to adnosterzak, pokemon coloscript integrated with fastfetch when opted with pokemon to add some bling, additional external oh-my-zsh themev --- CHANGELOGS.md | 5 + assets/.zshrc | 3 +- assets/add_zsh_theme/agnosterzak.zsh-theme | 370 +++++++++++ assets/add_zsh_theme/antares.zsh-theme | 392 +++++++++++ assets/add_zsh_theme/bullet-train.zsh-theme | 696 ++++++++++++++++++++ assets/add_zsh_theme/color-input.zsh-theme | 38 ++ assets/add_zsh_theme/comfyline.zsh-theme | 418 ++++++++++++ assets/add_zsh_theme/emoji.zsh-theme | 7 + assets/add_zsh_theme/fishbone++.zsh-theme | 60 ++ assets/fastfetch/config-pokemon.jsonc | 73 ++ install-scripts/zsh_pokemon.sh | 7 +- 11 files changed, 2067 insertions(+), 2 deletions(-) create mode 100644 assets/add_zsh_theme/agnosterzak.zsh-theme create mode 100644 assets/add_zsh_theme/antares.zsh-theme create mode 100644 assets/add_zsh_theme/bullet-train.zsh-theme create mode 100644 assets/add_zsh_theme/color-input.zsh-theme create mode 100644 assets/add_zsh_theme/comfyline.zsh-theme create mode 100644 assets/add_zsh_theme/emoji.zsh-theme create mode 100644 assets/add_zsh_theme/fishbone++.zsh-theme create mode 100644 assets/fastfetch/config-pokemon.jsonc diff --git a/CHANGELOGS.md b/CHANGELOGS.md index d448276..bb30aaf 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -1,5 +1,10 @@ ## Changelogs +## 18 Feb 2025 +- Change default zsh theme to adnosterzak +- pokemon coloscript integrated with fastfetch when opted with pokemon to add some bling +- additional external oh-my-zsh theme + ## 06 Feb 2025 - added semi-unattended function. - move all the initial questions at the beginning diff --git a/assets/.zshrc b/assets/.zshrc index 5cb4d8f..30b41f9 100644 --- a/assets/.zshrc +++ b/assets/.zshrc @@ -16,7 +16,8 @@ source $ZSH/oh-my-zsh.sh # Display Pokemon-colorscripts # Project page: https://gitlab.com/phoneybadger/pokemon-colorscripts#on-other-distros-and-macos -#pokemon-colorscripts --no-title -s -r +#pokemon-colorscripts --no-title -s -r #without fastfetch +#pokemon-colorscripts --no-title -s -r | fastfetch -c $HOME/.config/fastfetch/config-pokemon.jsonc --logo-type file-raw --logo-height 10 --logo-width 5 --logo - # fastfetch. Will be disabled if above colorscript was chosen to install fastfetch -c $HOME/.config/fastfetch/config-compact.jsonc diff --git a/assets/add_zsh_theme/agnosterzak.zsh-theme b/assets/add_zsh_theme/agnosterzak.zsh-theme new file mode 100644 index 0000000..20eda0c --- /dev/null +++ b/assets/add_zsh_theme/agnosterzak.zsh-theme @@ -0,0 +1,370 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' + +# Characters +SEGMENT_SEPARATOR="\ue0b0" +PLUSMINUS="\u00b1" +BRANCH="\ue0a0" +DETACHED="\u27a6" +CROSS="\u2718" +LIGHTNING="\u26a1" +GEAR="\u2699" + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + print -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + print -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && print -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + print -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + print -n "%{%k%}" + fi + print -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + if [[ -n "$SSH_CLIENT" ]]; then + prompt_segment magenta white "%{$fg_bold[white]%(!.%{%F{white}%}.)%}$USER@%m%{$fg_no_bold[white]%}" + else + prompt_segment yellow magenta "%{$fg_bold[magenta]%(!.%{%F{magenta}%}.)%}@$USER%{$fg_no_bold[magenta]%}" + fi +} + +# Battery Level +prompt_battery() { + HEART='♥ ' + + if [[ $(uname) == "Darwin" ]] ; then + + function battery_is_charging() { + [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ] + } + + function battery_pct() { + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') + typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') + integer i=$(((currentcapacity/maxcapacity) * 100)) + echo $i + } + + function battery_pct_remaining() { + if battery_is_charging ; then + battery_pct + else + echo "External Power" + fi + } + + function battery_time_remaining() { + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') + if [ $timeremaining -gt 720 ] ; then + echo "::" + else + echo "~$((timeremaining / 60)):$((timeremaining % 60))" + fi + fi + } + + b=$(battery_pct_remaining) + if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + if [ $b -gt 50 ] ; then + prompt_segment green white + elif [ $b -gt 20 ] ; then + prompt_segment yellow white + else + prompt_segment red white + fi + echo -n "%{$fg_bold[white]%}$HEART$(battery_pct_remaining)%%%{$fg_no_bold[white]%}" + fi + fi + + if [[ $(uname) == "Linux" && -d /sys/module/battery ]] ; then + + function battery_is_charging() { + ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] + } + + function battery_pct() { + if (( $+commands[acpi] )) ; then + echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" + fi + } + + function battery_pct_remaining() { + if [ ! $(battery_is_charging) ] ; then + battery_pct + else + echo "External Power" + fi + } + + function battery_time_remaining() { + if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + echo $(acpi | cut -f3 -d ',') + fi + } + + b=$(battery_pct_remaining) + if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then + if [ $b -gt 40 ] ; then + prompt_segment green white + elif [ $b -gt 20 ] ; then + prompt_segment yellow white + else + prompt_segment red white + fi + echo -n "%{$fg_bold[white]%}$HEART$(battery_pct_remaining)%%%{$fg_no_bold[white]%}" + fi + + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { +#«»±˖˗‑‐‒ ━ ✚‐↔←↑↓→↭⇎⇔⋆━◂▸◄►◆☀★☗☊✔✖❮❯⚑⚙ + local PL_BRANCH_CHAR + () { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + PL_BRANCH_CHAR="$BRANCH" + } + local ref dirty mode repo_path clean has_upstream + local modified untracked added deleted tagged stashed + local ready_commit git_status bgclr fgclr + local commits_diff commits_ahead commits_behind has_diverged to_push to_pull + + repo_path=$(git rev-parse --git-dir 2>/dev/null) + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + dirty=$(parse_git_dirty) + git_status=$(git status --porcelain 2> /dev/null) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" + if [[ -n $dirty ]]; then + clean='' + bgclr='yellow' + fgclr='magenta' + else + clean=' ✔' + bgclr='green' + fgclr='white' + fi + + local upstream=$(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} 2> /dev/null) + if [[ -n "${upstream}" && "${upstream}" != "@{upstream}" ]]; then has_upstream=true; fi + + local current_commit_hash=$(git rev-parse HEAD 2> /dev/null) + + local number_of_untracked_files=$(\grep -c "^??" <<< "${git_status}") + # if [[ $number_of_untracked_files -gt 0 ]]; then untracked=" $number_of_untracked_files◆"; fi + if [[ $number_of_untracked_files -gt 0 ]]; then untracked=" $number_of_untracked_files☀"; fi + + local number_added=$(\grep -c "^A" <<< "${git_status}") + if [[ $number_added -gt 0 ]]; then added=" $number_added✚"; fi + + local number_modified=$(\grep -c "^.M" <<< "${git_status}") + if [[ $number_modified -gt 0 ]]; then + modified=" $number_modified●" + bgclr='red' + fgclr='white' + fi + + local number_added_modified=$(\grep -c "^M" <<< "${git_status}") + local number_added_renamed=$(\grep -c "^R" <<< "${git_status}") + if [[ $number_modified -gt 0 && $number_added_modified -gt 0 ]]; then + modified="$modified$((number_added_modified+number_added_renamed))±" + elif [[ $number_added_modified -gt 0 ]]; then + modified=" ●$((number_added_modified+number_added_renamed))±" + fi + + local number_deleted=$(\grep -c "^.D" <<< "${git_status}") + if [[ $number_deleted -gt 0 ]]; then + deleted=" $number_deleted‒" + bgclr='red' + fgclr='white' + fi + + local number_added_deleted=$(\grep -c "^D" <<< "${git_status}") + if [[ $number_deleted -gt 0 && $number_added_deleted -gt 0 ]]; then + deleted="$deleted$number_added_deleted±" + elif [[ $number_added_deleted -gt 0 ]]; then + deleted=" ‒$number_added_deleted±" + fi + + local tag_at_current_commit=$(git describe --exact-match --tags $current_commit_hash 2> /dev/null) + if [[ -n $tag_at_current_commit ]]; then tagged=" ☗$tag_at_current_commit "; fi + + local number_of_stashes="$(git stash list -n1 2> /dev/null | wc -l)" + if [[ $number_of_stashes -gt 0 ]]; then + stashed=" ${number_of_stashes##*( )}⚙" + bgclr='magenta' + fgclr='white' + fi + + if [[ $number_added -gt 0 || $number_added_modified -gt 0 || $number_added_deleted -gt 0 ]]; then ready_commit=' ⚑'; fi + + local upstream_prompt='' + if [[ $has_upstream == true ]]; then + commits_diff="$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} 2> /dev/null)" + commits_ahead=$(\grep -c "^<" <<< "$commits_diff") + commits_behind=$(\grep -c "^>" <<< "$commits_diff") + upstream_prompt="$(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} 2> /dev/null)" + upstream_prompt=$(sed -e 's/\/.*$/ ☊ /g' <<< "$upstream_prompt") + fi + + has_diverged=false + if [[ $commits_ahead -gt 0 && $commits_behind -gt 0 ]]; then has_diverged=true; fi + if [[ $has_diverged == false && $commits_ahead -gt 0 ]]; then + if [[ $bgclr == 'red' || $bgclr == 'magenta' ]] then + to_push=" $fg_bold[white]↑$commits_ahead$fg_bold[$fgclr]" + else + to_push=" $fg_bold[black]↑$commits_ahead$fg_bold[$fgclr]" + fi + fi + if [[ $has_diverged == false && $commits_behind -gt 0 ]]; then to_pull=" $fg_bold[magenta]↓$commits_behind$fg_bold[$fgclr]"; fi + + if [[ -e "${repo_path}/BISECT_LOG" ]]; then + mode=" " + elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then + mode=" >M<" + elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then + mode=" >R>" + fi + + prompt_segment $bgclr $fgclr + + print -n "%{$fg_bold[$fgclr]%}${ref/refs\/heads\//$PL_BRANCH_CHAR $upstream_prompt}${mode}$to_push$to_pull$clean$tagged$stashed$untracked$modified$deleted$added$ready_commit%{$fg_no_bold[$fgclr]%}" + fi +} + +prompt_hg() { + local rev status + if $(hg id >/dev/null 2>&1); then + if $(hg prompt >/dev/null 2>&1); then + if [[ $(hg prompt "{status|unknown}") = "?" ]]; then + # if files are not added + prompt_segment red white + st='±' + elif [[ -n $(hg prompt "{status|modified}") ]]; then + # if any modification + prompt_segment yellow black + st='±' + else + # if working copy is clean + prompt_segment green black + fi + print -n $(hg prompt "☿ {rev}@{branch}") $st + else + st="" + rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') + branch=$(hg id -b 2>/dev/null) + if `hg st | grep -q "^\?"`; then + prompt_segment red black + st='±' + elif `hg st | grep -q "^[MA]"`; then + prompt_segment yellow black + st='±' + else + prompt_segment green black + fi + print -n "☿ $rev@$branch" $st + fi + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment cyan white "%{$fg_bold[white]%}%~%{$fg_no_bold[white]%}" +} + +# Virtualenv: current working virtualenv +prompt_virtualenv() { + local virtualenv_path="$VIRTUAL_ENV" + if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then + prompt_segment blue black "(`basename $virtualenv_path`)" + fi +} + +prompt_time() { + prompt_segment blue white "%{$fg_bold[white]%}%D{%a %e %b - %H:%M}%{$fg_no_bold[white]%}" +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + print -n "\n" + prompt_status + #prompt_battery + prompt_time + prompt_virtualenv + prompt_dir + prompt_git + prompt_hg + prompt_end + CURRENT_BG='NONE' + print -n "\n" + prompt_context + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' diff --git a/assets/add_zsh_theme/antares.zsh-theme b/assets/add_zsh_theme/antares.zsh-theme new file mode 100644 index 0000000..90ecf50 --- /dev/null +++ b/assets/add_zsh_theme/antares.zsh-theme @@ -0,0 +1,392 @@ + +### +### You can re-define the following variables in your .zshrc file +### in order to customize the appearance of the prompt +### + +# The indentation of the rprompt +ZLE_RPROMPT_INDENT=${ZLE_RPROMPT_INDENT:-0} + +# Whether to use oh-my-zsh's git-prompt plugin +# or the builtin logic written in this file +ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT="" + +# Whether to gather additional details about the git status +# This option only applies when using the builtin logic +# Usefull when dealing with huge repositories to speed things up +ZSH_ANTARES_USE_LIGHT_GIT_MODE="" + +# The colors to use for the various elements of the prompt +ZSH_ANTARES_FG_EXECTIME="#dd00ff" +ZSH_ANTARES_FG_ERRVAL="#c31a1a" +ZSH_ANTARES_FG_DECO="#ffffff" +ZSH_ANTARES_FG_PWD_OK="#ffffff" +ZSH_ANTARES_BG_PWD_OK="#0055ff" +ZSH_ANTARES_FG_PWD_ERR="#ffffff" +ZSH_ANTARES_BG_PWD_ERR="#c31a1a" +ZSH_ANTARES_FG_GIT_INIT="#000000" +ZSH_ANTARES_BG_GIT_INIT="#b5f3a1" +ZSH_ANTARES_FG_GIT_BARE="#000000" +ZSH_ANTARES_BG_GIT_BARE="#b07a4e" +ZSH_ANTARES_FG_GIT_BRANCH="#000000" +ZSH_ANTARES_BG_GIT_BRANCH="#47cc2b" +ZSH_ANTARES_FG_GIT_DETACH="#000000" +ZSH_ANTARES_BG_GIT_DETACH="#eeaa22" +ZSH_ANTARES_FG_GIT_CONFLICT="#000000" +ZSH_ANTARES_BG_GIT_CONFLICT="#c31a1a" +ZSH_ANTARES_FG_GIT_AHEAD="#cfcfcf" +ZSH_ANTARES_FG_GIT_BEHIND="#9f9f9f" +ZSH_ANTARES_FG_GIT_STAGED="#6cc6ee" +ZSH_ANTARES_FG_GIT_ADDED="#04c304" +ZSH_ANTARES_FG_GIT_DELETED="#e7165a" +ZSH_ANTARES_FG_GIT_CHANGED="#ee9931" +ZSH_ANTARES_FG_GIT_CONFLICTS="#ff0000" +ZSH_ANTARES_FG_GIT_UNTRACKED="#bbffff" +ZSH_ANTARES_FG_GIT_STASHED="#eaa0ff" +ZSH_ANTARES_FG_GIT_TAG="#ffffff" +ZSH_ANTARES_FG_JOBS="#9f9f9f" +ZSH_ANTARES_FG_PRIVILEDGES="#ffdd44" + +# The characters (or strings, by will) to use for some of the elements +ZSH_ANTARES_STR_GIT_BARE="⛁" +ZSH_ANTARES_STR_GIT_AHEAD="↑" +ZSH_ANTARES_STR_GIT_BEHIND="↓" +ZSH_ANTARES_STR_GIT_STAGED="●" +ZSH_ANTARES_STR_GIT_ADDED="✚" +ZSH_ANTARES_STR_GIT_DELETED="━" +ZSH_ANTARES_STR_GIT_CHANGED="✱" +ZSH_ANTARES_STR_GIT_CONFLICTS="✖" +ZSH_ANTARES_STR_GIT_UNTRACKED="❍" +ZSH_ANTARES_STR_GIT_STASHED="⚑" +ZSH_ANTARES_STR_GIT_TAG="🏲" +ZSH_ANTARES_STR_JOBS="⚙" +ZSH_ANTARES_STR_ROOT="#" +ZSH_ANTARES_STR_USER="$" + +# The path expansion to use to display the pwd +ZSH_ANTARES_PATHVAR='%~' + +# The minimum amount of time (in seconds) a command shall take to complete +# in order to display the execution time in the prompt +ZSH_ANTARES_MIN_EXEC_TIME=0 + +# The control character used to insert a new line +# You shouldn't edit this variable, but if you really want to... +ZSH_ANTARES_LINEFEED=$'\n' + +### +### End of the re-definable section +### + + +antares_update_git_status() +{ + ZSH_ANTARES_GIT_STATUS="" + ZSH_ANTARES_GIT_IN_WORKING_TREE=0 + ZSH_ANTARES_GIT_IS_INIT_REPO=0 + ZSH_ANTARES_GIT_IS_BARE_REPO=0 + ZSH_ANTARES_GIT_IS_DETACHED_HEAD=0 + ZSH_ANTARES_GIT_HAS_CONFLICTS=0 + ZSH_ANTARES_GIT_HAS_TAGS=0 + ZSH_ANTARES_GIT_TAG="" + + if ( $(git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null) ) + then + ZSH_ANTARES_GIT_IN_WORKING_TREE=1 + private branch_name="$(git branch --show-current)" + if [ -n "$branch_name" ] + then + if [ -z "$ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT" ] + then + GIT_BRANCH="$branch_name" + fi + if ( ! $(git rev-parse --verify HEAD 1>/dev/null 2>/dev/null) ) + then + ZSH_ANTARES_GIT_IS_INIT_REPO=1 + fi + if [ $(git rev-parse --is-bare-repository) = "true" ] + then + ZSH_ANTARES_GIT_IS_BARE_REPO=1 + GIT_BRANCH="$ZSH_ANTARES_STR_GIT_BARE" + fi + else + ZSH_ANTARES_GIT_IS_DETACHED_HEAD=1 + if [ -z "$ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT" ] + then + GIT_BRANCH="$(git rev-parse --short HEAD)" + if [ -z "$ZSH_ANTARES_USE_LIGHT_GIT_MODE" ] + then + private git_tag="$(git tag --points-at=HEAD)" + if [ -n "$git_tag" ] + then + ZSH_ANTARES_GIT_HAS_TAGS=1 + private n_tags="$(echo "$git_tag" | wc -l)" + if (( n_tags == 1 )) + then + ZSH_ANTARES_GIT_TAG=" $ZSH_ANTARES_STR_GIT_TAG $git_tag" + elif (( n_tags > 1 )) + then + ZSH_ANTARES_GIT_TAG=" $ZSH_ANTARES_STR_GIT_TAG $n_tags" + else + fi + fi + fi + fi + fi + else + antares_reset_git_info + return + fi + + if (( ZSH_ANTARES_GIT_IS_BARE_REPO )) + then + antares_reset_git_counts + GIT_AHEAD=$(git rev-list --left-only HEAD..FETCH_HEAD --count) + GIT_BEHIND=$(git rev-list --right-only HEAD..FETCH_HEAD --count) + return + fi + + if [ -n "$ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT" ] + then + GIT_ADDED=0 + elif [ -n "$ZSH_ANTARES_USE_LIGHT_GIT_MODE" ] + then + antares_reset_git_counts + return + else + private git_status="$(git status -sb)" + if [ -n "$git_status" ] + then + GIT_STAGED=$(echo $git_status | grep '^[AMD]. ' | wc -l) + GIT_ADDED=$(echo $git_status | grep '^A ' | wc -l) + GIT_DELETED=$(echo $git_status | grep -E '^(D |.D) ' | wc -l) + GIT_CHANGED=$(echo $git_status | grep -E '^(M |.M) ' | wc -l) + GIT_CONFLICTS=$(echo $git_status | grep '^U. ' | wc -l) + GIT_UNTRACKED=$(echo $git_status | grep '^?? ' | wc -l) + GIT_STASHED=$(git stash list | wc -l) + if (( ZSH_ANTARES_GIT_IS_DETACHED_HEAD )) + then + GIT_AHEAD=0 + GIT_BEHIND=0 + elif (( ! ZSH_ANTARES_GIT_IS_INIT_REPO )) + then + private left_right=$(echo $git_status | grep '^## ' | cut -d" " -f2) + GIT_AHEAD=$(git rev-list --left-only $left_right --count) + GIT_BEHIND=$(git rev-list --right-only $left_right --count) + fi + fi + fi + + ZSH_ANTARES_GIT_HAS_CONFLICTS=$(( GIT_CONFLICTS > 0 )) +} + +antares_reset_git_info() +{ + if [ -z "$ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT" ] + then + GIT_BRANCH="" + fi + antares_reset_git_counts +} +antares_reset_git_counts() +{ + if [ -n "$ZSH_ANTARES_USE_OHMYZSH_GIT_PROMPT" ] + then + GIT_ADDED=0 + else + GIT_AHEAD=0 + GIT_BEHIND=0 + GIT_STAGED=0 + GIT_ADDED=0 + GIT_DELETED=0 + GIT_CHANGED=0 + GIT_CONFLICTS=0 + GIT_UNTRACKED=0 + GIT_STASHED=0 + fi +} + +antares_update_prompt() +{ + ZSH_ANTARES_RETURN="" + if [ -n "$ZSH_ANTARES_EXEC_FLAG" ] + then + if (( ZSH_ANTARES_MIN_EXEC_TIME >= 0 )) + then + private exec_time=$(( SECONDS - ZSH_ANTARES_EXEC_START )) + if (( exec_time >= ZSH_ANTARES_MIN_EXEC_TIME )) + then + ZSH_ANTARES_RETURN+="%F{$ZSH_ANTARES_FG_EXECTIME}%B⤷%b $exec_time%f" + fi + fi + if [[ "$ZSH_ANTARES_ERR_CODE" != "0" ]] + then + if [ -z "$ZSH_ANTARES_RETURN" ] + then + ZSH_ANTARES_RETURN+="%F{$ZSH_ANTARES_FG_ERRVAL}%B⤷%b%f" + fi + ZSH_ANTARES_RETURN+=" %F{$ZSH_ANTARES_FG_ERRVAL}✘%B${ZSH_ANTARES_ERR_CODE}%b%f" + fi + [ -n "$ZSH_ANTARES_RETURN" ] && ZSH_ANTARES_RETURN+="$ZSH_ANTARES_LINEFEED" + fi + + ZSH_ANTARES_FILLER="" + private fillchar=" " + + private width=$(( COLUMNS - ${ZLE_RPROMPT_INDENT:-1} )) + + private decosize=7 + private pwdsize=${#${(%):-$ZSH_ANTARES_PATHVAR}} + private pwdcut="" + private gitsize=${#${(%):-$GIT_BRANCH$ZSH_ANTARES_GIT_TAG}} + private gitcut="" + + if (( pwdsize + gitsize + (decosize * 2) > width )); then + private half_width=$(( width / 2 )) + private pwd_over_half=$(( (pwdsize + decosize) > half_width )) + private git_over_half=$(( (gitsize + decosize) > half_width )) + if (( pwd_over_half > 0 )) && (( git_over_half > 0 )) + then + (( pwdcut = half_width - decosize )) + (( gitcut = half_width - decosize )) + elif (( pwd_over_half > 0 )) + then + (( pwdcut = width - gitsize - (decosize * 2) )) + ZSH_ANTARES_FILLER="\${(l:$(( width - pwdcut - gitsize - (decosize * 2) ))::$fillchar:)}" + elif (( git_over_half > 0 )) + then + (( gitcut = width - pwdsize - (decosize * 2) )) + ZSH_ANTARES_FILLER="\${(l:$(( width - pwdsize - gitcut - (decosize * 2) ))::$fillchar:)}" + else + ZSH_ANTARES_FILLER="\${(l:$(( width - pwdsize - gitsize - (decosize * 2) ))::$fillchar:)}" + fi + else + ZSH_ANTARES_FILLER="\${(l:$(( width - pwdsize - gitsize - (decosize * 2) ))::$fillchar:)}" + fi + + if [ -n "$ZSH_ANTARES_EXEC_FLAG" ] + then + private pwd_fg_color="%(?.${ZSH_ANTARES_FG_PWD_OK}.${ZSH_ANTARES_FG_PWD_ERR})" + private pwd_bg_color="%(?.${ZSH_ANTARES_BG_PWD_OK}.${ZSH_ANTARES_BG_PWD_ERR})" + else + private pwd_fg_color="$ZSH_ANTARES_FG_PWD_OK" + private pwd_bg_color="$ZSH_ANTARES_BG_PWD_OK" + fi + ZSH_ANTARES_PWD="%K{$pwd_bg_color}%F{$pwd_fg_color} %${pwdcut}<...<${ZSH_ANTARES_PATHVAR}%<< %f%k%F{$pwd_bg_color}▓▒░%f" + + ZSH_ANTARES_GIT_BRANCH="" + if (( ZSH_ANTARES_GIT_IN_WORKING_TREE )) + then + if (( ZSH_ANTARES_GIT_HAS_CONFLICTS )) + then + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_BG_GIT_CONFLICT}░▒▓%f%K{$ZSH_ANTARES_BG_GIT_CONFLICT}%F{$ZSH_ANTARES_FG_GIT_CONFLICT}" + elif (( ZSH_ANTARES_GIT_IS_DETACHED_HEAD )) + then + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_BG_GIT_DETACH}░▒▓%f%K{$ZSH_ANTARES_BG_GIT_DETACH}%F{$ZSH_ANTARES_FG_GIT_DETACH}" + if (( ZSH_ANTARES_GIT_HAS_TAGS )) + then + GIT_BRANCH+="%F{$ZSH_ANTARES_FG_GIT_TAG}${ZSH_ANTARES_GIT_TAG}%f" + fi + elif (( ZSH_ANTARES_GIT_IS_BARE_REPO )) + then + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_BG_GIT_BARE}░▒▓%f%K{$ZSH_ANTARES_BG_GIT_BARE}%F{$ZSH_ANTARES_FG_GIT_BARE}" + elif (( ZSH_ANTARES_GIT_IS_INIT_REPO )) + then + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_BG_GIT_INIT}░▒▓%f%K{$ZSH_ANTARES_BG_GIT_INIT}%F{$ZSH_ANTARES_FG_GIT_INIT}" + else + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_BG_GIT_BRANCH}░▒▓%f%K{$ZSH_ANTARES_BG_GIT_BRANCH}%F{$ZSH_ANTARES_FG_GIT_BRANCH}" + fi + ZSH_ANTARES_GIT_BRANCH+=" %${gitcut}>...>$GIT_BRANCH%>> %f%k" + if [ -n "$ZSH_ANTARES_USE_LIGHT_GIT_MODE" ] + then + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_FG_DECO}├╼%f" + else + ZSH_ANTARES_GIT_BRANCH+="%F{$ZSH_ANTARES_FG_DECO}├╮%f" + fi + fi + + ZSH_ANTARES_JOBS="%(1j.%F{$ZSH_ANTARES_FG_JOBS}${ZSH_ANTARES_STR_JOBS}%j%f .)" + + ZSH_ANTARES_PRIVILEDGES="%F{$ZSH_ANTARES_FG_PRIVILEDGES}%B%(!.${ZSH_ANTARES_STR_ROOT}.${ZSH_ANTARES_STR_USER})%b%f" +} + +antares_update_rprompt() +{ + ZSH_ANTARES_GIT_STATUS="" + + [ -n "$ZSH_ANTARES_USE_LIGHT_GIT_MODE" ] && return + + (( ZSH_ANTARES_GIT_IN_WORKING_TREE )) || return + + if (( GIT_CONFLICTS > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_CONFLICTS}${ZSH_ANTARES_STR_GIT_CONFLICTS}${GIT_CONFLICTS}%f" + fi + if (( GIT_STAGED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_STAGED}${ZSH_ANTARES_STR_GIT_STAGED}${GIT_STAGED}%f" + fi + if (( GIT_DELETED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_DELETED}${ZSH_ANTARES_STR_GIT_DELETED}${GIT_DELETED}%f" + fi + if (( GIT_CHANGED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_CHANGED}${ZSH_ANTARES_STR_GIT_CHANGED}${GIT_CHANGED}%f" + fi + if (( GIT_ADDED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_ADDED}${ZSH_ANTARES_STR_GIT_ADDED}${GIT_ADDED}%f" + fi + if (( GIT_UNTRACKED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_UNTRACKED}${ZSH_ANTARES_STR_GIT_UNTRACKED}${GIT_UNTRACKED}%f" + fi + if (( GIT_STASHED > 0 )) + then + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_GIT_STASHED}${ZSH_ANTARES_STR_GIT_STASHED}${GIT_STASHED}%f" + fi + if (( ! ZSH_ANTARES_GIT_IS_DETACHED_HEAD )) + then + private ahead_behind="" + if (( GIT_AHEAD > 0 )) + then + ahead_behind+="%F{$ZSH_ANTARES_FG_GIT_AHEAD}${ZSH_ANTARES_STR_GIT_AHEAD}${GIT_AHEAD}%f" + fi + if (( GIT_BEHIND > 0 )) + then + ahead_behind+="%F{$ZSH_ANTARES_FG_GIT_BEHIND}${ZSH_ANTARES_STR_GIT_BEHIND}${GIT_BEHIND}%f" + fi + if [ -n "$ahead_behind" ] + then + ZSH_ANTARES_GIT_STATUS+=" $ahead_behind" + fi + fi + ZSH_ANTARES_GIT_STATUS+=" %F{$ZSH_ANTARES_FG_DECO}╾─╯%f" +} + +antares_precmd() +{ + ZSH_ANTARES_ERR_CODE="$?" + antares_update_git_status + antares_update_prompt + antares_update_rprompt + ZSH_ANTARES_EXEC_FLAG="" +} + +antares_preexec() +{ + ZSH_ANTARES_EXEC_FLAG="+" + ZSH_ANTARES_EXEC_START=$SECONDS +} + +autoload -U add-zsh-hook +add-zsh-hook precmd antares_precmd +add-zsh-hook preexec antares_preexec + +PROMPT='${ZSH_ANTARES_RETURN}\ +%F{$ZSH_ANTARES_FG_DECO}╭┤%f${ZSH_ANTARES_PWD}${(e)ZSH_ANTARES_FILLER}${ZSH_ANTARES_GIT_BRANCH} +%F{$ZSH_ANTARES_FG_DECO}╰─╼%f ${ZSH_ANTARES_JOBS}${ZSH_ANTARES_PRIVILEDGES} ' + +RPROMPT='${ZSH_ANTARES_GIT_STATUS}' + diff --git a/assets/add_zsh_theme/bullet-train.zsh-theme b/assets/add_zsh_theme/bullet-train.zsh-theme new file mode 100644 index 0000000..d72c4f5 --- /dev/null +++ b/assets/add_zsh_theme/bullet-train.zsh-theme @@ -0,0 +1,696 @@ +# README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). +# +# In addition, I recommend the +# [Tomorrow Night theme](https://github.com/chriskempson/tomorrow-theme) and, if +# you're using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over +# Terminal.app - it has significantly better color fidelity. + +# ------------------------------------------------------------------------------ +# CONFIGURATION +# The default configuration, that can be overwrite in your .zshrc file +# ------------------------------------------------------------------------------ + +VIRTUAL_ENV_DISABLE_PROMPT=true + +# Define order and content of prompt +if [ ! -n "${BULLETTRAIN_PROMPT_ORDER+1}" ]; then + BULLETTRAIN_PROMPT_ORDER=( + time + status + custom + context + dir + screen + perl + ruby + virtualenv + nvm + aws + go + rust + elixir + git + hg + cmd_exec_time + ) +fi + +# PROMPT +if [ ! -n "${BULLETTRAIN_PROMPT_CHAR+1}" ]; then + BULLETTRAIN_PROMPT_CHAR="\$" +fi +if [ ! -n "${BULLETTRAIN_PROMPT_ROOT+1}" ]; then + BULLETTRAIN_PROMPT_ROOT=true +fi +if [ ! -n "${BULLETTRAIN_PROMPT_SEPARATE_LINE+1}" ]; then + BULLETTRAIN_PROMPT_SEPARATE_LINE=true +fi +if [ ! -n "${BULLETTRAIN_PROMPT_ADD_NEWLINE+1}" ]; then + BULLETTRAIN_PROMPT_ADD_NEWLINE=true +fi + +# STATUS +if [ ! -n "${BULLETTRAIN_STATUS_EXIT_SHOW+1}" ]; then + BULLETTRAIN_STATUS_EXIT_SHOW=false +fi +if [ ! -n "${BULLETTRAIN_STATUS_BG+1}" ]; then + BULLETTRAIN_STATUS_BG=green +fi +if [ ! -n "${BULLETTRAIN_STATUS_ERROR_BG+1}" ]; then + BULLETTRAIN_STATUS_ERROR_BG=red +fi +if [ ! -n "${BULLETTRAIN_STATUS_FG+1}" ]; then + BULLETTRAIN_STATUS_FG=white +fi + +# TIME +if [ ! -n "${BULLETTRAIN_TIME_BG+1}" ]; then + BULLETTRAIN_TIME_BG=white +fi +if [ ! -n "${BULLETTRAIN_TIME_FG+1}" ]; then + BULLETTRAIN_TIME_FG=black +fi + +# CUSTOM +if [ ! -n "${BULLETTRAIN_CUSTOM_MSG+1}" ]; then + BULLETTRAIN_CUSTOM_MSG=false +fi +if [ ! -n "${BULLETTRAIN_CUSTOM_BG+1}" ]; then + BULLETTRAIN_CUSTOM_BG=black +fi +if [ ! -n "${BULLETTRAIN_CUSTOM_FG+1}" ]; then + BULLETTRAIN_CUSTOM_FG=default +fi + +# VIRTUALENV +if [ ! -n "${BULLETTRAIN_VIRTUALENV_BG+1}" ]; then + BULLETTRAIN_VIRTUALENV_BG=yellow +fi +if [ ! -n "${BULLETTRAIN_VIRTUALENV_FG+1}" ]; then + BULLETTRAIN_VIRTUALENV_FG=white +fi +if [ ! -n "${BULLETTRAIN_VIRTUALENV_PREFIX+1}" ]; then + BULLETTRAIN_VIRTUALENV_PREFIX=🐍 +fi + +# NVM +if [ ! -n "${BULLETTRAIN_NVM_BG+1}" ]; then + BULLETTRAIN_NVM_BG=green +fi +if [ ! -n "${BULLETTRAIN_NVM_FG+1}" ]; then + BULLETTRAIN_NVM_FG=white +fi +if [ ! -n "${BULLETTRAIN_NVM_PREFIX+1}" ]; then + BULLETTRAIN_NVM_PREFIX="⬡ " +fi + +# AWS +if [ ! -n "${BULLETTRAIN_AWS_BG+1}" ]; then + BULLETTRAIN_AWS_BG=yellow +fi +if [ ! -n "${BULLETTRAIN_AWS_FG+1}" ]; then + BULLETTRAIN_AWS_FG=black +fi +if [ ! -n "${BULLETTRAIN_AWS_PREFIX+1}" ]; then + BULLETTRAIN_AWS_PREFIX="☁️" +fi + +# RUBY +if [ ! -n "${BULLETTRAIN_RUBY_BG+1}" ]; then + BULLETTRAIN_RUBY_BG=red +fi +if [ ! -n "${BULLETTRAIN_RUBY_FG+1}" ]; then + BULLETTRAIN_RUBY_FG=white +fi +if [ ! -n "${BULLETTRAIN_RUBY_PREFIX+1}" ]; then + BULLETTRAIN_RUBY_PREFIX=♦️ +fi + +# Go +if [ ! -n "${BULLETTRAIN_GO_BG+1}" ]; then + BULLETTRAIN_GO_BG=cyan +fi +if [ ! -n "${BULLETTRAIN_GO_FG+1}" ]; then + BULLETTRAIN_GO_FG=white +fi +if [ ! -n "${BULLETTRAIN_GO_PREFIX+1}" ]; then + BULLETTRAIN_GO_PREFIX="go" +fi + +# Rust +if [ ! -n "${BULLETTRAIN_RUST_BG+1}" ]; then + BULLETTRAIN_RUST_BG=black +fi +if [ ! -n "${BULLETTRAIN_RUST_FG+1}" ]; then + BULLETTRAIN_RUST_FG=white +fi +if [ ! -n "${BULLETTRAIN_RUST_PREFIX+1}" ]; then + BULLETTRAIN_RUST_PREFIX="🦀" +fi + +# Kubernetes Context +if [ ! -n "${BULLETTRAIN_KCTX_BG+1}" ]; then + BULLETTRAIN_KCTX_BG=yellow +fi +if [ ! -n "${BULLETTRAIN_KCTX_FG+1}" ]; then + BULLETTRAIN_KCTX_FG=white +fi +if [ ! -n "${BULLETTRAIN_KCTX_PREFIX+1}" ]; then + BULLETTRAIN_KCTX_PREFIX="⎈" +fi +if [ ! -n "${BULLETTRAIN_KCTX_KCONFIG+1}" ]; then + BULLETTRAIN_KCTX_KCONFIG="${HOME}/.kube/config" +fi +if [ ! -n "${BULLETTRAIN_KCTX_KUBECTL+1}" ]; then + BULLETTRAIN_KCTX_KUBECTL="true" +fi +if [ ! -n "${BULLETTRAIN_KCTX_NAMESPACE+1}" ]; then + BULLETTRAIN_KCTX_NAMESPACE="true" +fi + +# ELIXIR +if [ ! -n "${BULLETTRAIN_ELIXIR_BG+1}" ]; then + BULLETTRAIN_ELIXIR_BG=magenta +fi +if [ ! -n "${BULLETTRAIN_ELIXIR_FG+1}" ]; then + BULLETTRAIN_ELIXIR_FG=white +fi +if [ ! -n "${BULLETTRAIN_ELIXIR_PREFIX+1}" ]; then + BULLETTRAIN_ELIXIR_PREFIX="💧" +fi + +# DIR +if [ ! -n "${BULLETTRAIN_DIR_BG+1}" ]; then + BULLETTRAIN_DIR_BG=blue +fi +if [ ! -n "${BULLETTRAIN_DIR_FG+1}" ]; then + BULLETTRAIN_DIR_FG=white +fi +if [ ! -n "${BULLETTRAIN_DIR_CONTEXT_SHOW+1}" ]; then + BULLETTRAIN_DIR_CONTEXT_SHOW=false +fi +if [ ! -n "${BULLETTRAIN_DIR_EXTENDED+1}" ]; then + BULLETTRAIN_DIR_EXTENDED=1 +fi + +# GIT +if [ ! -n "${BULLETTRAIN_GIT_COLORIZE_DIRTY+1}" ]; then + BULLETTRAIN_GIT_COLORIZE_DIRTY=false +fi +if [ ! -n "${BULLETTRAIN_GIT_COLORIZE_DIRTY_FG_COLOR+1}" ]; then + BULLETTRAIN_GIT_COLORIZE_DIRTY_FG_COLOR=black +fi +if [ ! -n "${BULLETTRAIN_GIT_COLORIZE_DIRTY_BG_COLOR+1}" ]; then + BULLETTRAIN_GIT_COLORIZE_DIRTY_BG_COLOR=yellow +fi +if [ ! -n "${BULLETTRAIN_GIT_BG+1}" ]; then + BULLETTRAIN_GIT_BG=white +fi +if [ ! -n "${BULLETTRAIN_GIT_FG+1}" ]; then + BULLETTRAIN_GIT_FG=black +fi +if [ ! -n "${BULLETTRAIN_GIT_EXTENDED+1}" ]; then + BULLETTRAIN_GIT_EXTENDED=true +fi +if [ ! -n "${BULLETTRAIN_GIT_PROMPT_CMD+1}" ]; then + BULLETTRAIN_GIT_PROMPT_CMD="\$(git_prompt_info)" +fi + +# PERL +if [ ! -n "${BULLETTRAIN_PERL_BG+1}" ]; then + BULLETTRAIN_PERL_BG=yellow +fi +if [ ! -n "${BULLETTRAIN_PERL_FG+1}" ]; then + BULLETTRAIN_PERL_FG=black +fi +if [ ! -n "${BULLETTRAIN_PERL_PREFIX+1}" ]; then + BULLETTRAIN_PERL_PREFIX=🐪 +fi + +# CONTEXT +if [ ! -n "${BULLETTRAIN_CONTEXT_BG+1}" ]; then + BULLETTRAIN_CONTEXT_BG=black +fi +if [ ! -n "${BULLETTRAIN_CONTEXT_FG+1}" ]; then + BULLETTRAIN_CONTEXT_FG=default +fi +if [ ! -n "${BULLETTRAIN_CONTEXT_HOSTNAME+1}" ]; then + BULLETTRAIN_CONTEXT_HOSTNAME=%m +fi + +# GIT PROMPT +if [ ! -n "${BULLETTRAIN_GIT_PREFIX+1}" ]; then + ZSH_THEME_GIT_PROMPT_PREFIX="\ue0a0 " +else + ZSH_THEME_GIT_PROMPT_PREFIX=$BULLETTRAIN_GIT_PREFIX +fi +if [ ! -n "${BULLETTRAIN_GIT_SUFFIX+1}" ]; then + ZSH_THEME_GIT_PROMPT_SUFFIX="" +else + ZSH_THEME_GIT_PROMPT_SUFFIX=$BULLETTRAIN_GIT_SUFFIX +fi +if [ ! -n "${BULLETTRAIN_GIT_DIRTY+1}" ]; then + ZSH_THEME_GIT_PROMPT_DIRTY=" %F{red}✘%F{black}" +else + ZSH_THEME_GIT_PROMPT_DIRTY=$BULLETTRAIN_GIT_DIRTY +fi +if [ ! -n "${BULLETTRAIN_GIT_CLEAN+1}" ]; then + ZSH_THEME_GIT_PROMPT_CLEAN=" %F{green}✔%F{black}" +else + ZSH_THEME_GIT_PROMPT_CLEAN=$BULLETTRAIN_GIT_CLEAN +fi +if [ ! -n "${BULLETTRAIN_GIT_ADDED+1}" ]; then + ZSH_THEME_GIT_PROMPT_ADDED=" %F{green}✚%F{black}" +else + ZSH_THEME_GIT_PROMPT_ADDED=$BULLETTRAIN_GIT_ADDED +fi +if [ ! -n "${BULLETTRAIN_GIT_MODIFIED+1}" ]; then + ZSH_THEME_GIT_PROMPT_MODIFIED=" %F{blue}✹%F{black}" +else + ZSH_THEME_GIT_PROMPT_MODIFIED=$BULLETTRAIN_GIT_MODIFIED +fi +if [ ! -n "${BULLETTRAIN_GIT_DELETED+1}" ]; then + ZSH_THEME_GIT_PROMPT_DELETED=" %F{red}✖%F{black}" +else + ZSH_THEME_GIT_PROMPT_DELETED=$BULLETTRAIN_GIT_DELETED +fi +if [ ! -n "${BULLETTRAIN_GIT_UNTRACKED+1}" ]; then + ZSH_THEME_GIT_PROMPT_UNTRACKED=" %F{yellow}✭%F{black}" +else + ZSH_THEME_GIT_PROMPT_UNTRACKED=$BULLETTRAIN_GIT_UNTRACKED +fi +if [ ! -n "${BULLETTRAIN_GIT_RENAMED+1}" ]; then + ZSH_THEME_GIT_PROMPT_RENAMED=" ➜" +else + ZSH_THEME_GIT_PROMPT_RENAMED=$BULLETTRAIN_GIT_RENAMED +fi +if [ ! -n "${BULLETTRAIN_GIT_UNMERGED+1}" ]; then + ZSH_THEME_GIT_PROMPT_UNMERGED=" ═" +else + ZSH_THEME_GIT_PROMPT_UNMERGED=$BULLETTRAIN_GIT_UNMERGED +fi +if [ ! -n "${BULLETTRAIN_GIT_AHEAD+1}" ]; then + ZSH_THEME_GIT_PROMPT_AHEAD=" ⬆" +else + ZSH_THEME_GIT_PROMPT_AHEAD=$BULLETTRAIN_GIT_AHEAD +fi +if [ ! -n "${BULLETTRAIN_GIT_BEHIND+1}" ]; then + ZSH_THEME_GIT_PROMPT_BEHIND=" ⬇" +else + ZSH_THEME_GIT_PROMPT_BEHIND=$BULLETTRAIN_GIT_BEHIND +fi +if [ ! -n "${BULLETTRAIN_GIT_DIVERGED+1}" ]; then + ZSH_THEME_GIT_PROMPT_DIVERGED=" ⬍" +else + ZSH_THEME_GIT_PROMPT_DIVERGED=$BULLETTRAIN_GIT_PROMPT_DIVERGED +fi + +# SCREEN +if [ ! -n "${BULLETTRAIN_SCREEN_BG+1}" ]; then + BULLETTRAIN_SCREEN_BG=white +fi +if [ ! -n "${BULLETTRAIN_SCREEN_FG+1}" ]; then + BULLETTRAIN_SCREEN_FG=black +fi +if [ ! -n "${BULLETTRAIN_SCREEN_PREFIX+1}" ]; then + BULLETTRAIN_SCREEN_PREFIX="⬗" +fi + +# COMMAND EXECUTION TIME +if [ ! -n "${BULLETTRAIN_EXEC_TIME_ELAPSED+1}" ]; then + BULLETTRAIN_EXEC_TIME_ELAPSED=5 +fi +if [ ! -n "${BULLETTRAIN_EXEC_TIME_BG+1}" ]; then + BULLETTRAIN_EXEC_TIME_BG=yellow +fi +if [ ! -n "${BULLETTRAIN_EXEC_TIME_FG+1}" ]; then + BULLETTRAIN_EXEC_TIME_FG=black +fi + + +# ------------------------------------------------------------------------------ +# SEGMENT DRAWING +# A few functions to make it easy and re-usable to draw segmented prompts +# ------------------------------------------------------------------------------ + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='' + +# Begin a segment +# Takes three arguments, background, foreground and text. All of them can be omitted, +# rendering default background/foreground and no text. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +# ------------------------------------------------------------------------------ +# PROMPT COMPONENTS +# Each component will draw itself, and hide itself if no information needs +# to be shown +# ------------------------------------------------------------------------------ + +# Context: user@hostname (who am I and where am I) +context() { + local user="$(whoami)" + [[ "$user" != "$BULLETTRAIN_CONTEXT_DEFAULT_USER" || -n "$BULLETTRAIN_IS_SSH_CLIENT" ]] && echo -n "${user}@$BULLETTRAIN_CONTEXT_HOSTNAME" +} + +prompt_context() { + local _context="$(context)" + [[ -n "$_context" ]] && prompt_segment $BULLETTRAIN_CONTEXT_BG $BULLETTRAIN_CONTEXT_FG "$_context" +} + +# Based on http://stackoverflow.com/a/32164707/3859566 +function displaytime { + local T=$1 + local D=$((T/60/60/24)) + local H=$((T/60/60%24)) + local M=$((T/60%60)) + local S=$((T%60)) + [[ $D > 0 ]] && printf '%dd' $D + [[ $H > 0 ]] && printf '%dh' $H + [[ $M > 0 ]] && printf '%dm' $M + printf '%ds' $S +} + +# Prompt previous command execution time +preexec() { + cmd_timestamp=`date +%s` +} + +precmd() { + local stop=`date +%s` + local start=${cmd_timestamp:-$stop} + let BULLETTRAIN_last_exec_duration=$stop-$start + cmd_timestamp='' +} + +prompt_cmd_exec_time() { + [ $BULLETTRAIN_last_exec_duration -gt $BULLETTRAIN_EXEC_TIME_ELAPSED ] && prompt_segment $BULLETTRAIN_EXEC_TIME_BG $BULLETTRAIN_EXEC_TIME_FG "$(displaytime $BULLETTRAIN_last_exec_duration)" +} + +# Custom +prompt_custom() { + if [[ $BULLETTRAIN_CUSTOM_MSG == false ]]; then + return + fi + + local custom_msg + eval custom_msg=$BULLETTRAIN_CUSTOM_MSG + [[ -n "${custom_msg}" ]] && prompt_segment $BULLETTRAIN_CUSTOM_BG $BULLETTRAIN_CUSTOM_FG "${custom_msg}" +} + +# Git +prompt_git() { + if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" == "1" ]]; then + return + fi + + local ref dirty mode repo_path git_prompt + repo_path=$(git rev-parse --git-dir 2>/dev/null) + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + if [[ $BULLETTRAIN_GIT_COLORIZE_DIRTY == true && -n $(git status --porcelain --ignore-submodules) ]]; then + BULLETTRAIN_GIT_BG=$BULLETTRAIN_GIT_COLORIZE_DIRTY_BG_COLOR + BULLETTRAIN_GIT_FG=$BULLETTRAIN_GIT_COLORIZE_DIRTY_FG_COLOR + fi + prompt_segment $BULLETTRAIN_GIT_BG $BULLETTRAIN_GIT_FG + + eval git_prompt=${BULLETTRAIN_GIT_PROMPT_CMD} + if [[ $BULLETTRAIN_GIT_EXTENDED == true ]]; then + echo -n ${git_prompt}$(git_prompt_status) + else + echo -n ${git_prompt} + fi + fi +} + +prompt_hg() { + local rev status + if $(hg id >/dev/null 2>&1); then + if $(hg prompt >/dev/null 2>&1); then + if [[ $(hg prompt "{status|unknown}") = "?" ]]; then + # if files are not added + prompt_segment red white + st='±' + elif [[ -n $(hg prompt "{status|modified}") ]]; then + # if any modification + prompt_segment yellow black + st='±' + else + # if working copy is clean + prompt_segment green black + fi + echo -n $(hg prompt "☿ {rev}@{branch}") $st + else + st="" + rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') + branch=$(hg id -b 2>/dev/null) + if $(hg st | grep -Eq "^\?"); then + prompt_segment red black + st='±' + elif $(hg st | grep -Eq "^(M|A)"); then + prompt_segment yellow black + st='±' + else + prompt_segment green black + fi + echo -n "☿ $rev@$branch" $st + fi + fi +} + +# Dir: current working directory +prompt_dir() { + local dir='' + local _context="$(context)" + [[ $BULLETTRAIN_DIR_CONTEXT_SHOW == true && -n "$_context" ]] && dir="${dir}${_context}:" + + if [[ $BULLETTRAIN_DIR_EXTENDED == 0 ]]; then + #short directories + dir="${dir}%1~" + elif [[ $BULLETTRAIN_DIR_EXTENDED == 2 ]]; then + #long directories + dir="${dir}%0~" + else + #medium directories (default case) + dir="${dir}%4(c:...:)%3c" + fi + + prompt_segment $BULLETTRAIN_DIR_BG $BULLETTRAIN_DIR_FG $dir +} + +# RUBY +# RVM: only shows RUBY info if on a gemset that is not the default one +# RBENV: shows current ruby version active in the shell; also with non-global gemsets if any is active +# CHRUBY: shows current ruby version active in the shell +prompt_ruby() { + if command -v rvm-prompt > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rvm-prompt i v g)" + elif command -v chruby > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(chruby | sed -n -e 's/ \* //p')" + elif command -v rbenv > /dev/null 2>&1; then + current_gemset() { + echo "$(rbenv gemset active 2&>/dev/null | sed -e 's/ global$//')" + } + + if [[ -n $(current_gemset) ]]; then + prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rbenv version | sed -e 's/ (set.*$//')"@"$(current_gemset)" + else + prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rbenv version | sed -e 's/ (set.*$//')" + fi + fi +} + +# ELIXIR +prompt_elixir() { + if command -v elixir > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_ELIXIR_BG $BULLETTRAIN_ELIXIR_FG $BULLETTRAIN_ELIXIR_PREFIX" $(elixir -v | tail -n 1 | awk '{print $2}')" + fi +} + +# PERL +# PLENV: shows current PERL version active in the shell +prompt_perl() { + if command -v plenv > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_PERL_BG $BULLETTRAIN_PERL_FG $BULLETTRAIN_PERL_PREFIX" $(plenv version | sed -e 's/ (set.*$//')" + fi +} + +# Go +prompt_go() { + setopt extended_glob + if [[ (-f *.go(#qN) || -d Godeps || -f glide.yaml) ]]; then + if command -v go > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_GO_BG $BULLETTRAIN_GO_FG $BULLETTRAIN_GO_PREFIX" $(go version | grep --colour=never -oE '[[:digit:]].[[:digit:]]+')" + fi + fi +} + +# Rust +prompt_rust() { + if [[ (-f Cargo.toml) ]]; then + if command -v rustc > /dev/null 2>&1; then + prompt_segment $BULLETTRAIN_RUST_BG $BULLETTRAIN_RUST_FG $BULLETTRAIN_RUST_PREFIX" $(rustc -V version | cut -d' ' -f2)" + fi + fi +} + +# Kubernetes Context +prompt_kctx() { + if [[ "$BULLETTRAIN_KCTX_KUBECTL" == "true" ]] && command -v kubectl > /dev/null 2>&1; then + local jsonpath='{.current-context}' + if [[ "$BULLETTRAIN_KCTX_NAMESPACE" == "true" ]]; then + jsonpath="${jsonpath}{':'}{..namespace}" + fi + prompt_segment $BULLETTRAIN_KCTX_BG $BULLETTRAIN_KCTX_FG $BULLETTRAIN_KCTX_PREFIX" $(kubectl config view --minify --output "jsonpath=${jsonpath}" 2>/dev/null)" + elif [[ -f $BULLETTRAIN_KCTX_KCONFIG ]]; then + prompt_segment $BULLETTRAIN_KCTX_BG $BULLETTRAIN_KCTX_FG $BULLETTRAIN_KCTX_PREFIX" $(cat $BULLETTRAIN_KCTX_KCONFIG | grep current-context | awk '{print $2}')" + fi +} + +# Virtualenv: current working virtualenv +prompt_virtualenv() { + local virtualenv_path="$VIRTUAL_ENV" + if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then + prompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_VIRTUALENV_PREFIX" $(basename $virtualenv_path)" + elif which pyenv &> /dev/null; then + if [[ "$(pyenv version | sed -e 's/ (set.*$//' | tr '\n' ' ' | sed 's/.$//')" != "system" ]]; then + prompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_VIRTUALENV_PREFIX" $(pyenv version | sed -e 's/ (set.*$//' | tr '\n' ' ' | sed 's/.$//')" + fi + fi +} + +# NVM: Node version manager +prompt_nvm() { + local nvm_prompt + if type nvm >/dev/null 2>&1; then + nvm_prompt=$(nvm current 2>/dev/null) + [[ "${nvm_prompt}x" == "x" || "${nvm_prompt}" == "system" ]] && return + elif type node >/dev/null 2>&1; then + nvm_prompt="$(node --version)" + else + return + fi + nvm_prompt=${nvm_prompt} + prompt_segment $BULLETTRAIN_NVM_BG $BULLETTRAIN_NVM_FG $BULLETTRAIN_NVM_PREFIX$nvm_prompt +} + +#AWS Profile +prompt_aws() { + local spaces=" " + + if [[ -n "$AWS_PROFILE" ]]; then + prompt_segment $BULLETTRAIN_AWS_BG $BULLETTRAIN_AWS_FG $BULLETTRAIN_AWS_PREFIX$spaces$AWS_PROFILE + fi +} + +# SCREEN Session +prompt_screen() { + local session_name="$STY" + if [[ "$session_name" != "" ]]; then + prompt_segment $BULLETTRAIN_SCREEN_BG $BULLETTRAIN_SCREEN_FG $BULLETTRAIN_SCREEN_PREFIX" $session_name" + fi +} + +prompt_time() { + if [[ $BULLETTRAIN_TIME_12HR == true ]]; then + prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG %D{%r} + else + prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG %D{%T} + fi +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 && $BULLETTRAIN_STATUS_EXIT_SHOW != true ]] && symbols+="✘" + [[ $RETVAL -ne 0 && $BULLETTRAIN_STATUS_EXIT_SHOW == true ]] && symbols+="✘ $RETVAL" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡%f" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="⚙" + + if [[ -n "$symbols" && $RETVAL -ne 0 ]]; then + prompt_segment $BULLETTRAIN_STATUS_ERROR_BG $BULLETTRAIN_STATUS_FG "$symbols" + elif [[ -n "$symbols" ]]; then + prompt_segment $BULLETTRAIN_STATUS_BG $BULLETTRAIN_STATUS_FG "$symbols" + fi + +} + +# Prompt Character +prompt_chars() { + local bt_prompt_chars="${BULLETTRAIN_PROMPT_CHAR}" + + if [[ $BULLETTRAIN_PROMPT_ROOT == true ]]; then + bt_prompt_chars="%(!.%F{red}# .%F{green}${bt_prompt_chars}%f)" + fi + + if [[ $BULLETTRAIN_PROMPT_SEPARATE_LINE == false ]]; then + bt_prompt_chars="${bt_prompt_chars}" + fi + + echo -n "$bt_prompt_chars" + + if [[ -n $BULLETTRAIN_PROMPT_CHAR ]]; then + echo -n " " + fi +} + +# Prompt Line Separator +prompt_line_sep() { + if [[ $BULLETTRAIN_PROMPT_SEPARATE_LINE == true ]]; then + # newline wont print without a non newline character, so add a zero-width space + echo -e '\n%{\u200B%}' + fi +} + +# ------------------------------------------------------------------------------ +# MAIN +# Entry point +# ------------------------------------------------------------------------------ + +build_prompt() { + RETVAL=$? + for segment in $BULLETTRAIN_PROMPT_ORDER + do + prompt_$segment + done + prompt_end +} + +NEWLINE=' +' +PROMPT='' +[[ $BULLETTRAIN_PROMPT_ADD_NEWLINE == true ]] && PROMPT="$PROMPT$NEWLINE" +PROMPT="$PROMPT"'%{%f%b%k%}$(build_prompt)' +[[ $BULLETTRAIN_PROMPT_SEPARATE_LINE == true ]] && PROMPT="$PROMPT$NEWLINE" +PROMPT="$PROMPT"'%{${fg_bold[default]}%}' +[[ $BULLETTRAIN_PROMPT_SEPARATE_LINE == false ]] && PROMPT="$PROMPT " +PROMPT="$PROMPT"'$(prompt_chars)%{$reset_color%}' diff --git a/assets/add_zsh_theme/color-input.zsh-theme b/assets/add_zsh_theme/color-input.zsh-theme new file mode 100644 index 0000000..a863802 --- /dev/null +++ b/assets/add_zsh_theme/color-input.zsh-theme @@ -0,0 +1,38 @@ +# Refer https://misc.flogisoft.com/bash/tip_colors_and_formatting for the ANSI/VT100 control sequences + +local user_color=026 +local dir_color=130 +local git_branch_color=010 +local input_color=220 + +# Uncomment the following line to hide the virtual environment name. +# export VIRTUAL_ENV_DISABLE_PROMPT=1 + +# User details in green, bold +local user='%B$FG[${user_color}]%}%n@%m%{$reset_color%}' +# Directory details in cyan, bold +local dir='%B$FG[${dir_color}]%~%{$reset_color%}' +# git branch details in green +local git_branch='$FG[${git_branch_color}]$(git_prompt_info)%{$reset_color%}' + +# Error message on command returning non-zero exit code +error_msg="\e[0;31mCommand failed" + +PROMPT="${user}:${dir}:${git_branch} +$ $FG[${input_color}]" + +# Resetting color to default white. +preexec() +{ + echo -ne "\e[0m" +} + +# Printing error message if command failed. +precmd() +{ + # Command failed + if [ $? -ne 0 ]; + then + echo "${error_msg}" + fi +} diff --git a/assets/add_zsh_theme/comfyline.zsh-theme b/assets/add_zsh_theme/comfyline.zsh-theme new file mode 100644 index 0000000..a97aa0d --- /dev/null +++ b/assets/add_zsh_theme/comfyline.zsh-theme @@ -0,0 +1,418 @@ +########################################## +### Comfyline - theme for zsh ### +# Original Author: not pua ( imnotpua ) # +# email: atp@tutamail.com # +########################################## + + +# make prompt work without oh-my-zsh +setopt PROMPT_SUBST +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 + +# default segment seperators +if [[ $COMFYLINE_SEGSEP == "" ]]; then + COMFYLINE_SEGSEP='\ue0b4' +fi + +if [[ $COMFYLINE_SEGSEP_REVERSE == "" ]]; then + COMFYLINE_SEGSEP_REVERSE='\ue0b6' +fi + +# date and time formats +if [[ $COMFYLINE_DATE_FORMAT == "" ]]; then + COMFYLINE_DATE_FORMAT="%A, %e %B %Y" +fi + +if [[ $COMFYLINE_TIME_FORMAT == "" ]]; then + COMFYLINE_TIME_FORMAT="%l:%M %p" +fi + +# default light theme +if [[ $RETVAL_RANK == "" ]]; then + RETVAL_RANK=1 +fi +if [[ $HOST_RANK == "" ]]; then + HOST_RANK=2 +fi +if [[ $USER_RANK == "" ]] then + USER_RANK=3 +fi +if [[ $DIR_RANK == "" ]]; then + DIR_RANK=4 +fi +if [[ $GIT_RANK == "" ]] then + GIT_RANK=5 +fi +if [[ $VENV_RANK = "" ]]; then + VENV_RANK=6 +fi +if [[ $BAT_RANK == "" ]] then + BAT_RANK=-3 +fi +if [[ $DATE_RANK == "" ]]; then + DATE_RANK=-2 +fi +if [[ $TIME_RANK == "" ]]; then + TIME_RANK=-1 +fi + +# default colors +if [[ $RETVAL_b == "" ]]; then + RETVAL_b="#8a8bd8" +fi +if [[ $RETVAL_f == "" ]]; then + RETVAL_f="#61355c" +fi +if [[ $HOST_b == "" ]]; then + HOST_b="#b3b5fb" +fi +if [[ $HOST_f == "" ]]; then + HOST_f="#4a4b87" +fi +if [[ $USER_b == "" ]]; then + USER_b="#f8bbe5" +fi +if [[ $USER_f == "" ]]; then + USER_f="#874c80" +fi +if [[ $GIT_b == "" ]]; then + GIT_b="#f6b3b3" +fi +if [[ $GIT_f == "" ]]; then + GIT_f="#d95353" +fi +if [[ $GIT_CLEAN_b == "" ]]; then + GIT_CLEAN_b="#b3f58c" +fi +if [[ $GIT_CLEAN_f == "" ]]; then + GIT_CLEAN_f="#568459" +fi +if [[ $DIR_b == "" ]]; then + DIR_b="#e1bff2" +fi +if [[ $DIR_f == "" ]]; then + DIR_f="#844189" +fi +if [[ $VENV_b == "" ]]; then + VENV_b="#a8ddf9" +fi +if [[ $VENV_f == "" ]]; then + VENV_f="#0066a4" +fi +if [[ $BAT_b == "" ]]; then + BAT_b="#b3b5fb" +fi +if [[ $BAT_f == "" ]]; then + BAT_f="#4a4b87" +fi +if [[ $DATE_b == "" ]]; then + DATE_b="#f8bbe5" +fi +if [[ $DATE_f == "" ]]; then + DATE_f="#874c80" +fi +if [[ $TIME_b == "" ]]; then + TIME_b="#e1bff2" +fi +if [[ $TIME_f == "" ]]; then + TIME_f="#844189" +fi + +# basic functions + +#function takes 4 arguments, background, foreground, text and rank (for edge cases) +function create_segment(){ + if [[ $4 -lt $RIGHTMOST_RANK ]]; then + local segment="%F{$1}$COMFYLINE_SEGSEP_REVERSE" + echo -n "$segment%K{$1}%F{$2} $3 " + elif [[ $4 -gt $LEFTMOST_RANK ]]; then + local segment="%K{$1}$COMFYLINE_SEGSEP " + echo -n "$segment%F{$2}$3%F{$1} " + elif [[ $4 -eq $RIGHTMOST_RANK ]]; then + if [[ $COMFYLINE_NO_START -eq 1 ]]; then + local segment="%F{$1}$COMFYLINE_SEGSEP_REVERSE" + echo -n "$segment%K{$1}%F{$2} $3" + else + local segment="%F{$1}$COMFYLINE_SEGSEP_REVERSE" + echo -n "$segment%K{$1}%F{$2} $3 %k%F{$1}$COMFYLINE_SEGSEP" + fi + elif [[ $4 -eq $LEFTMOST_RANK ]]; then + if [[ $COMFYLINE_NO_START -eq 1 ]]; then + local segment="%K{$1} " + echo -n "$segment%F{$2}$3%F{$1} " + else + local segment="%F{$1}$COMFYLINE_SEGSEP_REVERSE%K{$1} " + echo -n "$segment%F{$2}$3%F{$1} " + fi + fi + +} +### explanation: creates segment seperator with new bg but fg as old bg. +### then prints contents in new fg and prepares for next fg as current bg + +# segment functions +function retval(){ + if [[ $COMFYLINE_RETVAL_NUMBER -eq 2 ]]; then + symbol="%(?..✘ %?)" + elif [[ $COMFYLINE_RETVAL_NUMBER -eq 1 ]]; then + symbol="%?" + else + symbol="%(?..✘)" + fi + create_segment $RETVAL_b $RETVAL_f $symbol $RETVAL_RANK +} + +function hostname(){ + if [[ $COMFYLINE_FULL_HOSTNAME -eq 1 ]]; then + create_segment $HOST_b $HOST_f "%M" $HOST_RANK + else + create_segment $HOST_b $HOST_f "%m" $HOST_RANK + fi +} + +function username(){ + create_segment $USER_b $USER_f "%n" $USER_RANK +} + +function dir(){ + if [[ $COMFYLINE_FULL_DIR -eq 1 ]]; then + symbol="%d" + else + symbol="%~" + fi + create_segment $DIR_b $DIR_f $symbol $DIR_RANK +} + +# variables to set git_prompt info and status +ZSH_THEME_GIT_PROMPT_PREFIX=" \ue0a0 " +ZSH_THEME_GIT_PROMPT_SUFFIX="" +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_CLEAN="" +ZSH_THEME_GIT_PROMPT_ADDED=" ✚" +ZSH_THEME_GIT_PROMPT_MODIFIED=" ±" +ZSH_THEME_GIT_PROMPT_DELETED=" \u2796" +ZSH_THEME_GIT_PROMPT_UNTRACKED=" !" +ZSH_THEME_GIT_PROMPT_RENAMED=" \u21b7" +ZSH_THEME_GIT_PROMPT_UNMERGED=" \u21e1" +ZSH_THEME_GIT_PROMPT_AHEAD=" \u21c5" +ZSH_THEME_GIT_PROMPT_BEHIND=" \u21b1" +ZSH_THEME_GIT_PROMPT_DIVERGED=" \u21b0" + +function gitrepo(){ + if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then + if [[ $(git status --porcelain) == "" ]]; then + if [[ $(command -v git_prompt_info 2> /dev/null) ]]; then + create_segment $GIT_CLEAN_b $GIT_CLEAN_f "$(git_prompt_info)$(git_prompt_status)" $GIT_RANK + else + create_segment $GIT_CLEAN_b $GIT_CLEAN_f "$ZSH_THEME_GIT_PROMPT_PREFIX$(git rev-parse --abbrev-ref HEAD)" $GIT_RANK + fi + else + if [[ $(command -v git_prompt_info 2> /dev/null) ]]; then + create_segment $GIT_b $GIT_f "$(git_prompt_info)$(git_prompt_status)" $GIT_RANK + else + create_segment $GIT_b $GIT_f "$ZSH_THEME_GIT_PROMPT_PREFIX$(git rev-parse --abbrev-ref HEAD)" $GIT_RANK + fi + fi + fi +} + +function venv(){ + if [ -n "$VIRTUAL_ENV" ]; then + create_segment $VENV_b $VENV_f ${VIRTUAL_ENV:t:gs/%/%%} $VENV_RANK + fi +} + +# battery function + +# variables + +if [[ $COMFYLINE_BATTERY_LOW == "" ]]; then + COMFYLINE_BATTERY_LOW=15 +fi +if [[ $COMFYLINE_BATTERY_HIGH == "" ]]; then + COMFYLINE_BATTERY_HIGH=90 +fi +if [[ $COMFYLINE_CHARGING_ICON == "" ]]; then + COMFYLINE_CHARGING_ICON="⚡️" +fi +if [[ $COMFYLINE_HIGHCHARGE_ICON == "" ]]; then + COMFYLINE_HIGHCHARGE_ICON="󰁹" +fi +if [[ $COMFYLINE_MIDCHARGE_ICON == "" ]]; then + COMFYLINE_MIDCHARGE_ICON="󰁽" +fi +if [[ $COMFYLINE_LOWCHARGE_ICON == "" ]]; then + COMFYLINE_LOWCHARGE_ICON="󰂃" +fi + +function calcbat(){ + BAT="" + if [[ $(uname) == "Linux" ]]; then + number=$(ls /sys/class/power_supply/ | grep 'BAT' | wc -l ) + if [[ $number -eq 0 ]]; then + return 0 + fi + for ((i=0;i<$number;i++));do + capacity=$(cat /sys/class/power_supply/BAT${i}/capacity) + stats=$(cat /sys/class/power_supply/BAT${i}/status) + if [[ $stats == "Charging" ]]; then + stats="$COMFYLINE_CHARGING_ICON" + elif [[ $stats == "Discharging" ]]; then + if [ $capacity -gt $COMFYLINE_BATTERY_HIGH ]; then + stats="$COMFYLINE_HIGHCHARGE_ICON" + elif [ $capacity -lt $COMFYLINE_BATTERY_LOW ]; then + stats="$COMFYLINE_LOWCHARGE_ICON" + else + stats="$COMFYLINE_MIDCHARGE_ICON" + fi + elif [[ $stats == "Not charging" ]]; then + stats="$COMFYLINE_HIGHCHARGE_ICON" + fi + BAT="$BAT$capacity%% $stats " + done + + elif [[ $(uname) == "Darwin" ]]; then + battery_details = $(pmset -g batt) + charged=$(echo "$battery_details" | grep -w 'charged') + charging=$(echo "$battery_details" | grep -w 'AC Power') + discharging=$(echo "$battery_details" | grep -w 'Battery Power') + capacity=$(echo "$battery_details" | grep -o "([0-9]*)"%) + + if [ -n "$charging" ]; then + stats="$COMFYLINE_CHARGING_ICON" + elif [[ -n "$discharging" ]]; then + if [ $capacity -gt $COMFYLINE_BATTERY_HIGH ]; then + stats="$COMFYLINE_HIGHCHARGE_ICON" + elif [ $capacity -lt $COMFYLINE_BATTERY_LOW ]; then + stats="$COMFYLINE_LOWCHARGE_ICON" + else + stats="$COMFYLINE_MIDCHARGE_ICON" + fi + fi + BAT="$capacity%% $stats" + + elif [[ $(uname) == "FreeBSD" || $(uname) == "OpenBSD" ]]; then + capacity=$(apm -l) + stats=$(apm -b) + if [ $stats -eq 3 ]; then + stats="$COMFYLINE_CHARGING_ICON" + else + if [[ $capacity -gt $COMFYLINE_BATTERY_HIGH ]]; then + stats="$COMFYLINE_HIGHCHARGE_ICON" + elif [[ $capacity -lt $COMFYLINE_BATTERY_LOW ]]; then + stats="$COMFYLINE_LOWCHARGE_ICON" + else + stats="$COMFYLINE_MIDCHARGE_ICON" + fi + fi + BAT="$capacity%% $stats" + fi +} + +# function to call battery calculation +function currbat(){ + if [[ $COMFYLINE_BATTERY_PLUGIN -eq 1 ]]; then + create_segment $BAT_b $BAT_f "$(battery_pct_prompt)" $BAT_RANK + else + calcbat + create_segment $BAT_b $BAT_f "$BAT" $BAT_RANK + fi +} + +function currdate(){ + info="%D{$COMFYLINE_DATE_FORMAT}" + create_segment $DATE_b $DATE_f $info $DATE_RANK +} + +function currtime(){ + info="%D{$COMFYLINE_TIME_FORMAT}" + create_segment $TIME_b $TIME_f $info $TIME_RANK +} + +function endleft(){ + echo -n "%k$COMFYLINE_SEGSEP%f" +} + +# parse variables + +segments=("retval" "hostname" "username" "dir" "gitrepo" "venv" "currbat" "currtime" "currdate") +segment_ranks=($RETVAL_RANK $HOST_RANK $USER_RANK $DIR_RANK $GIT_RANK $VENV_RANK $BAT_RANK $TIME_RANK $DATE_RANK) + +# split into left and right + +left_prompt=() +right_prompt=() +left_ranks=() +right_ranks=() +for ((i=1;i<=${#segments[@]};i++)); do + if [[ segment_ranks[$i] -gt 0 ]]; then + left_prompt+=(${segments[$i]}) + left_ranks+=(${segment_ranks[$i]}) + elif [[ segment_ranks[$i] -lt 0 ]]; then + right_prompt+=(${segments[$i]}) + right_ranks+=(${segment_ranks[$i]#-}) + fi +done + +# sort the prompts according to ranks and find the leftmost and rightmost +# I use the traditional iterative method to find max/min and using count-sort for sorting + +LEFTMOST_RANK=100 +declare -A sorted_left +for ((i=1;i<=${#left_prompt[@]};i++)); do + if [[ $left_ranks[$i] -lt $LEFTMOST_RANK ]]; then LEFTMOST_RANK=$left_ranks[$i] fi + sorted_left[$left_ranks[$i]]="$left_prompt[$i]" +done + +RIGHTMOST_RANK=100 +declare -A sorted_right +for ((i=1;i<=${#right_prompt[@]};i++)); do + if [[ $right_ranks[$i] -lt $RIGHTMOST_RANK ]]; then RIGHTMOST_RANK=$right_ranks[$i] fi + sorted_right[$right_ranks[$i]]="$right_prompt[$i]" +done +((RIGHTMOST_RANK*=-1)) + + +# finally make_prompt which makes prompts +make_left_prompt(){ + for ((j = 1; j <= ${#left_prompt[@]}; j++)); do + type $sorted_left[$j] &>/dev/null && $sorted_left[$j] + done +} + +make_right_prompt(){ + for ((j = ${#right_prompt[@]}; j>0; j--)); do + type $sorted_right[$j] &>/dev/null && $sorted_right[$j] + done +} + +export PROMPT='%{%f%b%k%}$(make_left_prompt)$(endleft) ' +export RPROMPT=' %{%f%b%k%}$(make_right_prompt)' # spaces left so that hiding is triggered + +if [[ $COMFYLINE_NEXT_LINE_CHAR == "" ]]; then + COMFYLINE_NEXT_LINE_CHAR='➟' +fi + +if [[ $COMFYLINE_NEXT_LINE_CHAR_COLOR == "" ]]; then + COMFYLINE_NEXT_LINE_CHAR_COLOR="grey" +fi + +next_line_maker(){ + echo -n "%F{$COMFYLINE_NEXT_LINE_CHAR_COLOR}$COMFYLINE_NEXT_LINE_CHAR %f" +} + +# setting up typing area +if [[ COMFYLINE_START_NEXT_LINE -eq 2 ]]; then + +PROMPT=$PROMPT' +'$(next_line_maker) + + +elif [[ COMFYLINE_NO_GAP_LINE -eq 1 ]]; then +else + + PROMPT=' +'$PROMPT + +fi diff --git a/assets/add_zsh_theme/emoji.zsh-theme b/assets/add_zsh_theme/emoji.zsh-theme new file mode 100644 index 0000000..08ffaf6 --- /dev/null +++ b/assets/add_zsh_theme/emoji.zsh-theme @@ -0,0 +1,7 @@ +PROMPT=" %(?:%{$fg_bold[green]%}➜:%{$fg_bold[red]%}➜)" +PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✏️ " +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}) ✅" diff --git a/assets/add_zsh_theme/fishbone++.zsh-theme b/assets/add_zsh_theme/fishbone++.zsh-theme new file mode 100644 index 0000000..55af62e --- /dev/null +++ b/assets/add_zsh_theme/fishbone++.zsh-theme @@ -0,0 +1,60 @@ + +local username="%n" +local path_prefix="%{$fg[yellow]%}[" +local path_string="%{$fg[blue]%}%~" +local path_postfix="%{$fg[yellow]%}]" +local prompt_string="❯❯ " +local local_time="%T" +local newline=$'\n' +local line_mode=$'\n' + +# customize user settings +# prompt symbol +if [ ! -z "$FISHBONEPP_PROMPT" ]; then + prompt_string="$FISHBONEPP_PROMPT" +fi +# username +if [ ! -z "$FISHBONEPP_USER" ]; then + username="$FISHBONEPP_USER" +fi +# time mode +if [ "$FISHBONEPP_TIME" = "12HR" ]; then + local_time="%t" +elif [ "$FISHBONEPP_TIME" = "FULL" ]; then + local_time="%*" +else + local_time="%T" +fi +# new line on start +if [ "$FISHBONEPP_NEWLINE" = false ]; then + newline='' +fi +# line mode +if [ "$FISHBONEPP_LINE_MODE" = "singleline" ]; then + line_mode='' +fi + +local host_name="%{$fg[blue]%}${username}" +local time_string="%{$fg[blue]%}${local_time}" +# Make prompt_string red if the previous command failed. +local return_status="%(?:%{$fg[cyan]%}$prompt_string:%{$fg[red]%}$prompt_string%}" + + +# set the git_prompt_info text +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[blue](%{$reset_color%}%{$fg[yellow]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%{$fg[blue])%}" +ZSH_THEME_GIT_PROMPT_DIRTY="⚡" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +PROMPT='${newline}\ +${host_name}${hosr}%{$reset_color%}@${time_string} ${line_mode}\ +${path_prefix}${path_string}${path_postfix}$(git_prompt_info)$(git_prompt_status) \ +${return_status} %{$reset_color%}' + + +ZSH_THEME_GIT_PROMPT_ADDED="➕" +ZSH_THEME_GIT_PROMPT_MODIFIED="✒️ " +ZSH_THEME_GIT_PROMPT_DELETED="➖" +ZSH_THEME_GIT_PROMPT_RENAMED="⁉️ " +ZSH_THEME_GIT_PROMPT_UNMERGED="🥺" +ZSH_THEME_GIT_PROMPT_UNTRACKED="🚝" diff --git a/assets/fastfetch/config-pokemon.jsonc b/assets/fastfetch/config-pokemon.jsonc new file mode 100644 index 0000000..2b4522f --- /dev/null +++ b/assets/fastfetch/config-pokemon.jsonc @@ -0,0 +1,73 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "height": 5, + "width": 10, + "padding": { + "top": 1 + } + }, + "display": { + "separator": " -> " + }, + "modules": [ + "break", + { + "type": "title", + "keyWidth": 10, + "format": " {6}{7}{8}" + }, + { + "type": "custom", + "format": " ─────────────────────────── " + }, + { + "type": "kernel", + "key": " ", + "keyColor": "yellow" + }, + { + "type": "wm", + "key": " ", + "keyColor": "blue" + }, + { + "type": "shell", + "key": " ", + "keyColor": "yellow" + }, + { + "type": "terminal", + "key": " ", + "keyColor": "blue" + }, + /* + { + "type": "packages", + "key": "󰏖 ", + "keyColor": "yellow" + }, + */ + { + "type": "memory", + "key": "󰍛 ", + "keyColor": "magenta", + // format: used / total + "format": "{1} / {2}" + }, + { + "type": "uptime", + "key": "󰔛 ", + "keyColor": "green" + }, + { + "type": "custom", + "format": " ─────────────────────────── " + }, + { + "type": "custom", + "format": " \u001b[31m \u001b[32m \u001b[33m \u001b[34m \u001b[35m \u001b[36m \u001b[37m \u001b[90m " + }, + "break", + ] +} diff --git a/install-scripts/zsh_pokemon.sh b/install-scripts/zsh_pokemon.sh index b3a8692..c54f74b 100755 --- a/install-scripts/zsh_pokemon.sh +++ b/install-scripts/zsh_pokemon.sh @@ -26,10 +26,15 @@ fi # Check if ~/.zshrc exists if [ -f "$HOME/.zshrc" ]; then - sed -i '/#pokemon-colorscripts --no-title -s -r/s/^#//' "$HOME/.zshrc" >> "$LOG" 2>&1 + sed -i '/#pokemon-colorscripts --no-title -s -r | fastfetch -c $HOME\/.config\/fastfetch\/config-pokemon.jsonc --logo-type file-raw --logo-height 10 --logo-width 5 --logo -/s/^#//' "$HOME/.zshrc" >> "$LOG" 2>&1 sed -i '/^fastfetch -c $HOME\/.config\/fastfetch\/config-compact.jsonc/s/^/#/' "$HOME/.zshrc" >> "$LOG" 2>&1 else echo "$HOME/.zshrc not found. Cant enable ${YELLOW}Pokemon color scripts${RESET}" >> "$LOG" 2>&1 fi + +# copy additional oh-my-zsh themes from assets +if [ -d "$HOME/.oh-my-zsh/themes" ]; then + cp -r assets/add_zsh_theme/* ~/.oh-my-zsh/themes >> "$LOG" 2>&1 +fi printf "\n%.0s" {1..2}