#!/bin/zsh # Headline ZSH Prompt # Copyright (c) 2022 Moarram under the MIT License # To install, source this file from your .zshrc file # Customization variables begin around line 70 # Formatting aliases # (add more if you need) reset=$'\e[0m' bold=$'\e[1m' faint=$'\e[2m' italic=$'\e[3m' underline=$'\e[4m' invert=$'\e[7m' # ... # Foreground color aliases black=$'\e[30m' red=$'\e[31m' green=$'\e[32m' yellow=$'\e[33m' blue=$'\e[34m' magenta=$'\e[35m' cyan=$'\e[36m' white=$'\e[37m' light_black=$'\e[90m' light_red=$'\e[91m' light_green=$'\e[92m' light_yellow=$'\e[93m' light_blue=$'\e[94m' light_magenta=$'\e[95m' light_cyan=$'\e[96m' light_white=$'\e[97m' # Background color aliases black_back=$'\e[40m' red_back=$'\e[41m' green_back=$'\e[42m' yellow_back=$'\e[43m' blue_back=$'\e[44m' magenta_back=$'\e[45m' cyan_back=$'\e[46m' white_back=$'\e[47m' light_black_back=$'\e[100m' light_red_back=$'\e[101m' light_green_back=$'\e[102m' light_yellow_back=$'\e[103m' light_blue_back=$'\e[104m' light_magenta_back=$'\e[105m' light_cyan_back=$'\e[106m' light_white_back=$'\e[107m' # Custom colors # REF: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters # orange_yellow=$'\e[38;5;214m' # example 8-bit color # orange_brown=$'\e[38;2;191;116;46m' # example rgb color # ... # Flags ! [ -z "$SSH_TTY$SSH_CONNECTION$SSH_CLIENT" ] IS_SSH=$? # 0=true, 1=false # ------------------------------------------------------------------------------ # Customization # Use the following variables to customize the theme # These variables can also be set in your ~/.zshrc after sourcing this file # The style aliases for ANSI SGR codes (defined above) can be used there too # Info sources (enclose in single quotes as these will be eval'd, use empty string to hide segment) HEADLINE_USER_CMD='echo $USER' HEADLINE_HOST_CMD='hostname -s' # consider 'basename "$VIRTUAL_ENV"' to replace host with environment HEADLINE_PATH_CMD='print -rP "%~"' HEADLINE_GIT_BRANCH_CMD='headline_git_branch' HEADLINE_GIT_STATUS_CMD='headline_git_status' # Info symbols (optional) HEADLINE_USER_PREFIX='' # consider " " HEADLINE_HOST_PREFIX='' # consider " " HEADLINE_PATH_PREFIX='' # consider " " HEADLINE_BRANCH_PREFIX='' # consider " " # Info joints HEADLINE_USER_BEGIN='' if [ $IS_SSH = 0 ]; then HEADLINE_USER_BEGIN='=> '; fi HEADLINE_USER_TO_HOST=' @ ' HEADLINE_HOST_TO_PATH=': ' HEADLINE_PATH_TO_BRANCH=' | ' # only used when no padding between and HEADLINE_PATH_TO_PAD='' # used if padding between and HEADLINE_PAD_TO_BRANCH='' # used if padding between and HEADLINE_BRANCH_TO_STATUS=' [' HEADLINE_STATUS_TO_STATUS='' # between each status section, consider "]" HEADLINE_STATUS_END=']' # Info padding character HEADLINE_PAD_CHAR=' ' # repeated for space between and # Info truncation symbol HEADLINE_TRUNC_PREFIX='...' # shown where or is truncated, consider "…" # Info styles HEADLINE_STYLE_DEFAULT='' # style applied to entire info line HEADLINE_STYLE_JOINT=$light_black HEADLINE_STYLE_USER=$bold$red HEADLINE_STYLE_HOST=$bold$yellow HEADLINE_STYLE_PATH=$bold$blue HEADLINE_STYLE_BRANCH=$bold$cyan HEADLINE_STYLE_STATUS=$bold$magenta # Info options HEADLINE_INFO_MODE=precmd # precmd|prompt (whether info line is in PROMPT or printed by precmd) # use "precmd" for window resize to work properly (but Ctrl+L doesn't show info line) # use "prompt" for Ctrl+L to clear properly (but window resize eats previous output) # Separator options HEADLINE_LINE_MODE=on # on|auto|off (whether to print the line above the prompt) # Separator character HEADLINE_LINE_CHAR='_' # repeated for line above information # Separator styles HEADLINE_STYLE_JOINT_LINE=$HEADLINE_STYLE_JOINT HEADLINE_STYLE_USER_LINE=$HEADLINE_STYLE_USER HEADLINE_STYLE_HOST_LINE=$HEADLINE_STYLE_HOST HEADLINE_STYLE_PATH_LINE=$HEADLINE_STYLE_PATH HEADLINE_STYLE_BRANCH_LINE=$HEADLINE_STYLE_BRANCH HEADLINE_STYLE_STATUS_LINE=$HEADLINE_STYLE_STATUS # Git branch characters HEADLINE_GIT_HASH=':' # hash prefix to distinguish from branch # Git status characters # To set individual status styles use "%{$reset