Skip to content

Instantly share code, notes, and snippets.

@piotrgredowski
Last active May 8, 2022 10:48
Show Gist options
  • Save piotrgredowski/2398143fa0f5e4893f4e4c9a3886c5b4 to your computer and use it in GitHub Desktop.
Save piotrgredowski/2398143fa0f5e4893f4e4c9a3886c5b4 to your computer and use it in GitHub Desktop.
function git_tag() {
echo -n $(git tag --points-at HEAD)
}
function git_tag_formatted() {
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
if [ "$inside_git_repo" ]; then
if [ -z $(git_tag) ]; then
echo -n
else
echo -n "(%{$fg[yellow]%}$(git_tag)%{$reset_color%})"
fi
else
echo -n
fi
}
function get_user_and_host() {
color=$1
echo -n "%{$fg_bold[$color]%}%n@%m"
}
function get_current_time() {
echo -n "%{$fg[blue]%}%D{[%X]}%{$reset_color%}"
}
function get_current_path() {
echo -n "%{$fg[white]%}[%~]"
}
function get_command_line() {
echo "%{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%}"
}
USER_COLOR="green"
ROOT_COLOR="red"
if [[ $UID -eq 0 ]]; then
COLOR=$ROOT_COLOR
else
COLOR=$USER_COLOR
fi
PROMPT="$(get_user_and_host $COLOR) $(get_current_time) $(get_current_path) $(git_tag_formatted)
$(get_command_line) "
# PROMPT="$(get_user_and_host $COLOR) $(get_current_time) $(get_current_path) $(git_prompt_info) $(git_tag_formatted)
# $(get_command_line) "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment