#!/bin/zsh # Headline ZSH Prompt # Copyright (c) 2021 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 # (dont change these definitions, apply them below) 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 # (dont change these definitions, apply them below) 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' # User defined 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=$? # ------------------------------------------------------------------------------ # Customization # I recommend setting these variables in your ~/.zshrc after sourcing this file # The style aliases for ANSI SGR codes (defined above) can be used there too # Options HEADLINE_LINE_MODE='off' # on|auto|off (whether to print the line above the prompt) 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) # Segments HEADLINE_DO_USER='true' HEADLINE_DO_HOST='true' HEADLINE_DO_PATH='true' HEADLINE_DO_GIT_BRANCH='true' HEADLINE_DO_GIT_STATUS='true' # Prompt character HEADLINE_PROMPT="%(#.#.%(!.!.$)) " # consider "%#" # Repeated characters (no styles here) HEADLINE_LINE_CHAR='_' # line above information HEADLINE_PAD_CHAR=' ' # space between and # Prefixes (optional) HEADLINE_USER_PREFIX='' # consider " " HEADLINE_HOST_PREFIX='' # consider " " HEADLINE_PATH_PREFIX='' # consider " " HEADLINE_BRANCH_PREFIX='' # consider " " # Joints HEADLINE_USER_BEGIN='' 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 styles (ANSI SGR codes) HEADLINE_STYLE_DEFAULT='' # style applied to entire info line HEADLINE_STYLE_JOINT=$light_black if [ $IS_SSH = 0 ]; then HEADLINE_STYLE_USER=$bold$magenta else HEADLINE_STYLE_USER=$bold$red fi HEADLINE_STYLE_HOST=$bold$yellow HEADLINE_STYLE_PATH=$bold$blue HEADLINE_STYLE_BRANCH=$bold$cyan HEADLINE_STYLE_STATUS=$bold$magenta # Line 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 options HEADLINE_DO_GIT_STATUS_COUNTS='false' # set "true" to show count of each status HEADLINE_DO_GIT_STATUS_OMIT_ONE='false' # set "true" to omit the status number when it is 1 # Git status styles and characters # To set individual status styles use "%{$reset