Skip to content

Instantly share code, notes, and snippets.

@joe-sharp
Last active October 21, 2021 21:08
Show Gist options
  • Save joe-sharp/5b0c67179aa076ff53e7c03c4191eec3 to your computer and use it in GitHub Desktop.
Save joe-sharp/5b0c67179aa076ff53e7c03c4191eec3 to your computer and use it in GitHub Desktop.
My personal antigen themes
: ${omg_ungit_prompt:=$PS1}
: ${omg_second_line:="%B%F{6}%~%f%b ๐Ÿ”ฎ%B%F{235}โฏ%F{55}โฏ%F{27}โฏ%f%b "}
: ${omg_is_a_git_repo_symbol:='๏‚›'}
: ${omg_has_untracked_files_symbol:='๏žŸ'}
: ${omg_has_adds_symbol:='๏ง'}
: ${omg_has_deletions_symbol:='๏จ'}
: ${omg_has_cached_deletions_symbol:='๏€'}
: ${omg_has_modifications_symbol:='๏€'}
: ${omg_has_cached_modifications_symbol:='๏ƒถ'}
: ${omg_ready_to_commit_symbol:='๏…'}
: ${omg_is_on_a_tag_symbol:='๏€ซ'}
: ${omg_needs_to_merge_symbol:='แ„‰'}
: ${omg_detached_symbol:='๏„ง'}
: ${omg_can_fast_forward_symbol:='๏œ'}
: ${omg_has_diverged_symbol:='๎œฅ'}
: ${omg_not_tracked_branch_symbol:='๏„‰'}
: ${omg_rebase_tracking_branch_symbol:='๎œฆ'}
: ${omg_merge_tracking_branch_symbol:='๎œง'}
: ${omg_should_push_symbol:='๏ƒฎ'}
: ${omg_has_stashes_symbol:='๏ฐค'}
: ${omg_has_action_in_progress_symbol:='๏‚ญ'}
autoload -U colors && colors
PROMPT='$(build_prompt)'
#RPROMPT='%{$reset_color%}%T %{$fg_bold[cyan]%} %n@%m%{$reset_color%}'
function enrich_append {
local flag=$1
local symbol=$2
local color=${3:-$omg_default_color_on}
if [[ $flag == false ]]; then symbol=' '; fi
echo -n "${color}${symbol} "
}
function custom_build_prompt {
local enabled=${1}
local current_commit_hash=${2}
local is_a_git_repo=${3}
local current_branch=$4
local detached=${5}
local just_init=${6}
local has_upstream=${7}
local has_modifications=${8}
local has_modifications_cached=${9}
local has_adds=${10}
local has_deletions=${11}
local has_deletions_cached=${12}
local has_untracked_files=${13}
local ready_to_commit=${14}
local tag_at_current_commit=${15}
local is_on_a_tag=${16}
local has_upstream=${17}
local commits_ahead=${18}
local commits_behind=${19}
local has_diverged=${20}
local should_push=${21}
local will_rebase=${22}
local has_stashes=${23}
local action=${24}
local prompt=""
local original_prompt=$PS1
local black_on_white="%K{55}%F{cyan}"
local yellow_on_white="%K{55}%F{yellow}"
local red_on_white="%K{55}%F{red}"
local red_on_black="%K{black}%F{red}"
local black_on_red="%K{235}%F{27}"
local white_on_red="%K{235}%F{white}"
local yellow_on_red="%K{235}%F{yellow}"
# Flags
local omg_default_color_on="${black_on_white}"
local current_path="%~"
if [[ $is_a_git_repo == true ]]; then
# on filesystem
prompt="${black_on_white} "
prompt+=$(enrich_append $is_a_git_repo $omg_is_a_git_repo_symbol "${black_on_white}")
prompt+=$(enrich_append $has_stashes $omg_has_stashes_symbol "${yellow_on_white}")
prompt+=$(enrich_append $has_untracked_files $omg_has_untracked_files_symbol "${red_on_white}")
prompt+=$(enrich_append $has_modifications $omg_has_modifications_symbol "${red_on_white}")
prompt+=$(enrich_append $has_deletions $omg_has_deletions_symbol "${red_on_white}")
# ready
prompt+=$(enrich_append $has_adds $omg_has_adds_symbol "${black_on_white}")
prompt+=$(enrich_append $has_modifications_cached $omg_has_cached_modifications_symbol "${black_on_white}")
prompt+=$(enrich_append $has_deletions_cached $omg_has_cached_deletions_symbol "${black_on_white}")
# next operation
prompt+=$(enrich_append $ready_to_commit $omg_ready_to_commit_symbol "${red_on_white}")
prompt+=$(enrich_append $action "${omg_has_action_in_progress_symbol} $action" "${red_on_white}")
# where
prompt="${prompt} %K{235}%F{55}๎ƒ€ ${black_on_red}"
if [[ $detached == true ]]; then
prompt+=$(enrich_append $detached $omg_detached_symbol "${white_on_red}")
prompt+=$(enrich_append $detached "(${current_commit_hash:0:7})" "${black_on_red}")
else
if [[ $has_upstream == false ]]; then
prompt+=$(enrich_append true "-- ${omg_not_tracked_branch_symbol} -- (${current_branch})" "${black_on_red}")
else
if [[ $will_rebase == true ]]; then
local type_of_upstream=$omg_rebase_tracking_branch_symbol
else
local type_of_upstream=$omg_merge_tracking_branch_symbol
fi
if [[ $has_diverged == true ]]; then
prompt+=$(enrich_append true "-${commits_behind} ${omg_has_diverged_symbol} +${commits_ahead}" "${white_on_red}")
else
if [[ $commits_behind -gt 0 ]]; then
prompt+=$(enrich_append true "-${commits_behind} %F{white}${omg_can_fast_forward_symbol}%F{27} --" "${black_on_red}")
fi
if [[ $commits_ahead -gt 0 ]]; then
prompt+=$(enrich_append true "-- %F{white}${omg_should_push_symbol}%F{27} +${commits_ahead}" "${black_on_red}")
fi
if [[ $commits_ahead == 0 && $commits_behind == 0 ]]; then
prompt+=$(enrich_append true " -- -- " "${black_on_red}")
fi
fi
prompt+=$(enrich_append true "(${current_branch} ${type_of_upstream} ${upstream//\/$current_branch/})" "${black_on_red}")
fi
fi
prompt+=$(enrich_append ${is_on_a_tag} "${omg_is_on_a_tag_symbol} ${tag_at_current_commit}" "${black_on_red}")
prompt+="%k%F{235}๎ƒ€%f
${omg_second_line}"
else
prompt="${omg_ungit_prompt}"
fi
echo "${prompt}"
}
: ${omg_ungit_prompt:=$PS1}
: ${omg_second_line:="%B%F{6}%~%f%b ๐Ÿ”ฎ%B%F{235}โฏ%F{55}โฏ%F{27}โฏ%f%b "}
: ${omg_is_a_git_repo_symbol:='๐Ÿ™๐Ÿฑ'}
: ${omg_has_untracked_files_symbol:='๐Ÿ†•'}
: ${omg_has_adds_symbol:='โž•'}
: ${omg_has_deletions_symbol:='โž–'}
: ${omg_has_cached_deletions_symbol:='โœ–๏ธ'}
: ${omg_has_modifications_symbol:='โœ๏ธ'}
: ${omg_has_cached_modifications_symbol:='๐Ÿ“'}
: ${omg_ready_to_commit_symbol:='๐Ÿ”œ'}
: ${omg_is_on_a_tag_symbol:='๐Ÿท'}
: ${omg_needs_to_merge_symbol:='แ„‰'}
: ${omg_detached_symbol:='๐Ÿ”—'}
: ${omg_can_fast_forward_symbol:='โฉ'}
: ${omg_has_diverged_symbol:='ใ€ฝ๏ธ'}
: ${omg_not_tracked_branch_symbol:='๐Ÿ’ป'}
: ${omg_rebase_tracking_branch_symbol:='๐Ÿ–‡'}
: ${omg_merge_tracking_branch_symbol:='๐Ÿ“Ž'}
: ${omg_should_push_symbol:='๐Ÿ“ค'}
: ${omg_has_stashes_symbol:='๐ŸŽ'}
: ${omg_has_action_in_progress_symbol:='๐Ÿ”ง'}
autoload -U colors && colors
PROMPT='$(build_prompt)'
#RPROMPT='%{$reset_color%}%T %{$fg_bold[cyan]%} %n@%m%{$reset_color%}'
function enrich_append {
local flag=$1
local symbol=$2
local color=${3:-$omg_default_color_on}
if [[ $flag == false ]]; then symbol=' '; fi
echo -n "${color}${symbol} "
}
function custom_build_prompt {
local enabled=${1}
local current_commit_hash=${2}
local is_a_git_repo=${3}
local current_branch=$4
local detached=${5}
local just_init=${6}
local has_upstream=${7}
local has_modifications=${8}
local has_modifications_cached=${9}
local has_adds=${10}
local has_deletions=${11}
local has_deletions_cached=${12}
local has_untracked_files=${13}
local ready_to_commit=${14}
local tag_at_current_commit=${15}
local is_on_a_tag=${16}
local has_upstream=${17}
local commits_ahead=${18}
local commits_behind=${19}
local has_diverged=${20}
local should_push=${21}
local will_rebase=${22}
local has_stashes=${23}
local action=${24}
local prompt=""
local original_prompt=$PS1
local black_on_white="%K{55}%F{cyan}"
local yellow_on_white="%K{55}%F{yellow}"
local red_on_white="%K{55}%F{red}"
local red_on_black="%K{black}%F{red}"
local black_on_red="%K{235}%F{cyan}"
local white_on_red="%K{235}%F{white}"
local yellow_on_red="%K{235}%F{yellow}"
# Flags
local omg_default_color_on="${black_on_white}"
local current_path="%~"
if [[ $is_a_git_repo == true ]]; then
# on filesystem
prompt="${black_on_white} "
prompt+=$(enrich_append $is_a_git_repo $omg_is_a_git_repo_symbol "${black_on_white}")
prompt+=$(enrich_append $has_stashes $omg_has_stashes_symbol "${yellow_on_white}")
prompt+=$(enrich_append $has_untracked_files $omg_has_untracked_files_symbol "${red_on_white}")
prompt+=$(enrich_append $has_modifications $omg_has_modifications_symbol "${red_on_white}")
prompt+=$(enrich_append $has_deletions $omg_has_deletions_symbol "${red_on_white}")
# ready
prompt+=$(enrich_append $has_adds $omg_has_adds_symbol "${black_on_white}")
prompt+=$(enrich_append $has_modifications_cached $omg_has_cached_modifications_symbol "${black_on_white}")
prompt+=$(enrich_append $has_deletions_cached $omg_has_cached_deletions_symbol "${black_on_white}")
# next operation
prompt+=$(enrich_append $ready_to_commit $omg_ready_to_commit_symbol "${red_on_white}")
prompt+=$(enrich_append $action "${omg_has_action_in_progress_symbol} $action" "${red_on_white}")
# where
prompt="${prompt} %K{235}%F{55}๎‚ฐ ${black_on_red}"
if [[ $detached == true ]]; then
prompt+=$(enrich_append $detached $omg_detached_symbol "${white_on_red}")
prompt+=$(enrich_append $detached "(${current_commit_hash:0:7})" "${black_on_red}")
else
if [[ $has_upstream == false ]]; then
prompt+=$(enrich_append true "-- ${omg_not_tracked_branch_symbol} -- (${current_branch})" "${black_on_red}")
else
if [[ $will_rebase == true ]]; then
local type_of_upstream=$omg_rebase_tracking_branch_symbol
else
local type_of_upstream=$omg_merge_tracking_branch_symbol
fi
if [[ $has_diverged == true ]]; then
prompt+=$(enrich_append true "-${commits_behind} ${omg_has_diverged_symbol} +${commits_ahead}" "${white_on_red}")
else
if [[ $commits_behind -gt 0 ]]; then
prompt+=$(enrich_append true "-${commits_behind} %F{white}${omg_can_fast_forward_symbol}%F{cyan} --" "${black_on_red}")
fi
if [[ $commits_ahead -gt 0 ]]; then
prompt+=$(enrich_append true "-- %F{white}${omg_should_push_symbol}%F{cyan} +${commits_ahead}" "${black_on_red}")
fi
if [[ $commits_ahead == 0 && $commits_behind == 0 ]]; then
prompt+=$(enrich_append true " -- -- " "${black_on_red}")
fi
fi
prompt+=$(enrich_append true "(${current_branch} ${type_of_upstream} ${upstream//\/$current_branch/})" "${black_on_red}")
fi
fi
prompt+=$(enrich_append ${is_on_a_tag} "${omg_is_on_a_tag_symbol} ${tag_at_current_commit}" "${black_on_red}")
prompt+="%k%F{235}๎‚ฐ%f
${omg_second_line}"
else
prompt="${omg_ungit_prompt}"
fi
echo "${prompt}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment