Created
September 5, 2023 02:05
-
-
Save 8vius/125bb3e492ebdeee56e973196654a5a3 to your computer and use it in GitHub Desktop.
bash profile
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
function ps1_powerline { | |
RETCODE=$? # save return code | |
NUM_JOBS=$(jobs -rp | wc -l) | |
GIT_BRANCH=$(__git_ps1) | |
RUBY=$(prompt_rvm) | |
# local GREY="\[\e[48;5;240m\]\[\e[38;5;250m\]" | |
# local GREY_END="\[\e[48;5;2m\]\[\e[38;5;240m\]" | |
local GREEN="\[\e[48;5;2m\]\[\e[38;5;255m\]" | |
local GREEN_END="\[\e[48;5;27m\]\[\e[38;5;2m\]" | |
local ORANGE="\[\e[48;5;208m\]\[\e[38;5;255m\]" | |
local ORANGE_END="\[\e[48;5;236m\]\[\e[38;5;208m\]" | |
local ORANGE_RET_END="\[\e[48;5;160m\]\[\e[38;5;208m\]" # when next segment is prompt with return code | |
local BLUE="\[\e[48;5;27m\]\[\e[38;5;255m\]" | |
local BLUE_END="\[\e[48;5;208m\]\[\e[38;5;27m\]" # when next segment is git | |
local BLUE_END_JOBS="\[\e[48;5;93m\]\[\e[38;5;27m\]" # when next segment is jobs | |
local BLUE_END_ALT="\[\e[48;5;236m\]\[\e[38;5;27m\]" # when next segment is prompt | |
local BLUE_END_RET="\[\e[48;5;160m\]\[\e[38;5;27m\]" # when next segment is prompt with return code | |
local JOBS="\[\e[48;5;93m\]\[\e[38;5;255m\] ⏎" | |
local JOBS_END="\[\e[48;5;236m\]\[\e[38;5;93m\]" # when next segment is prompt | |
local JOBS_NO_RET_END="\[\e[48;5;208m\]\[\e[38;5;93m\]" # when next segment is git | |
local JOBS_NO_GIT_END="\[\e[48;5;160m\]\[\e[38;5;93m\]" # when next segment is prompt with return code | |
local RET="\[\e[48;5;160m\]\[\e[38;5;255m\]" | |
local RET_END="\[\e[0m\]\[\e[38;5;160m\]\[\e[0m\] " | |
local PROMPT="\[\e[48;5;236m\]\[\e[38;5;255m\]" | |
local PROMPT_END="\[\e[0m\]\[\e[38;5;236m\]\[\e[0m\] " | |
# Display Ruby version | |
BLUE_END="\[\e[48;5;160m\]\[\e[38;5;27m\]\[\e[38;5;255m\] $RUBY \[\e[48;5;208m\]\[\e[38;5;160m\]" | |
BLUE_END_JOBS="\[\e[48;5;160m\]\[\e[38;5;27m\]\[\e[38;5;255m\] $RUBY \[\e[48;5;93m\]\[\e[38;5;160m\]" | |
BLUE_END_ALT="\[\e[48;5;160m\]\[\e[38;5;27m\]\[\e[38;5;255m\] $RUBY \[\e[48;5;236m\]\[\e[38;5;160m\]" | |
BLUE_END_RET="\[\e[48;5;160m\]\[\e[38;5;27m\]\[\e[38;5;255m\] $RUBY " | |
if [ -z "$GIT_BRANCH" ]; then | |
# Is not a git repo | |
if [ "$RETCODE" -eq 0 ]; then | |
if [ "$NUM_JOBS" -eq 0 ]; then | |
# No jobs or ret code | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_ALT$PROMPT \$ $PROMPT_END" | |
else | |
# no ret code but jobs | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_JOBS$JOBS$NUM_JOBS $JOBS_END$PROMPT \$ $PROMPT_END" | |
fi | |
else | |
if [ "$NUM_JOBS" -eq 0 ]; then | |
# No jobs but ret code is there | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_RET$RET \$ ⚑ $RETCODE $RET_END" | |
else | |
# Both jobs and ret code | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_JOBS$JOBS$NUM_JOBS $JOBS_NO_GIT_END$RET \$ ⚑ $RETCODE $RET_END" | |
fi | |
fi | |
else | |
if [ "$RETCODE" -eq 0 ]; then | |
if [ "$NUM_JOBS" -eq 0 ]; then | |
# No jobs or ret code | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END$ORANGE $GIT_BRANCH$ORANGE_END $GIT_STATUS$PROMPT \$ $PROMPT_END" | |
else | |
# no ret code but jobs | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_JOBS$JOBS$NUM_JOBS $JOBS_NO_RET_END$ORANGE $GIT_BRANCH$ORANGE_END $GIT_STATUS$PROMPT \$ $PROMPT_END" | |
fi | |
else | |
if [ "$NUM_JOBS" -eq 0 ]; then | |
# No jobs but ret code is there | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END$ORANGE $GIT_BRANCH$ORANGE_END $GIT_STATUS$RET \$ ⚑ $RETCODE $RET_END" | |
else | |
# Both jobs and ret code | |
PS1="$GREEN @$USER $GREEN_END$BLUE \W $BLUE_END_JOBS$JOBS$NUM_JOBS $JOBS_NO_RET_END$ORANGE $GIT_BRANCH$ORANGE_END $GIT_STATUS$RET \$ ⚑ $RETCODE $RET_END" | |
fi | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment