From 795dc4d0a2399963a5b875824a4fa1c92e536db6 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 8 Mar 2018 06:28:35 +0400 Subject: [PATCH 01/55] Moved all segments into their own files Have moved all segments into their own files except prompt_vi_mode. Have to move icon definitions into they files next. --- powerlevel9k.zsh-theme | 1371 +--------------------- segments/core/background_jobs.p9k | 18 + segments/core/battery.p9k | 111 ++ segments/core/command_execution_time.p9k | 33 + segments/core/context.p9k | 41 + segments/core/date.p9k | 7 + segments/core/dir.p9k | 263 +++++ segments/core/dir_writable.p9k | 7 + segments/core/disk_usage.p9k | 42 + segments/core/history.p9k | 5 + segments/core/host.p9k | 25 + segments/core/ip.p9k | 31 + segments/core/load.p9k | 56 + segments/core/newline.p9k | 17 + segments/core/os_icon.p9k | 5 + segments/core/public_ip.p9k | 79 ++ segments/core/ram.p9k | 23 + segments/core/root_indicator.p9k | 7 + segments/core/ssh.p9k | 7 + segments/core/status.p9k | 55 + segments/core/swap.p9k | 25 + segments/core/test_stats.p9k | 15 + segments/core/time.p9k | 7 + segments/core/user.p9k | 36 + segments/core/vpn_ip.p9k | 11 + segments/developer/anaconda.p9k | 13 + segments/developer/aws.p9k | 9 + segments/developer/aws_eb_env.p9k | 9 + segments/developer/chruby.p9k | 11 + segments/developer/detect_virt.p9k | 18 + segments/developer/docker_machine.p9k | 9 + segments/developer/go_version.p9k | 12 + segments/developer/kubecontext.p9k | 26 + segments/developer/node_env.p9k | 9 + segments/developer/node_version.p9k | 8 + segments/developer/nvm.p9k | 15 + segments/developer/php_version.p9k | 10 + segments/developer/pyenv.p9k | 8 + segments/developer/rbenv.p9k | 15 + segments/developer/rspec_stats.p9k | 11 + segments/developer/rust_version.p9k | 10 + segments/developer/rvm.p9k | 9 + segments/developer/swift_version.p9k | 11 + segments/developer/symfony2_tests.p9k | 11 + segments/developer/symfony2_version.p9k | 9 + segments/developer/vcs.p9k | 92 ++ segments/developer/virtualenv.p9k | 10 + segments/other/dropbox.p9k | 17 + segments/other/icons_test.p9k | 11 + segments/other/openfoam.p9k | 11 + segments/other/todo.p9k | 10 + 51 files changed, 1322 insertions(+), 1359 deletions(-) create mode 100644 segments/core/background_jobs.p9k create mode 100644 segments/core/battery.p9k create mode 100644 segments/core/command_execution_time.p9k create mode 100644 segments/core/context.p9k create mode 100644 segments/core/date.p9k create mode 100644 segments/core/dir.p9k create mode 100644 segments/core/dir_writable.p9k create mode 100644 segments/core/disk_usage.p9k create mode 100644 segments/core/history.p9k create mode 100644 segments/core/host.p9k create mode 100644 segments/core/ip.p9k create mode 100644 segments/core/load.p9k create mode 100644 segments/core/newline.p9k create mode 100644 segments/core/os_icon.p9k create mode 100644 segments/core/public_ip.p9k create mode 100644 segments/core/ram.p9k create mode 100644 segments/core/root_indicator.p9k create mode 100644 segments/core/ssh.p9k create mode 100644 segments/core/status.p9k create mode 100644 segments/core/swap.p9k create mode 100644 segments/core/test_stats.p9k create mode 100644 segments/core/time.p9k create mode 100644 segments/core/user.p9k create mode 100644 segments/core/vpn_ip.p9k create mode 100644 segments/developer/anaconda.p9k create mode 100644 segments/developer/aws.p9k create mode 100644 segments/developer/aws_eb_env.p9k create mode 100644 segments/developer/chruby.p9k create mode 100644 segments/developer/detect_virt.p9k create mode 100644 segments/developer/docker_machine.p9k create mode 100644 segments/developer/go_version.p9k create mode 100644 segments/developer/kubecontext.p9k create mode 100644 segments/developer/node_env.p9k create mode 100644 segments/developer/node_version.p9k create mode 100644 segments/developer/nvm.p9k create mode 100644 segments/developer/php_version.p9k create mode 100644 segments/developer/pyenv.p9k create mode 100644 segments/developer/rbenv.p9k create mode 100644 segments/developer/rspec_stats.p9k create mode 100644 segments/developer/rust_version.p9k create mode 100644 segments/developer/rvm.p9k create mode 100644 segments/developer/swift_version.p9k create mode 100644 segments/developer/symfony2_tests.p9k create mode 100644 segments/developer/symfony2_version.p9k create mode 100644 segments/developer/vcs.p9k create mode 100644 segments/developer/virtualenv.p9k create mode 100644 segments/other/dropbox.p9k create mode 100644 segments/other/icons_test.p9k create mode 100644 segments/other/openfoam.p9k create mode 100644 segments/other/todo.p9k diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8379f68a1..14b1fd027 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -66,9 +66,6 @@ source "${p9k_directory}/functions/colors.zsh" source "${p9k_directory}/functions/vcs.zsh" -# cleanup temporary variables. -unset p9k_directory - ################################################################ # Color Scheme ################################################################ @@ -273,417 +270,6 @@ right_prompt_segment() { # right-left but reads the opposite, this isn't necessary for the other side. CURRENT_BG='NONE' -################################################################ -# Anaconda Environment -prompt_anaconda() { - # Depending on the conda version, either might be set. This - # variant works even if both are set. - _path=$CONDA_ENV_PATH$CONDA_PREFIX - if ! [ -z "$_path" ]; then - # config - can be overwritten in users' zshrc file. - set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" - set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' - fi -} - -################################################################ -# AWS Profile -prompt_aws() { - local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" - - if [[ -n "$aws_profile" ]]; then - "$1_prompt_segment" "$0" "$2" red white "$aws_profile" 'AWS_ICON' - fi -} - -################################################################ -# Current Elastic Beanstalk environment -prompt_aws_eb_env() { - local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') - - if [[ -n "$eb_env" ]]; then - "$1_prompt_segment" "$0" "$2" black green "$eb_env" 'AWS_EB_ICON' - fi -} - -################################################################ -# Segment to indicate background jobs with an icon. -set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true -set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false -prompt_background_jobs() { - local background_jobs_number=${$(jobs -l | wc -l)// /} - local wrong_lines=`jobs -l | awk '/pwd now/{ count++ } END {print count}'` - if [[ wrong_lines -gt 0 ]]; then - background_jobs_number=$(( $background_jobs_number - $wrong_lines )) - fi - if [[ background_jobs_number -gt 0 ]]; then - local background_jobs_number_print="" - if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then - background_jobs_number_print="$background_jobs_number" - fi - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' - fi -} - -################################################################ -# A newline in your prompt, so you can segments on multiple lines. -prompt_newline() { - local lws newline - [[ "$1" == "right" ]] && return - newline=$'\n' - lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS - if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then - newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" - fi - POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= - "$1_prompt_segment" \ - "$0" \ - "$2" \ - "NONE" "NONE" "${newline}" - POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws -} - -################################################################ -# Segment that indicates usage level of current partition. -set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 -set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 -prompt_disk_usage() { - local current_state="unknown" - typeset -AH hdd_usage_forecolors - hdd_usage_forecolors=( - 'normal' 'yellow' - 'warning' "$DEFAULT_COLOR" - 'critical' 'white' - ) - typeset -AH hdd_usage_backcolors - hdd_usage_backcolors=( - 'normal' $DEFAULT_COLOR - 'warning' 'yellow' - 'critical' 'red' - ) - - local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" - - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then - current_state='warning' - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then - current_state='critical' - fi - else - if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then - current_state='' - return - fi - current_state='normal' - fi - - local message="${disk_usage}%%" - - # Draw the prompt_segment - if [[ -n $disk_usage ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' - fi -} - -################################################################ -# Segment that displays the battery status in levels and colors -prompt_battery() { - # The battery can have four different states - default to 'unknown'. - local current_state='unknown' - typeset -AH battery_states - battery_states=( - 'low' 'red' - 'charging' 'yellow' - 'charged' 'green' - 'disconnected' "$DEFAULT_COLOR_INVERTED" - ) - # Set default values if the user did not configure them - set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 - - if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then - # obtain battery information from system - local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" - # return if there is no battery on system - [[ -z $(echo $raw_data | grep "InternalBattery") ]] && return - - # Time remaining on battery operation (charging/discharging) - local tstring=$(echo $raw_data | awk -F ';' '{print $3}' | awk '{print $1}') - # If time has not been calculated by system yet - [[ $tstring =~ '(\(no|not)' ]] && tstring="..." - - # percent of battery charged - typeset -i 10 bat_percent - bat_percent=$(echo $raw_data | grep -o '[0-9]*%' | sed 's/%//') - - local remain="" - # Logic for string output - case $(echo $raw_data | awk -F ';' '{print $2}' | awk '{$1=$1};1') in - # for a short time after attaching power, status will be 'AC attached;' - 'charging'|'finishing charge'|'AC attached') - current_state="charging" - remain=" ($tstring)" - ;; - 'discharging') - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" - remain=" ($tstring)" - ;; - *) - current_state="charged" - ;; - esac - fi - - if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then - local sysp="/sys/class/power_supply" - - # Reported BAT0 or BAT1 depending on kernel version - [[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0 - [[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1 - - # Android-related - # Tested on: Moto G falcon (CM 13.0) - [[ -a $sysp/battery ]] && local bat=$sysp/battery - - # Return if no battery found - [[ -z $bat ]] && return - local capacity=$(cat $bat/capacity) - local battery_status=$(cat $bat/status) - [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity - [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true - if [[ -z $connected ]]; then - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" - else - [[ $bat_percent =~ 100 ]] && current_state="charged" - [[ $bat_percent -lt 100 ]] && current_state="charging" - fi - if [[ -f /usr/bin/acpi ]]; then - local time_remaining=$(acpi | awk '{ print $5 }') - if [[ $time_remaining =~ rate ]]; then - local tstring="..." - elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then - local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M 2> /dev/null)} - fi - fi - [[ -n $tstring ]] && local remain=" ($tstring)" - fi - - local message - # Default behavior: Be verbose! - set_default POWERLEVEL9K_BATTERY_VERBOSE true - if [[ "$POWERLEVEL9K_BATTERY_VERBOSE" == true ]]; then - message="$bat_percent%%$remain" - else - message="$bat_percent%%" - fi - - # override default icon if we are using battery stages - if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) - if [[ $segment > 1 ]]; then - local offset=$(( ($bat_percent / $segment) + 1 )) - # check if the stages are in an array or a string - [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} - fi - fi - - # override the default color if we are using a color level array - if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) - local offset=$(( ($bat_percent / $segment) + 1 )) - "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" - else - # Draw the prompt_segment - "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" - fi -} - -################################################################ -# Public IP segment -# Parameters: -# * $1 Alignment: string - left|right -# * $2 Index: integer -# * $3 Joined: bool - If the segment should be joined -prompt_public_ip() { - # set default values for segment - set_default POWERLEVEL9K_PUBLIC_IP_TIMEOUT "300" - set_default POWERLEVEL9K_PUBLIC_IP_NONE "" - set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" - set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" - defined POWERLEVEL9K_PUBLIC_IP_METHODS || POWERLEVEL9K_PUBLIC_IP_METHODS=(dig curl wget) - - # Do we need a fresh IP? - local refresh_ip=false - if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - typeset -i timediff - # if saved IP is more than - if [[ "$OS" == "OSX" ]]; then - timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) - else - timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - fi - [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true - # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true - [[ -n $POWERLEVEL9K_PUBLIC_IP_NONE ]] && [[ $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true - else - touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true - fi - - # grab a fresh IP if needed - local fresh_ip - if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - for method in "${POWERLEVEL9K_PUBLIC_IP_METHODS[@]}"; do - case $method in - 'dig') - fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" - [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip - ;; - 'curl') - fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" - ;; - 'wget') - fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" - ;; - esac - # If we found a fresh IP, break loop. - if [[ -n "${fresh_ip}" ]]; then - break; - fi - done - - # write IP to tmp file or clear tmp file if an IP was not retrieved - # Redirection with `>!`. From the manpage: Same as >, except that the file - # is truncated to zero length if it exists, even if CLOBBER is unset. - # If the file already exists, and a simple `>` redirection and CLOBBER - # unset, ZSH will produce an error. - [[ -n "${fresh_ip}" ]] && echo $fresh_ip >! $POWERLEVEL9K_PUBLIC_IP_FILE || echo $POWERLEVEL9K_PUBLIC_IP_NONE >! $POWERLEVEL9K_PUBLIC_IP_FILE - fi - - # read public IP saved to tmp file - local public_ip="$(cat $POWERLEVEL9K_PUBLIC_IP_FILE)" - - # Draw the prompt segment - if [[ -n $public_ip ]]; then - icon='PUBLIC_IP_ICON' - # Check VPN is on if VPN interface is set - if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then - for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) - do - icon='VPN_ICON' - break - done - fi - $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" - fi -} - -################################################################ -# Context: user@hostname (who am I and where am I) -# Note that if $DEFAULT_USER is not set, this prompt segment will always print -set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false -set_default POWERLEVEL9K_ALWAYS_SHOW_USER false -set_default POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" -prompt_context() { - local current_state="DEFAULT" - typeset -AH context_states - context_states=( - "ROOT" "yellow" - "SUDO" "yellow" - "DEFAULT" "yellow" - "REMOTE" "yellow" - "REMOTE_SUDO" "yellow" - ) - - local content="" - - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then - content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" - elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then - content="$(whoami)" - else - return - fi - - if [[ $(print -P "%#") == '#' ]]; then - current_state="ROOT" - elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then - if sudo -n true 2>/dev/null; then - current_state="REMOTE_SUDO" - else - current_state="REMOTE" - fi - elif sudo -n true 2>/dev/null; then - current_state="SUDO" - fi - - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" -} - -################################################################ -# User: user (who am I) -# Note that if $DEFAULT_USER is not set, this prompt segment will always print -set_default POWERLEVEL9K_USER_TEMPLATE "%n" -prompt_user() { - local current_state="DEFAULT" - typeset -AH user_state - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then - if [[ $(print -P "%#") == '#' ]]; then - user_state=( - "STATE" "ROOT" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "ROOT_ICON" - ) - elif sudo -n true 2>/dev/null; then - user_state=( - "STATE" "SUDO" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "SUDO_ICON" - ) - else - user_state=( - "STATE" "DEFAULT" - "CONTENT" "$(whoami)" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "USER_ICON" - ) - fi - "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" - fi -} - -################################################################ -# Host: machine (where am I) -set_default POWERLEVEL9K_HOST_TEMPLATE "%m" -prompt_host() { - local current_state="LOCAL" - typeset -AH host_state - if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - host_state=( - "STATE" "REMOTE" - "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "SSH_ICON" - ) - else - host_state=( - "STATE" "LOCAL" - "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" - "BACKGROUND_COLOR" "${DEFAULT_COLOR}" - "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "HOST_ICON" - ) - fi - "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" -} - ################################################################ # The 'custom` prompt provides a way for users to invoke commands and display # the output in a segment. @@ -696,856 +282,6 @@ prompt_custom() { fi } -################################################################ -# Display the duration the command needed to run. -prompt_command_execution_time() { - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 - - # Print time in human readable format - # For that use `strftime` and convert - # the duration (float) to an seconds - # (integer). - # See http://unix.stackexchange.com/a/89748 - local humanReadableDuration - if (( _P9K_COMMAND_DURATION > 3600 )); then - humanReadableDuration=$(TZ=GMT; strftime '%H:%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) - elif (( _P9K_COMMAND_DURATION > 60 )); then - humanReadableDuration=$(TZ=GMT; strftime '%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) - else - # If the command executed in seconds, print as float. - # Convert to float - if [[ "${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION}" == "0" ]]; then - # If user does not want microseconds, then we need to convert - # the duration to an integer. - typeset -i humanReadableDuration - else - typeset -F ${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION} humanReadableDuration - fi - humanReadableDuration=$_P9K_COMMAND_DURATION - fi - - if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - "$1_prompt_segment" "$0" "$2" "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' - fi -} - -################################################################ -# Dir: current working directory -# Parameters: -# * $1 Alignment: string - left|right -# * $2 Index: integer -set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" -set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" -set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false -prompt_dir() { - # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE - local current_path=$PWD # WAS: local current_path="$(print -P '%~')" - # check if the user wants to use absolute paths or "~" paths - [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} - # declare all local variables - local paths directory test_dir test_dir_length trunc_path threshhold - # if we are not in "~" or "/", split the paths into an array and exclude "~" - (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() - # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. - if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then - set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" - # convert delimiter from unicode to literal character, so that we can get the correct length later - local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) - - case "$POWERLEVEL9K_SHORTEN_STRATEGY" in - truncate_absolute_chars) - if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then - current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} - fi - ;; - truncate_middle) - # truncate characters from the middle of the path - current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") - ;; - truncate_from_right) - # truncate characters from the right of the path - current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) - ;; - truncate_absolute) - # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters - if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then - current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} - fi - ;; - truncate_to_last) - # truncate all characters before the current directory - current_path=${current_path##*/} - ;; - truncate_to_first_and_last) - if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then - threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) - # if we are in "~", add it back into the paths array - [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") - if (( ${#paths} > $threshhold )); then - local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) - # repace the middle elements - for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do - paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER - done - [[ $current_path != '~'* ]] && current_path="/" || current_path="" - current_path+="${(j:/:)paths}" - fi - fi - ;; - truncate_to_unique) - # for each parent path component find the shortest unique beginning - # characters sequence. Source: https://stackoverflow.com/a/45336078 - if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths - local matching - local cur_path='/' - [[ $current_path != "~"* ]] && trunc_path='/' || trunc_path='' - for directory in ${paths[@]}; do - test_dir='' - for (( i=0; i<${#directory}; i++ )); do - test_dir+="${directory:$i:1}" - matching=("$cur_path"/"$test_dir"*/) - if [[ ${#matching[@]} -eq 1 ]]; then - break - fi - done - trunc_path+="$test_dir/" - cur_path+="$directory/" - done - [[ $current_path == "~"* ]] && trunc_path="~/$trunc_path" - current_path="${trunc_path: : -1}" - fi - ;; - truncate_with_folder_marker) - if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this - local last_marked_folder marked_folder - set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker" - - # Search for the folder marker in the parent directories and - # buildup a pattern that is removed from the current path - # later on. - for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do - if [[ "$marked_folder" == "/" ]]; then - # If we reached root folder, stop upsearch. - trunc_path="/" - elif [[ "$marked_folder" == "$HOME" ]]; then - # If we reached home folder, stop upsearch. - trunc_path="~" - elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then - trunc_path="${trunc_path%/}/${marked_folder##*/}" - else - trunc_path="${trunc_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}" - fi - last_marked_folder=$marked_folder - done - - # Replace the shortest possible match of the marked folder from - # the current path. - current_path=$trunc_path${current_path#${last_marked_folder}*} - fi - ;; - truncate_with_package_name) - local name repo_path package_path current_dir zero - - # Get the path of the Git repo, which should have the package.json file - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then - # Get path from the root of the git repository to the current dir - local gitPath=$(git rev-parse --show-prefix) - # Remove trailing slash from git path, so that we can - # remove that git path from the pwd. - gitPath=${gitPath%/} - package_path=${$(pwd)%%$gitPath} - # Remove trailing slash - package_path=${package_path%/} - elif [[ $(git rev-parse --is-inside-git-dir 2> /dev/null) == "true" ]]; then - package_path=${$(pwd)%%/.git*} - fi - - # Replace the shortest possible match of the marked folder from - # the current path. Remove the amount of characters up to the - # folder marker from the left. Count only the visible characters - # in the path (this is done by the "zero" pattern; see - # http://stackoverflow.com/a/40855342/5586433). - local zero='%([BSUbfksu]|([FB]|){*})' - trunc_path=$(pwd) - # Then, find the length of the package_path string, and save the - # subdirectory path as a substring of the current directory's path from 0 - # to the length of the package path's string - subdirectory_path=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) - # Parse the 'name' from the package.json; if there are any problems, just - # print the file path - defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json) - - local pkgFile="unknown" - for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do - if [[ -f "${package_path}/${file}" ]]; then - pkgFile="${package_path}/${file}" - break; - fi - done - - local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \ - || node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \ - || cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \ - ) - if [[ -n "${packageName}" ]]; then - # Instead of printing out the full path, print out the name of the package - # from the package.json and append the current subdirectory - current_path="`echo $packageName | tr -d '"'`$subdirectory_path" - fi - ;; - *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" - ;; - esac - fi - - # save state of path for highlighting and bold options - local path_opt=$current_path - - typeset -AH dir_states - dir_states=( - "DEFAULT" "FOLDER_ICON" - "HOME" "HOME_ICON" - "HOME_SUBFOLDER" "HOME_SUB_ICON" - "NOT_WRITABLE" "LOCK_ICON" - ) - local state_path="$(print -P '%~')" - local current_state="DEFAULT" - if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then - current_state="NOT_WRITABLE" - elif [[ $state_path == '~' ]]; then - current_state="HOME" - elif [[ $state_path == '~'* ]]; then - current_state="HOME_SUBFOLDER" - fi - - # declare variables used for bold and state colors - local bld dir_state_foreground dir_state_user_foreground - # test if user wants the last directory printed in bold - if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then - bld_on="%B" - bld_off="%b" - else - bld_on="" - bld_off="" - fi - # determine is the user has set a last directory color - local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND - local dir_state_foreground=${(P)dir_state_user_foreground} - [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" - - local dir_name base_name - # use ZSH substitution to get the dirname and basename instead of calling external functions - dir_name=${path_opt%/*} - base_name=${path_opt##*/} - - # if the user wants the last directory colored... - if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then - # it the path is "/" or "~" - if [[ $path_opt == "/" || $path_opt == "~" ]]; then - current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" - else # has a subfolder - # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute - if [[ $dir_name != $base_name ]]; then - current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" - else - current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" - fi - fi - else # no coloring - # it the path is "/" or "~" - if [[ $path_opt == "/" || $path_opt == "~" ]]; then - current_path="${bld_on}${current_path}${bld_off}" - else # has a subfolder - # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute - if [[ $dir_name != $base_name ]]; then - current_path="${dir_name}/${bld_on}${base_name}${bld_off}" - else - current_path="${bld_on}${base_name}${bld_off}" - fi - fi - fi - - # check if we need to omit the first character and only do it if we are not in "~" or "/" - if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then - current_path="${current_path[2,-1]}" - fi - - # check if the user wants the separator colored. - if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then - # because this contains color changing codes, it is easier to set a variable for what should be replaced - local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" - # escape the / with a \ - current_path=${current_path//\//$repl} - fi - - if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then - current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} - fi - - if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then - # use :s to only replace the first occurance - current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} - fi - - "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" -} - -################################################################ -# Docker machine -prompt_docker_machine() { - local docker_machine="$DOCKER_MACHINE_NAME" - - if [[ -n "$docker_machine" ]]; then - "$1_prompt_segment" "$0" "$2" "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' - fi -} - -################################################################ -# GO prompt -prompt_go_version() { - local go_version - local go_path - go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/") - go_path=$(go env GOPATH 2>/dev/null) - - if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - "$1_prompt_segment" "$0" "$2" "green" "grey93" "$go_version" "GO_ICON" - fi -} - -################################################################ -# Command number (in local history) -prompt_history() { - "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' -} - -################################################################ -# Detection for virtualization (systemd based systems only) -prompt_detect_virt() { - if ! command -v systemd-detect-virt > /dev/null; then - return - fi - local virt=$(systemd-detect-virt) - if [[ "$virt" == "none" ]]; then - if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then - virt="chroot" - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" - else - ; - fi - else - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" - fi -} - -################################################################ -# Test icons -prompt_icons_test() { - for key in ${(@k)icons}; do - # The lower color spectrum in ZSH makes big steps. Choosing - # the next color has enough contrast to read. - local random_color=$((RANDOM % 8)) - local next_color=$((random_color+1)) - "$1_prompt_segment" "$0" "$2" "$random_color" "$next_color" "$key" "$key" - done -} - -################################################################ -# Segment to display the current IP address -prompt_ip() { - if [[ "$OS" == "OSX" ]]; then - if defined POWERLEVEL9K_IP_INTERFACE; then - # Get the IP address of the specified interface. - ip=$(ipconfig getifaddr "$POWERLEVEL9K_IP_INTERFACE") - else - local interfaces callback - # Get network interface names ordered by service precedence. - interfaces=$(networksetup -listnetworkserviceorder | grep -o "Device:\s*[a-z0-9]*" | grep -o -E '[a-z0-9]*$') - callback='ipconfig getifaddr $item' - - ip=$(getRelevantItem "$interfaces" "$callback") - fi - else - if defined POWERLEVEL9K_IP_INTERFACE; then - # Get the IP address of the specified interface. - ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") - else - local interfaces callback - # Get all network interface names that are up - interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o "[a-z0-9]*") - callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*"' - - ip=$(getRelevantItem "$interfaces" "$callback") - fi - fi - - "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' -} - -################################################################ -# Segment to display if VPN is active -set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" -# prompt if vpn active -prompt_vpn_ip() { - for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) - do - ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) - "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' - done -} - -################################################################ -# Segment to display load -set_default POWERLEVEL9K_LOAD_WHICH 5 -prompt_load() { - # The load segment can have three different states - local current_state="unknown" - local load_select=2 - local load_avg - local cores - - typeset -AH load_states - load_states=( - 'critical' 'red' - 'warning' 'yellow' - 'normal' 'green' - ) - - case "$POWERLEVEL9K_LOAD_WHICH" in - 1) - load_select=1 - ;; - 5) - load_select=2 - ;; - 15) - load_select=3 - ;; - esac - - case "$OS" in - OSX|BSD) - load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) - if [[ "$OS" == "OSX" ]]; then - cores=$(sysctl -n hw.logicalcpu) - else - cores=$(sysctl -n hw.ncpu) - fi - ;; - *) - load_avg=$(cut -d" " -f${load_select} /proc/loadavg) - cores=$(nproc) - esac - - # Replace comma - load_avg=${load_avg//,/.} - - if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then - current_state="critical" - elif [[ "$load_avg" -gt $((${cores} * 0.5)) ]]; then - current_state="warning" - else - current_state="normal" - fi - - "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' -} - -################################################################ -# Segment to diplay Node version -prompt_node_version() { - local node_version=$(node -v 2>/dev/null) - [[ -z "${node_version}" ]] && return - - "$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON' -} - -################################################################ -# Segment to display Node version from NVM -# Only prints the segment if different than the default value -prompt_nvm() { - local node_version nvm_default - (( $+functions[nvm_version] )) || return - - node_version=$(nvm_version current) - [[ -z "${node_version}" || ${node_version} == "none" ]] && return - - nvm_default=$(nvm_version default) - [[ "$node_version" =~ "$nvm_default" ]] && return - - $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' -} - -################################################################ -# Segment to display NodeEnv -prompt_nodeenv() { - local nodeenv_path="$NODE_VIRTUAL_ENV" - if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - local info="$(node -v)[$(basename "$nodeenv_path")]" - "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' - fi -} - -################################################################ -# Segment to print a little OS icon -prompt_os_icon() { - "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" -} - -################################################################ -# Segment to display PHP version number -prompt_php_version() { - local php_version - php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") - - if [[ -n "$php_version" ]]; then - "$1_prompt_segment" "$0" "$2" "fuchsia" "grey93" "$php_version" - fi -} - -################################################################ -# Segment to display free RAM and used Swap -prompt_ram() { - local base='' - local ramfree=0 - if [[ "$OS" == "OSX" ]]; then - # Available = Free + Inactive - # See https://support.apple.com/en-us/HT201538 - ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+') - ramfree=$((ramfree + $(vm_stat | grep "Pages inactive" | grep -o -E '[0-9]+'))) - # Convert pages into Bytes - ramfree=$(( ramfree * 4096 )) - else - if [[ "$OS" == "BSD" ]]; then - ramfree=$(grep 'avail memory' /var/run/dmesg.boot | awk '{print $4}') - else - ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - base='K' - fi - fi - - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' -} - -################################################################ -# Segment to display rbenv information -set_default POWERLEVEL9K_RBENV_ALWAYS false -prompt_rbenv() { - if which rbenv 2>/dev/null >&2; then - local rbenv_version_name="$(rbenv version-name)" - local rbenv_global="$(rbenv global)" - - # Don't show anything if the current Ruby is the same as the global Ruby - # unless `POWERLEVEL9K_RBENV_ALWAYS` is set. - if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' - fi - fi -} - -################################################################ -# Segment to display chruby information -# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH -prompt_chruby() { - local chruby_env - chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" - # Don't show anything if the chruby did not change the default ruby - if [[ "${chrb_env:-system}" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' - fi -} - -################################################################ -# Segment to print an icon if user is root. -prompt_root_indicator() { - if [[ "$UID" -eq 0 ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' - fi -} - -################################################################ -# Segment to display Rust version number -prompt_rust_version() { - local rust_version - rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') - - if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' - fi -} - -################################################################ -# Segment to display RSpec test ratio -prompt_rspec_stats() { - if [[ (-d app && -d spec) ]]; then - local code_amount tests_amount - code_amount=$(ls -1 app/**/*.rb | wc -l) - tests_amount=$(ls -1 spec/**/*.rb | wc -l) - - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' - fi -} - -################################################################ -# Segment to display Ruby Version Manager information -prompt_rvm() { - local version_and_gemset=${rvm_env_string/ruby-} - - if [[ -n "$version_and_gemset" ]]; then - "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' - fi -} - -################################################################ -# Segment to display SSH icon when connected -prompt_ssh() { - if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' - fi -} - -################################################################ -# Status: When an error occur, return the error code, or a cross icon if option is set -# Display an ok icon when no error occur, or hide the segment if option is set to false -# -set_default POWERLEVEL9K_STATUS_CROSS false -set_default POWERLEVEL9K_STATUS_OK true -set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true -set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false -# old options, retro compatibility -set_default POWERLEVEL9K_STATUS_VERBOSE true -set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false - -exit_code_or_status() { - local ec=$1 - if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then - echo "$ec" - elif (( ec <= 128 )); then - echo "$ec" - else - local sig=$(( ec - 128 )) - local idx=$(( sig + 1 )) - echo "SIG${signals[$idx]}(${sig})" - fi -} - -prompt_status() { - local ec_text - local ec_sum - local ec - - if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=$(exit_code_or_status "${RETVALS[1]}") - ec_sum=${RETVALS[1]} - - for ec in "${(@)RETVALS[2,-1]}"; do - ec_text="${ec_text}|$(exit_code_or_status "$ec")" - ec_sum=$(( $ec_sum + $ec )) - done - else - # We use RETVAL instead of the right-most RETVALS item because - # PIPE_FAIL may be set. - ec_text=$(exit_code_or_status "${RETVAL}") - ec_sum=${RETVAL} - fi - - if (( ec_sum > 0 )); then - if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' - else - "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' - fi - elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' - fi -} - -################################################################ -# Segment to display Swap information -prompt_swap() { - local swap_used=0 - local base='' - - if [[ "$OS" == "OSX" ]]; then - local raw_swap_used - raw_swap_used=$(sysctl vm.swapusage | grep -o "used\s*=\s*[0-9,.A-Z]*" | grep -o "[0-9,.A-Z]*$") - - typeset -F 2 swap_used - swap_used=${$(echo $raw_swap_used | grep -o "[0-9,.]*")//,/.} - # Replace comma - swap_used=${swap_used//,/.} - - base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$") - else - swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - swap_used=$(( swap_total - swap_free )) - base='K' - fi - - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' -} - -################################################################ -# Symfony2-PHPUnit test ratio -prompt_symfony2_tests() { - if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then - local code_amount tests_amount - code_amount=$(ls -1 src/**/*.php | grep -vc Tests) - tests_amount=$(ls -1 src/**/*.php | grep -c Tests) - - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' - fi -} - -################################################################ -# Segment to display Symfony2-Version -prompt_symfony2_version() { - if [[ -f app/bootstrap.php.cache ]]; then - local symfony2_version - symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' - fi -} - -################################################################ -# Show a ratio of tests vs code -build_test_stats() { - local code_amount="$4" - local tests_amount="$5"+0.00001 - local headline="$6" - - # Set float precision to 2 digits: - typeset -F 2 ratio - local ratio=$(( (tests_amount/code_amount) * 100 )) - - (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" -} - -################################################################ -# System time -prompt_time() { - set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" - - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" -} - -################################################################ -# System date -prompt_date() { - set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" - - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" -} - -################################################################ -# todo.sh: shows the number of tasks in your todo.sh file -prompt_todo() { - if $(hash todo.sh 2>&-); then - count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') - if [[ "$count" = <-> ]]; then - "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' - fi - fi -} - -################################################################ -# VCS segment: shows the state of your repository, if you are in a folder under -# version control -set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" -# Default: Just display the first 8 characters of our changeset-ID. -set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" -powerlevel9k_vcs_init() { - if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then - POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" - fi - - # Load VCS_INFO - autoload -Uz vcs_info - - VCS_WORKDIR_DIRTY=false - VCS_WORKDIR_HALF_DIRTY=false - - # The vcs segment can have three different states - defaults to 'clean'. - typeset -gAH vcs_states - vcs_states=( - 'clean' 'green' - 'modified' 'yellow' - 'untracked' 'green' - ) - - VCS_CHANGESET_PREFIX='' - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then - VCS_CHANGESET_PREFIX="$(print_icon 'VCS_COMMIT_ICON')%0.$POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH""i " - fi - - zstyle ':vcs_info:*' enable git hg svn - zstyle ':vcs_info:*' check-for-changes true - - VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m" - zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" - - zstyle ':vcs_info:*' actionformats "%b %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - - zstyle ':vcs_info:*' stagedstr " $(print_icon 'VCS_STAGED_ICON')" - zstyle ':vcs_info:*' unstagedstr " $(print_icon 'VCS_UNSTAGED_ICON')" - - defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) - zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS - defined POWERLEVEL9K_VCS_HG_HOOKS || POWERLEVEL9K_VCS_HG_HOOKS=(vcs-detect-changes) - zstyle ':vcs_info:hg*+set-message:*' hooks $POWERLEVEL9K_VCS_HG_HOOKS - defined POWERLEVEL9K_VCS_SVN_HOOKS || POWERLEVEL9K_VCS_SVN_HOOKS=(vcs-detect-changes svn-detect-changes) - zstyle ':vcs_info:svn*+set-message:*' hooks $POWERLEVEL9K_VCS_SVN_HOOKS - - # For Hg, only show the branch name - zstyle ':vcs_info:hg*:*' branchformat "$(print_icon 'VCS_BRANCH_ICON')%b" - # The `get-revision` function must be turned on for dirty-check to work for Hg - zstyle ':vcs_info:hg*:*' get-revision true - zstyle ':vcs_info:hg*:*' get-bookmarks true - zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks - - # For svn, only - # TODO fix the %b (branch) format for svn. Using %b breaks - # color-encoding of the foreground for the rest of the powerline. - zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u" - zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then - zstyle ':vcs_info:*' get-revision true - fi -} - -################################################################ -# Segment to show VCS information -prompt_vcs() { - VCS_WORKDIR_DIRTY=false - VCS_WORKDIR_HALF_DIRTY=false - local current_state="" - - # Actually invoke vcs_info manually to gather all information. - vcs_info - local vcs_prompt="${vcs_info_msg_0_}" - - if [[ -n "$vcs_prompt" ]]; then - if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, - # as we have there access to vcs_info internal hooks. - current_state='modified' - else - if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then - current_state='untracked' - else - current_state='clean' - fi - fi - "$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" - fi -} - ################################################################ # Vi Mode: show editing mode (NORMAL|INSERT) set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" @@ -1562,101 +298,6 @@ prompt_vi_mode() { esac } -################################################################ -# Virtualenv: current working virtualenv -# More information on virtualenv (Python): -# https://virtualenv.pypa.io/en/latest/ -prompt_virtualenv() { - local virtualenv_path="$VIRTUAL_ENV" - if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' - fi -} - -################################################################ -# pyenv: current active python version (with restrictions) -# https://github.com/pyenv/pyenv#choosing-the-python-version -prompt_pyenv() { - if [[ -n "$PYENV_VERSION" ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' - fi -} - -################################################################ -# Display openfoam information -prompt_openfoam() { - local wm_project_version="$WM_PROJECT_VERSION" - local wm_fork="$WM_FORK" - if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" - elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" - fi -} - -################################################################ -# Segment to display Swift version -prompt_swift_version() { - # Get the first number as this is probably the "main" version number.. - local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) - [[ -z "${swift_version}" ]] && return - - "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' -} - -################################################################ -# dir_writable: Display information about the user's permission to write in the current directory -prompt_dir_writable() { - if [[ ! -w "$PWD" ]]; then - "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "yellow1" "" 'LOCK_ICON' - fi -} - -################################################################ -# Kubernetes Current Context/Namespace -prompt_kubecontext() { - local kubectl_version="$(kubectl version --client 2>/dev/null)" - - if [[ -n "$kubectl_version" ]]; then - # Get the current Kuberenetes context - local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}') - cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" - # If the namespace comes back empty set it default. - if [[ -z "${cur_namespace}" ]]; then - cur_namespace="default" - fi - - local k8s_final_text="" - - if [[ "$cur_ctx" == "cur_namespace" ]]; then - # No reason to print out the same identificator twice - k8s_final_text="$cur_ctx" - else - k8s_final_text="$cur_ctx/$cur_namespace" - fi - - "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" - fi -} - -################################################################ -# Dropbox status -prompt_dropbox() { - # The first column is just the directory, so cut it - local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" - - # Only show if the folder is tracked and dropbox is running - if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then - # If "up to date", only show the icon - if [[ "$dropbox_status" =~ 'up to date' ]]; then - dropbox_status="" - fi - - "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" - fi - -} - ################################################################ # Prompt processing and drawing ################################################################ @@ -1809,6 +450,18 @@ prompt_powerlevel9k_setup() { # initialize colors autoload -U colors && colors + # load only the segments that are being used! + for segment in $p9k_directory/segments/**/*.p9k; do + local segment_file=${segment##*/} + local segment_name=${segment_file//.p9k/} + if segment_in_use "$segment_name"; then + source "${segment}" + fi + done + + # cleanup temporary variable + unset p9k_directory + if segment_in_use "vcs"; then powerlevel9k_vcs_init fi diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k new file mode 100644 index 000000000..87117bb60 --- /dev/null +++ b/segments/core/background_jobs.p9k @@ -0,0 +1,18 @@ +################################################################ +# Segment to indicate background jobs with an icon. +set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true +set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +prompt_background_jobs() { + local background_jobs_number=${$(jobs -l | wc -l)// /} + local wrong_lines=`jobs -l | awk '/pwd now/{ count++ } END {print count}'` + if [[ wrong_lines -gt 0 ]]; then + background_jobs_number=$(( $background_jobs_number - $wrong_lines )) + fi + if [[ background_jobs_number -gt 0 ]]; then + local background_jobs_number_print="" + if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then + background_jobs_number_print="$background_jobs_number" + fi + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' + fi +} diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k new file mode 100644 index 000000000..868301a52 --- /dev/null +++ b/segments/core/battery.p9k @@ -0,0 +1,111 @@ +################################################################ +# Segment that displays the battery status in levels and colors +prompt_battery() { + # The battery can have four different states - default to 'unknown'. + local current_state='unknown' + typeset -AH battery_states + battery_states=( + 'low' 'red' + 'charging' 'yellow' + 'charged' 'green' + 'disconnected' "$DEFAULT_COLOR_INVERTED" + ) + # Set default values if the user did not configure them + set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 + + if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then + # obtain battery information from system + local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" + # return if there is no battery on system + [[ -z $(echo $raw_data | grep "InternalBattery") ]] && return + + # Time remaining on battery operation (charging/discharging) + local tstring=$(echo $raw_data | awk -F ';' '{print $3}' | awk '{print $1}') + # If time has not been calculated by system yet + [[ $tstring =~ '(\(no|not)' ]] && tstring="..." + + # percent of battery charged + typeset -i 10 bat_percent + bat_percent=$(echo $raw_data | grep -o '[0-9]*%' | sed 's/%//') + + local remain="" + # Logic for string output + case $(echo $raw_data | awk -F ';' '{print $2}' | awk '{$1=$1};1') in + # for a short time after attaching power, status will be 'AC attached;' + 'charging'|'finishing charge'|'AC attached') + current_state="charging" + remain=" ($tstring)" + ;; + 'discharging') + [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + remain=" ($tstring)" + ;; + *) + current_state="charged" + ;; + esac + fi + + if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then + local sysp="/sys/class/power_supply" + + # Reported BAT0 or BAT1 depending on kernel version + [[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0 + [[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1 + + # Android-related + # Tested on: Moto G falcon (CM 13.0) + [[ -a $sysp/battery ]] && local bat=$sysp/battery + + # Return if no battery found + [[ -z $bat ]] && return + local capacity=$(cat $bat/capacity) + local battery_status=$(cat $bat/status) + [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity + [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true + if [[ -z $connected ]]; then + [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + else + [[ $bat_percent =~ 100 ]] && current_state="charged" + [[ $bat_percent -lt 100 ]] && current_state="charging" + fi + if [[ -f /usr/bin/acpi ]]; then + local time_remaining=$(acpi | awk '{ print $5 }') + if [[ $time_remaining =~ rate ]]; then + local tstring="..." + elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then + local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M 2> /dev/null)} + fi + fi + [[ -n $tstring ]] && local remain=" ($tstring)" + fi + + local message + # Default behavior: Be verbose! + set_default POWERLEVEL9K_BATTERY_VERBOSE true + if [[ "$POWERLEVEL9K_BATTERY_VERBOSE" == true ]]; then + message="$bat_percent%%$remain" + else + message="$bat_percent%%" + fi + + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi + fi + + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + else + # Draw the prompt_segment + "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + fi +} diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k new file mode 100644 index 000000000..5ba75d36e --- /dev/null +++ b/segments/core/command_execution_time.p9k @@ -0,0 +1,33 @@ +################################################################ +# Display the duration the command needed to run. +prompt_command_execution_time() { + set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 + set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 + + # Print time in human readable format + # For that use `strftime` and convert + # the duration (float) to an seconds + # (integer). + # See http://unix.stackexchange.com/a/89748 + local humanReadableDuration + if (( _P9K_COMMAND_DURATION > 3600 )); then + humanReadableDuration=$(TZ=GMT; strftime '%H:%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) + elif (( _P9K_COMMAND_DURATION > 60 )); then + humanReadableDuration=$(TZ=GMT; strftime '%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) + else + # If the command executed in seconds, print as float. + # Convert to float + if [[ "${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION}" == "0" ]]; then + # If user does not want microseconds, then we need to convert + # the duration to an integer. + typeset -i humanReadableDuration + else + typeset -F ${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION} humanReadableDuration + fi + humanReadableDuration=$_P9K_COMMAND_DURATION + fi + + if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then + "$1_prompt_segment" "$0" "$2" "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + fi +} diff --git a/segments/core/context.p9k b/segments/core/context.p9k new file mode 100644 index 000000000..5416504a9 --- /dev/null +++ b/segments/core/context.p9k @@ -0,0 +1,41 @@ +################################################################ +# Context: user@hostname (who am I and where am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false +set_default POWERLEVEL9K_ALWAYS_SHOW_USER false +set_default POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" +prompt_context() { + local current_state="DEFAULT" + typeset -AH context_states + context_states=( + "ROOT" "yellow" + "SUDO" "yellow" + "DEFAULT" "yellow" + "REMOTE" "yellow" + "REMOTE_SUDO" "yellow" + ) + + local content="" + + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" + elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + content="$(whoami)" + else + return + fi + + if [[ $(print -P "%#") == '#' ]]; then + current_state="ROOT" + elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if sudo -n true 2>/dev/null; then + current_state="REMOTE_SUDO" + else + current_state="REMOTE" + fi + elif sudo -n true 2>/dev/null; then + current_state="SUDO" + fi + + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" +} diff --git a/segments/core/date.p9k b/segments/core/date.p9k new file mode 100644 index 000000000..3fddbcf28 --- /dev/null +++ b/segments/core/date.p9k @@ -0,0 +1,7 @@ +################################################################ +# System date +prompt_date() { + set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" +} diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k new file mode 100644 index 000000000..fbe398ff7 --- /dev/null +++ b/segments/core/dir.p9k @@ -0,0 +1,263 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# Dir: current working directory +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" +set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +prompt_dir() { + # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE + local current_path=$PWD # WAS: local current_path="$(print -P '%~')" + # check if the user wants to use absolute paths or "~" paths + [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + # declare all local variables + local paths directory test_dir test_dir_length trunc_path threshhold + # if we are not in "~" or "/", split the paths into an array and exclude "~" + (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() + # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. + if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then + set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" + # convert delimiter from unicode to literal character, so that we can get the correct length later + local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) + + case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_middle) + # truncate characters from the middle of the path + current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") + ;; + truncate_from_right) + # truncate characters from the right of the path + current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + ;; + truncate_absolute) + # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_to_last) + # truncate all characters before the current directory + current_path=${current_path##*/} + ;; + truncate_to_first_and_last) + if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then + threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) + # if we are in "~", add it back into the paths array + [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") + if (( ${#paths} > $threshhold )); then + local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) + # repace the middle elements + for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do + paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER + done + [[ $current_path != '~'* ]] && current_path="/" || current_path="" + current_path+="${(j:/:)paths}" + fi + fi + ;; + truncate_to_unique) + # for each parent path component find the shortest unique beginning + # characters sequence. Source: https://stackoverflow.com/a/45336078 + if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths + local matching + local cur_path='/' + [[ $current_path != "~"* ]] && trunc_path='/' || trunc_path='' + for directory in ${paths[@]}; do + test_dir='' + for (( i=0; i<${#directory}; i++ )); do + test_dir+="${directory:$i:1}" + matching=("$cur_path"/"$test_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + trunc_path+="$test_dir/" + cur_path+="$directory/" + done + [[ $current_path == "~"* ]] && trunc_path="~/$trunc_path" + current_path="${trunc_path: : -1}" + fi + ;; + truncate_with_folder_marker) + if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this + local last_marked_folder marked_folder + set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker" + + # Search for the folder marker in the parent directories and + # buildup a pattern that is removed from the current path + # later on. + for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do + if [[ "$marked_folder" == "/" ]]; then + # If we reached root folder, stop upsearch. + trunc_path="/" + elif [[ "$marked_folder" == "$HOME" ]]; then + # If we reached home folder, stop upsearch. + trunc_path="~" + elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then + trunc_path="${trunc_path%/}/${marked_folder##*/}" + else + trunc_path="${trunc_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}" + fi + last_marked_folder=$marked_folder + done + + # Replace the shortest possible match of the marked folder from + # the current path. + current_path=$trunc_path${current_path#${last_marked_folder}*} + fi + ;; + truncate_with_package_name) + local name repo_path package_path current_dir zero + + # Get the path of the Git repo, which should have the package.json file + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then + # Get path from the root of the git repository to the current dir + local gitPath=$(git rev-parse --show-prefix) + # Remove trailing slash from git path, so that we can + # remove that git path from the pwd. + gitPath=${gitPath%/} + package_path=${$(pwd)%%$gitPath} + # Remove trailing slash + package_path=${package_path%/} + elif [[ $(git rev-parse --is-inside-git-dir 2> /dev/null) == "true" ]]; then + package_path=${$(pwd)%%/.git*} + fi + + # Replace the shortest possible match of the marked folder from + # the current path. Remove the amount of characters up to the + # folder marker from the left. Count only the visible characters + # in the path (this is done by the "zero" pattern; see + # http://stackoverflow.com/a/40855342/5586433). + local zero='%([BSUbfksu]|([FB]|){*})' + trunc_path=$(pwd) + # Then, find the length of the package_path string, and save the + # subdirectory path as a substring of the current directory's path from 0 + # to the length of the package path's string + subdirectory_path=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + # Parse the 'name' from the package.json; if there are any problems, just + # print the file path + defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json) + + local pkgFile="unknown" + for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do + if [[ -f "${package_path}/${file}" ]]; then + pkgFile="${package_path}/${file}" + break; + fi + done + + local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \ + || node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \ + || cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \ + ) + if [[ -n "${packageName}" ]]; then + # Instead of printing out the full path, print out the name of the package + # from the package.json and append the current subdirectory + current_path="`echo $packageName | tr -d '"'`$subdirectory_path" + fi + ;; + *) + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + ;; + esac + fi + + # save state of path for highlighting and bold options + local path_opt=$current_path + + typeset -AH dir_states + dir_states=( + "DEFAULT" "FOLDER_ICON" + "HOME" "HOME_ICON" + "HOME_SUBFOLDER" "HOME_SUB_ICON" + "NOT_WRITABLE" "LOCK_ICON" + ) + local state_path="$(print -P '%~')" + local current_state="DEFAULT" + if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + current_state="NOT_WRITABLE" + elif [[ $state_path == '~' ]]; then + current_state="HOME" + elif [[ $state_path == '~'* ]]; then + current_state="HOME_SUBFOLDER" + fi + + # declare variables used for bold and state colors + local bld dir_state_foreground dir_state_user_foreground + # test if user wants the last directory printed in bold + if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then + bld_on="%B" + bld_off="%b" + else + bld_on="" + bld_off="" + fi + # determine is the user has set a last directory color + local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND + local dir_state_foreground=${(P)dir_state_user_foreground} + [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" + + local dir_name base_name + # use ZSH substitution to get the dirname and basename instead of calling external functions + dir_name=${path_opt%/*} + base_name=${path_opt##*/} + + # if the user wants the last directory colored... + if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + else + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + fi + fi + else # no coloring + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}${base_name}${bld_off}" + else + current_path="${bld_on}${base_name}${bld_off}" + fi + fi + fi + + # check if we need to omit the first character and only do it if we are not in "~" or "/" + if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then + current_path="${current_path[2,-1]}" + fi + + # check if the user wants the separator colored. + if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then + # because this contains color changing codes, it is easier to set a variable for what should be replaced + local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" + # escape the / with a \ + current_path=${current_path//\//$repl} + fi + + if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then + current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} + fi + + if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + # use :s to only replace the first occurance + current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} + fi + + "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" +} diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k new file mode 100644 index 000000000..8a6d70e55 --- /dev/null +++ b/segments/core/dir_writable.p9k @@ -0,0 +1,7 @@ +############################################################### +# dir_writable: Display information about the user's permission to write in the current directory +prompt_dir_writable() { + if [[ ! -w "$PWD" ]]; then + "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "yellow1" "" 'LOCK_ICON' + fi +} diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k new file mode 100644 index 000000000..087d56b33 --- /dev/null +++ b/segments/core/disk_usage.p9k @@ -0,0 +1,42 @@ +################################################################ +# Segment that indicates usage level of current partition. +set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false +set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 +set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 +prompt_disk_usage() { + local current_state="unknown" + typeset -AH hdd_usage_forecolors + hdd_usage_forecolors=( + 'normal' 'yellow' + 'warning' "$DEFAULT_COLOR" + 'critical' 'white' + ) + typeset -AH hdd_usage_backcolors + hdd_usage_backcolors=( + 'normal' $DEFAULT_COLOR + 'warning' 'yellow' + 'critical' 'red' + ) + + local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" + + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then + current_state='warning' + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then + current_state='critical' + fi + else + if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then + current_state='' + return + fi + current_state='normal' + fi + + local message="${disk_usage}%%" + + # Draw the prompt_segment + if [[ -n $disk_usage ]]; then + "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' + fi +} diff --git a/segments/core/history.p9k b/segments/core/history.p9k new file mode 100644 index 000000000..4173f19b1 --- /dev/null +++ b/segments/core/history.p9k @@ -0,0 +1,5 @@ +################################################################ +# Command number (in local history) +prompt_history() { + "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' +} diff --git a/segments/core/host.p9k b/segments/core/host.p9k new file mode 100644 index 000000000..f7d2c1948 --- /dev/null +++ b/segments/core/host.p9k @@ -0,0 +1,25 @@ +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k new file mode 100644 index 000000000..ef74538e9 --- /dev/null +++ b/segments/core/ip.p9k @@ -0,0 +1,31 @@ +################################################################ +# Segment to display the current IP address +prompt_ip() { + if [[ "$OS" == "OSX" ]]; then + if defined POWERLEVEL9K_IP_INTERFACE; then + # Get the IP address of the specified interface. + ip=$(ipconfig getifaddr "$POWERLEVEL9K_IP_INTERFACE") + else + local interfaces callback + # Get network interface names ordered by service precedence. + interfaces=$(networksetup -listnetworkserviceorder | grep -o "Device:\s*[a-z0-9]*" | grep -o -E '[a-z0-9]*$') + callback='ipconfig getifaddr $item' + + ip=$(getRelevantItem "$interfaces" "$callback") + fi + else + if defined POWERLEVEL9K_IP_INTERFACE; then + # Get the IP address of the specified interface. + ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") + else + local interfaces callback + # Get all network interface names that are up + interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o "[a-z0-9]*") + callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*"' + + ip=$(getRelevantItem "$interfaces" "$callback") + fi + fi + + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' +} diff --git a/segments/core/load.p9k b/segments/core/load.p9k new file mode 100644 index 000000000..4f455c703 --- /dev/null +++ b/segments/core/load.p9k @@ -0,0 +1,56 @@ +################################################################ +# Segment to display load +set_default POWERLEVEL9K_LOAD_WHICH 5 +prompt_load() { + # The load segment can have three different states + local current_state="unknown" + local load_select=2 + local load_avg + local cores + + typeset -AH load_states + load_states=( + 'critical' 'red' + 'warning' 'yellow' + 'normal' 'green' + ) + + case "$POWERLEVEL9K_LOAD_WHICH" in + 1) + load_select=1 + ;; + 5) + load_select=2 + ;; + 15) + load_select=3 + ;; + esac + + case "$OS" in + OSX|BSD) + load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) + if [[ "$OS" == "OSX" ]]; then + cores=$(sysctl -n hw.logicalcpu) + else + cores=$(sysctl -n hw.ncpu) + fi + ;; + *) + load_avg=$(cut -d" " -f${load_select} /proc/loadavg) + cores=$(nproc) + esac + + # Replace comma + load_avg=${load_avg//,/.} + + if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then + current_state="critical" + elif [[ "$load_avg" -gt $((${cores} * 0.5)) ]]; then + current_state="warning" + else + current_state="normal" + fi + + "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' +} diff --git a/segments/core/newline.p9k b/segments/core/newline.p9k new file mode 100644 index 000000000..9ce59a02f --- /dev/null +++ b/segments/core/newline.p9k @@ -0,0 +1,17 @@ +################################################################ +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws newline + [[ "$1" == "right" ]] && return + newline=$'\n' + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + fi + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" "${newline}" + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws +} diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k new file mode 100644 index 000000000..1fc030239 --- /dev/null +++ b/segments/core/os_icon.p9k @@ -0,0 +1,5 @@ +################################################################ +# Segment to print a little OS icon +prompt_os_icon() { + "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" +} diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k new file mode 100644 index 000000000..88d9f278c --- /dev/null +++ b/segments/core/public_ip.p9k @@ -0,0 +1,79 @@ +################################################################ +# Public IP segment +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +# * $3 Joined: bool - If the segment should be joined +prompt_public_ip() { + # set default values for segment + set_default POWERLEVEL9K_PUBLIC_IP_TIMEOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_NONE "" + set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" + set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" + defined POWERLEVEL9K_PUBLIC_IP_METHODS || POWERLEVEL9K_PUBLIC_IP_METHODS=(dig curl wget) + + # Do we need a fresh IP? + local refresh_ip=false + if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + typeset -i timediff + # if saved IP is more than + if [[ "$OS" == "OSX" ]]; then + timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + else + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + fi + [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true + # If tmp file is empty get a fresh IP + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true + [[ -n $POWERLEVEL9K_PUBLIC_IP_NONE ]] && [[ $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true + else + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true + fi + + # grab a fresh IP if needed + local fresh_ip + if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + for method in "${POWERLEVEL9K_PUBLIC_IP_METHODS[@]}"; do + case $method in + 'dig') + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + ;; + 'curl') + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + ;; + 'wget') + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + ;; + esac + # If we found a fresh IP, break loop. + if [[ -n "${fresh_ip}" ]]; then + break; + fi + done + + # write IP to tmp file or clear tmp file if an IP was not retrieved + # Redirection with `>!`. From the manpage: Same as >, except that the file + # is truncated to zero length if it exists, even if CLOBBER is unset. + # If the file already exists, and a simple `>` redirection and CLOBBER + # unset, ZSH will produce an error. + [[ -n "${fresh_ip}" ]] && echo $fresh_ip >! $POWERLEVEL9K_PUBLIC_IP_FILE || echo $POWERLEVEL9K_PUBLIC_IP_NONE >! $POWERLEVEL9K_PUBLIC_IP_FILE + fi + + # read public IP saved to tmp file + local public_ip="$(cat $POWERLEVEL9K_PUBLIC_IP_FILE)" + + # Draw the prompt segment + if [[ -n $public_ip ]]; then + icon='PUBLIC_IP_ICON' + # Check VPN is on if VPN interface is set + if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) + do + icon='VPN_ICON' + break + done + fi + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" + fi +} diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k new file mode 100644 index 000000000..7d4e4bd8e --- /dev/null +++ b/segments/core/ram.p9k @@ -0,0 +1,23 @@ +################################################################ +# Segment to display free RAM and used Swap +prompt_ram() { + local base='' + local ramfree=0 + if [[ "$OS" == "OSX" ]]; then + # Available = Free + Inactive + # See https://support.apple.com/en-us/HT201538 + ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+') + ramfree=$((ramfree + $(vm_stat | grep "Pages inactive" | grep -o -E '[0-9]+'))) + # Convert pages into Bytes + ramfree=$(( ramfree * 4096 )) + else + if [[ "$OS" == "BSD" ]]; then + ramfree=$(grep 'avail memory' /var/run/dmesg.boot | awk '{print $4}') + else + ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") + base='K' + fi + fi + + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' +} diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k new file mode 100644 index 000000000..4d8059dbe --- /dev/null +++ b/segments/core/root_indicator.p9k @@ -0,0 +1,7 @@ +################################################################ +# Segment to print an icon if user is root. +prompt_root_indicator() { + if [[ "$UID" -eq 0 ]]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' + fi +} diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k new file mode 100644 index 000000000..bd46190d8 --- /dev/null +++ b/segments/core/ssh.p9k @@ -0,0 +1,7 @@ +################################################################ +# Segment to display SSH icon when connected +prompt_ssh() { + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + fi +} diff --git a/segments/core/status.p9k b/segments/core/status.p9k new file mode 100644 index 000000000..bf367c53a --- /dev/null +++ b/segments/core/status.p9k @@ -0,0 +1,55 @@ +################################################################ +# Status: When an error occur, return the error code, or a cross icon if option is set +# Display an ok icon when no error occur, or hide the segment if option is set to false +# +set_default POWERLEVEL9K_STATUS_CROSS false +set_default POWERLEVEL9K_STATUS_OK true +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "SIG${signals[$idx]}(${sig})" + fi +} + +prompt_status() { + local ec_text + local ec_sum + local ec + + if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|$(exit_code_or_status "$ec")" + ec_sum=$(( $ec_sum + $ec )) + done + else + # We use RETVAL instead of the right-most RETVALS item because + # PIPE_FAIL may be set. + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + if (( ec_sum > 0 )); then + if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + else + "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + fi + elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' + fi +} diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k new file mode 100644 index 000000000..618ba465f --- /dev/null +++ b/segments/core/swap.p9k @@ -0,0 +1,25 @@ +################################################################ +# Segment to display Swap information +prompt_swap() { + local swap_used=0 + local base='' + + if [[ "$OS" == "OSX" ]]; then + local raw_swap_used + raw_swap_used=$(sysctl vm.swapusage | grep -o "used\s*=\s*[0-9,.A-Z]*" | grep -o "[0-9,.A-Z]*$") + + typeset -F 2 swap_used + swap_used=${$(echo $raw_swap_used | grep -o "[0-9,.]*")//,/.} + # Replace comma + swap_used=${swap_used//,/.} + + base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$") + else + swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") + swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") + swap_used=$(( swap_total - swap_free )) + base='K' + fi + + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' +} diff --git a/segments/core/test_stats.p9k b/segments/core/test_stats.p9k new file mode 100644 index 000000000..52b64d8f4 --- /dev/null +++ b/segments/core/test_stats.p9k @@ -0,0 +1,15 @@ +################################################################ +# Show a ratio of tests vs code +build_test_stats() { + local code_amount="$4" + local tests_amount="$5"+0.00001 + local headline="$6" + + # Set float precision to 2 digits: + typeset -F 2 ratio + local ratio=$(( (tests_amount/code_amount) * 100 )) + + (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" +} diff --git a/segments/core/time.p9k b/segments/core/time.p9k new file mode 100644 index 000000000..e5c09186b --- /dev/null +++ b/segments/core/time.p9k @@ -0,0 +1,7 @@ +################################################################ +# System time +prompt_time() { + set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" +} diff --git a/segments/core/user.p9k b/segments/core/user.p9k new file mode 100644 index 000000000..9be134bd8 --- /dev/null +++ b/segments/core/user.p9k @@ -0,0 +1,36 @@ +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) + else + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$(whoami)" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + fi +} diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k new file mode 100644 index 000000000..d0851086e --- /dev/null +++ b/segments/core/vpn_ip.p9k @@ -0,0 +1,11 @@ +################################################################ +# Segment to display if VPN is active +set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +# prompt if vpn active +prompt_vpn_ip() { + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + do + ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + done +} diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k new file mode 100644 index 000000000..cd95c47a8 --- /dev/null +++ b/segments/developer/anaconda.p9k @@ -0,0 +1,13 @@ +################################################################ +# Anaconda Environment +prompt_anaconda() { + # Depending on the conda version, either might be set. This + # variant works even if both are set. + _path=$CONDA_ENV_PATH$CONDA_PREFIX + if ! [ -z "$_path" ]; then + # config - can be overwritten in users' zshrc file. + set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" + set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' + fi +} diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k new file mode 100644 index 000000000..807a37df1 --- /dev/null +++ b/segments/developer/aws.p9k @@ -0,0 +1,9 @@ +################################################################ +# AWS Profile +prompt_aws() { + local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" + + if [[ -n "$aws_profile" ]]; then + "$1_prompt_segment" "$0" "$2" red white "$aws_profile" 'AWS_ICON' + fi +} diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k new file mode 100644 index 000000000..da66bbe2e --- /dev/null +++ b/segments/developer/aws_eb_env.p9k @@ -0,0 +1,9 @@ +################################################################ +# Current Elastic Beanstalk environment +prompt_aws_eb_env() { + local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') + + if [[ -n "$eb_env" ]]; then + "$1_prompt_segment" "$0" "$2" black green "$eb_env" 'AWS_EB_ICON' + fi +} diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k new file mode 100644 index 000000000..c9cb442f7 --- /dev/null +++ b/segments/developer/chruby.p9k @@ -0,0 +1,11 @@ +################################################################ +# Segment to display chruby information +# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH +prompt_chruby() { + local chruby_env + chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" + # Don't show anything if the chruby did not change the default ruby + if [[ "${chrb_env:-system}" != "system" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' + fi +} diff --git a/segments/developer/detect_virt.p9k b/segments/developer/detect_virt.p9k new file mode 100644 index 000000000..768509f67 --- /dev/null +++ b/segments/developer/detect_virt.p9k @@ -0,0 +1,18 @@ +################################################################ +# Detection for virtualization (systemd based systems only) +prompt_detect_virt() { + if ! command -v systemd-detect-virt > /dev/null; then + return + fi + local virt=$(systemd-detect-virt) + if [[ "$virt" == "none" ]]; then + if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then + virt="chroot" + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + fi +} diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k new file mode 100644 index 000000000..112041870 --- /dev/null +++ b/segments/developer/docker_machine.p9k @@ -0,0 +1,9 @@ +################################################################ +# Docker machine +prompt_docker_machine() { + local docker_machine="$DOCKER_MACHINE_NAME" + + if [[ -n "$docker_machine" ]]; then + "$1_prompt_segment" "$0" "$2" "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' + fi +} diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k new file mode 100644 index 000000000..b8024d7ba --- /dev/null +++ b/segments/developer/go_version.p9k @@ -0,0 +1,12 @@ +################################################################ +# GO prompt +prompt_go_version() { + local go_version + local go_path + go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/") + go_path=$(go env GOPATH 2>/dev/null) + + if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then + "$1_prompt_segment" "$0" "$2" "green" "grey93" "$go_version" "GO_ICON" + fi +} diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k new file mode 100644 index 000000000..4ff91a41a --- /dev/null +++ b/segments/developer/kubecontext.p9k @@ -0,0 +1,26 @@ +################################################################ +# Kubernetes Current Context/Namespace +prompt_kubecontext() { + local kubectl_version="$(kubectl version --client 2>/dev/null)" + + if [[ -n "$kubectl_version" ]]; then + # Get the current Kuberenetes context + local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}') + cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" + # If the namespace comes back empty set it default. + if [[ -z "${cur_namespace}" ]]; then + cur_namespace="default" + fi + + local k8s_final_text="" + + if [[ "$cur_ctx" == "cur_namespace" ]]; then + # No reason to print out the same identificator twice + k8s_final_text="$cur_ctx" + else + k8s_final_text="$cur_ctx/$cur_namespace" + fi + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + fi +} diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k new file mode 100644 index 000000000..7deb50e48 --- /dev/null +++ b/segments/developer/node_env.p9k @@ -0,0 +1,9 @@ +################################################################ +# Segment to display NodeEnv +prompt_node_env() { + local node_env_path="$NODE_VIRTUAL_ENV" + if [[ -n "$node_env_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then + local info="$(node -v)[$(basename "$node_env_path")]" + "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' + fi +} diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k new file mode 100644 index 000000000..64edee311 --- /dev/null +++ b/segments/developer/node_version.p9k @@ -0,0 +1,8 @@ +################################################################ +# Segment to diplay Node version +prompt_node_version() { + local node_version=$(node -v 2>/dev/null) + [[ -z "${node_version}" ]] && return + + "$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON' +} diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k new file mode 100644 index 000000000..14b047297 --- /dev/null +++ b/segments/developer/nvm.p9k @@ -0,0 +1,15 @@ +################################################################ +# Segment to display Node version from NVM +# Only prints the segment if different than the default value +prompt_nvm() { + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) + [[ "$node_version" =~ "$nvm_default" ]] && return + + $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' +} diff --git a/segments/developer/php_version.p9k b/segments/developer/php_version.p9k new file mode 100644 index 000000000..88ba544b1 --- /dev/null +++ b/segments/developer/php_version.p9k @@ -0,0 +1,10 @@ +################################################################ +# Segment to display PHP version number +prompt_php_version() { + local php_version + php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") + + if [[ -n "$php_version" ]]; then + "$1_prompt_segment" "$0" "$2" "fuchsia" "grey93" "$php_version" + fi +} diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k new file mode 100644 index 000000000..544b83ac4 --- /dev/null +++ b/segments/developer/pyenv.p9k @@ -0,0 +1,8 @@ +################################################################ +# pyenv: current active python version (with restrictions) +# https://github.com/pyenv/pyenv#choosing-the-python-version +prompt_pyenv() { + if [[ -n "$PYENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + fi +} diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k new file mode 100644 index 000000000..cf8ce2c92 --- /dev/null +++ b/segments/developer/rbenv.p9k @@ -0,0 +1,15 @@ +################################################################ +# Segment to display rbenv information +set_default POWERLEVEL9K_RBENV_ALWAYS false +prompt_rbenv() { + if which rbenv 2>/dev/null >&2; then + local rbenv_version_name="$(rbenv version-name)" + local rbenv_global="$(rbenv global)" + + # Don't show anything if the current Ruby is the same as the global Ruby + # unless `POWERLEVEL9K_RBENV_ALWAYS` is set. + if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + fi + fi +} diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k new file mode 100644 index 000000000..25c4ecbf2 --- /dev/null +++ b/segments/developer/rspec_stats.p9k @@ -0,0 +1,11 @@ +################################################################ +# Segment to display RSpec test ratio +prompt_rspec_stats() { + if [[ (-d app && -d spec) ]]; then + local code_amount tests_amount + code_amount=$(ls -1 app/**/*.rb | wc -l) + tests_amount=$(ls -1 spec/**/*.rb | wc -l) + + build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' + fi +} diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k new file mode 100644 index 000000000..e5421bdd6 --- /dev/null +++ b/segments/developer/rust_version.p9k @@ -0,0 +1,10 @@ +################################################################ +# Segment to display Rust version number +prompt_rust_version() { + local rust_version + rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') + + if [[ -n "$rust_version" ]]; then + "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + fi +} diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k new file mode 100644 index 000000000..858b672c5 --- /dev/null +++ b/segments/developer/rvm.p9k @@ -0,0 +1,9 @@ +################################################################ +# Segment to display Ruby Version Manager information +prompt_rvm() { + local version_and_gemset=${rvm_env_string/ruby-} + + if [[ -n "$version_and_gemset" ]]; then + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + fi +} diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k new file mode 100644 index 000000000..98707cd22 --- /dev/null +++ b/segments/developer/swift_version.p9k @@ -0,0 +1,11 @@ +################################################################ +# Segment to display Swift version +prompt_swift_version() { + # Get the first number as this is probably the "main" version number.. + local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) + [[ -z "${swift_version}" ]] && return + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' +} + +# diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k new file mode 100644 index 000000000..6b93c47e6 --- /dev/null +++ b/segments/developer/symfony2_tests.p9k @@ -0,0 +1,11 @@ +################################################################ +# Symfony2-PHPUnit test ratio +prompt_symfony2_tests() { + if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then + local code_amount tests_amount + code_amount=$(ls -1 src/**/*.php | grep -vc Tests) + tests_amount=$(ls -1 src/**/*.php | grep -c Tests) + + build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' + fi +} diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k new file mode 100644 index 000000000..b7c0b2b27 --- /dev/null +++ b/segments/developer/symfony2_version.p9k @@ -0,0 +1,9 @@ +################################################################ +# Segment to display Symfony2-Version +prompt_symfony2_version() { + if [[ -f app/bootstrap.php.cache ]]; then + local symfony2_version + symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' + fi +} diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k new file mode 100644 index 000000000..3a64d26b2 --- /dev/null +++ b/segments/developer/vcs.p9k @@ -0,0 +1,92 @@ +################################################################ +# VCS segment: shows the state of your repository, if you are in a folder under +# version control +set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" +# Default: Just display the first 8 characters of our changeset-ID. +set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" +powerlevel9k_vcs_init() { + if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then + POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" + fi + + # Load VCS_INFO + autoload -Uz vcs_info + + VCS_WORKDIR_DIRTY=false + VCS_WORKDIR_HALF_DIRTY=false + + # The vcs segment can have three different states - defaults to 'clean'. + typeset -gAH vcs_states + vcs_states=( + 'clean' 'green' + 'modified' 'yellow' + 'untracked' 'green' + ) + + VCS_CHANGESET_PREFIX='' + if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then + VCS_CHANGESET_PREFIX="$(print_icon 'VCS_COMMIT_ICON')%0.$POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH""i " + fi + + zstyle ':vcs_info:*' enable git hg svn + zstyle ':vcs_info:*' check-for-changes true + + VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m" + zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" + + zstyle ':vcs_info:*' actionformats "%b %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + + zstyle ':vcs_info:*' stagedstr " $(print_icon 'VCS_STAGED_ICON')" + zstyle ':vcs_info:*' unstagedstr " $(print_icon 'VCS_UNSTAGED_ICON')" + + defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) + zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS + defined POWERLEVEL9K_VCS_HG_HOOKS || POWERLEVEL9K_VCS_HG_HOOKS=(vcs-detect-changes) + zstyle ':vcs_info:hg*+set-message:*' hooks $POWERLEVEL9K_VCS_HG_HOOKS + defined POWERLEVEL9K_VCS_SVN_HOOKS || POWERLEVEL9K_VCS_SVN_HOOKS=(vcs-detect-changes svn-detect-changes) + zstyle ':vcs_info:svn*+set-message:*' hooks $POWERLEVEL9K_VCS_SVN_HOOKS + + # For Hg, only show the branch name + zstyle ':vcs_info:hg*:*' branchformat "$(print_icon 'VCS_BRANCH_ICON')%b" + # The `get-revision` function must be turned on for dirty-check to work for Hg + zstyle ':vcs_info:hg*:*' get-revision true + zstyle ':vcs_info:hg*:*' get-bookmarks true + zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks + + # For svn, only + # TODO fix the %b (branch) format for svn. Using %b breaks + # color-encoding of the foreground for the rest of the powerline. + zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u" + zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + + if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then + zstyle ':vcs_info:*' get-revision true + fi +} + +################################################################ +# Segment to show VCS information +prompt_vcs() { + VCS_WORKDIR_DIRTY=false + VCS_WORKDIR_HALF_DIRTY=false + local current_state="" + + # Actually invoke vcs_info manually to gather all information. + vcs_info + local vcs_prompt="${vcs_info_msg_0_}" + + if [[ -n "$vcs_prompt" ]]; then + if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then + # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, + # as we have there access to vcs_info internal hooks. + current_state='modified' + else + if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then + current_state='untracked' + else + current_state='clean' + fi + fi + "$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" + fi +} diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k new file mode 100644 index 000000000..d425d0bec --- /dev/null +++ b/segments/developer/virtualenv.p9k @@ -0,0 +1,10 @@ +################################################################ +# Virtualenv: current working virtualenv +# More information on virtualenv (Python): +# https://virtualenv.pypa.io/en/latest/ +prompt_virtualenv() { + local virtualenv_path="$VIRTUAL_ENV" + if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' + fi +} diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k new file mode 100644 index 000000000..fbf0a1fb1 --- /dev/null +++ b/segments/other/dropbox.p9k @@ -0,0 +1,17 @@ +################################################################ +# Dropbox status +prompt_dropbox() { + # The first column is just the directory, so cut it + local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" + + # Only show if the folder is tracked and dropbox is running + if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then + # If "up to date", only show the icon + if [[ "$dropbox_status" =~ 'up to date' ]]; then + dropbox_status="" + fi + + "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" + fi + +} diff --git a/segments/other/icons_test.p9k b/segments/other/icons_test.p9k new file mode 100644 index 000000000..fc3b47d49 --- /dev/null +++ b/segments/other/icons_test.p9k @@ -0,0 +1,11 @@ +################################################################ +# Test icons +prompt_icons_test() { + for key in ${(@k)icons}; do + # The lower color spectrum in ZSH makes big steps. Choosing + # the next color has enough contrast to read. + local random_color=$((RANDOM % 8)) + local next_color=$((random_color+1)) + "$1_prompt_segment" "$0" "$2" "$random_color" "$next_color" "$key" "$key" + done +} diff --git a/segments/other/openfoam.p9k b/segments/other/openfoam.p9k new file mode 100644 index 000000000..db87faec7 --- /dev/null +++ b/segments/other/openfoam.p9k @@ -0,0 +1,11 @@ +################################################################ +# Display openfoam information +prompt_openfoam() { + local wm_project_version="$WM_PROJECT_VERSION" + local wm_fork="$WM_FORK" + if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + fi +} diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k new file mode 100644 index 000000000..b5d6172b3 --- /dev/null +++ b/segments/other/todo.p9k @@ -0,0 +1,10 @@ +################################################################ +# todo.sh: shows the number of tasks in your todo.sh file +prompt_todo() { + if $(hash todo.sh 2>&-); then + count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') + if [[ "$count" = <-> ]]; then + "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' + fi + fi +} From 6811beba3b4749e10220f62b2e6f054f895f2ebf Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 10 Mar 2018 18:10:44 +0400 Subject: [PATCH 02/55] SEPARATION OF SEGMENTS INTO OWN FILES NEW: This PR moves all the segments into their own files. It adds the ability to register icons dynamically, thus making icon management the responsibility of the segment. This also allows us to only load the icons we require instead of loading all the icons. Utilities: union - returns the union of two arrays UPDATES: Split OS detection logic (in utilities) and recoded PROMPT_OS to make use of the split. TODO: Update all the comments in all the files to ensure uniformity. NOTES: This is also the first step in preparing for a web configurator. --- functions/colors.zsh | 9 + functions/icons.zsh | 635 ++++++++--------------- functions/utilities.zsh | 132 ++--- functions/vcs.zsh | 9 + powerlevel9k.zsh-theme | 34 +- segments/core/background_jobs.p9k | 24 + segments/core/battery.p9k | 54 +- segments/core/command_execution_time.p9k | 24 + segments/core/context.p9k | 10 + segments/core/date.p9k | 24 + segments/core/dir.p9k | 68 +++ segments/core/dir_writable.p9k | 24 + segments/core/disk_usage.p9k | 25 + segments/core/history.p9k | 26 +- segments/core/host.p9k | 38 ++ segments/core/ip.p9k | 24 + segments/core/load.p9k | 24 + segments/core/newline.p9k | 12 +- segments/core/os_icon.p9k | 338 +++++++++++- segments/core/public_ip.p9k | 37 ++ segments/core/ram.p9k | 24 + segments/core/root_indicator.p9k | 24 + segments/core/ssh.p9k | 24 + segments/core/status.p9k | 52 ++ segments/core/swap.p9k | 24 + segments/core/test_stats.p9k | 10 + segments/core/time.p9k | 25 + segments/core/user.p9k | 49 ++ segments/core/vi_mode.p9k | 32 ++ segments/core/vpn_ip.p9k | 24 + segments/developer/anaconda.p9k | 24 + segments/developer/aws.p9k | 24 + segments/developer/aws_eb_env.p9k | 24 + segments/developer/chruby.p9k | 24 + segments/developer/detect_virt.p9k | 10 + segments/developer/docker_machine.p9k | 24 + segments/developer/go_version.p9k | 24 + segments/developer/kubecontext.p9k | 24 + segments/developer/node_env.p9k | 24 + segments/developer/node_version.p9k | 24 + segments/developer/nvm.p9k | 24 + segments/developer/php_version.p9k | 10 + segments/developer/pyenv.p9k | 24 + segments/developer/rbenv.p9k | 24 + segments/developer/rspec_stats.p9k | 24 + segments/developer/rust_version.p9k | 24 + segments/developer/rvm.p9k | 24 + segments/developer/swift_version.p9k | 24 + segments/developer/symfony2_tests.p9k | 24 + segments/developer/symfony2_version.p9k | 24 + segments/developer/vcs.p9k | 240 +++++++++ segments/developer/virtualenv.p9k | 24 + segments/other/dropbox.p9k | 24 + segments/other/icons_test.p9k | 10 + segments/other/openfoam.p9k | 10 + segments/other/todo.p9k | 24 + 56 files changed, 2101 insertions(+), 542 deletions(-) create mode 100644 segments/core/vi_mode.p9k diff --git a/functions/colors.zsh b/functions/colors.zsh index f421165cb..f38feb1fc 100755 --- a/functions/colors.zsh +++ b/functions/colors.zsh @@ -1,4 +1,13 @@ +#!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Color functions # This file holds some color-functions for diff --git a/functions/icons.zsh b/functions/icons.zsh index b929f73ae..a3a816218 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -1,4 +1,13 @@ +#!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # icons # This file holds the icon definitions and @@ -6,10 +15,47 @@ # https://github.com/bhilburn/powerlevel9k ################################################################ +################################################################ # These characters require the Powerline fonts to work properly. If you see # boxes or bizarre characters below, your fonts are not correctly installed. If # you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to # `compatible`. This shows all icons in regular symbols. +################################################################ + +typeset -gAH icons + +local map +case $POWERLEVEL9K_MODE in + 'flat'|'awesome-patched') map=3 ;; + 'awesome-fontconfig') map=4 ;; + 'awesome-mapped-fontconfig') map=5 ;; + 'nerdfont-complete'|'nerdfont-fontconfig') map=6 ;; + *) map=2 ;; +esac + +################################################################ +# This function allows a segment to register the icons that it requires. +# These icons may be overriden by the user later. +# Arguments may be a direct call or an array. +# +# Direct call: +# register_icon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' +# +# Calling with an array: +# prompt_icon=( +# 'Gen' # codepoint/text for generic icons/fonts +# "name_of_icon" # name under which icon will be registered +# $'\uXXX' # codepoint for flat / awesome-patched +# $'\uXXX' # codepoint for awesome-fontconfig +# '\u'$CODEPOINT_OF_AWESOME_xxx # codepoint for awesome-mapped-fontconfig +# $'\uXXX' # codepoint for nerdfont (complete / fontconfig) +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon +register_icon() { + local arr=("$@") + icons[${arr[1]}]=${arr[$map]} +} # Initialize the icon list according to the user's `POWERLEVEL9K_MODE`. typeset -gAH icons @@ -25,85 +71,9 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uE801' #  - SUDO_ICON $'\uF09C' #  - RUBY_ICON $'\uE847 ' #  - AWS_ICON $'\uE895' #  - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\uE82F ' #  - TEST_ICON $'\uE891' #  - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\uE894' #  - DISK_ICON $'\uE1AE ' #  - OK_ICON $'\u2714' # ✔ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON $'\uE26E' #  - WINDOWS_ICON $'\uE26F' #  - FREEBSD_ICON $'\U1F608 ' # 😈 - ANDROID_ICON $'\uE270' #  - LINUX_ICON $'\uE271' #  - LINUX_ARCH_ICON 'Arc' - LINUX_DEBIAN_ICON 'Deb' - LINUX_UBUNTU_ICON 'Ubu' - LINUX_CENTOS_ICON 'Cen' - LINUX_COREOS_ICON 'Cor' - LINUX_ELEMENTARY_ICON 'Elm' - LINUX_MINT_ICON 'LMi' - LINUX_FEDORA_ICON 'Fed' - LINUX_GENTOO_ICON 'Gen' - LINUX_MAGEIA_ICON 'Mag' - LINUX_OPENSUSE_ICON 'OSu' - LINUX_SABAYON_ICON 'Sab' - LINUX_SLACKWARE_ICON 'Sla' - SUNOS_ICON $'\U1F31E ' # 🌞 - HOME_ICON $'\uE12C' #  - HOME_SUB_ICON $'\uE18D' #  - FOLDER_ICON $'\uE818' #  - NETWORK_ICON $'\uE1AD' #  - LOAD_ICON $'\uE190 ' #  - SWAP_ICON $'\uE87D' #  - RAM_ICON $'\uE1E2 ' #  - SERVER_ICON $'\uE895' #  - VCS_UNTRACKED_ICON $'\uE16C' #  - VCS_UNSTAGED_ICON $'\uE17C' #  - VCS_STAGED_ICON $'\uE168' #  - VCS_STASH_ICON $'\uE133 ' #  - #VCS_INCOMING_CHANGES_ICON $'\uE1EB ' #  - #VCS_INCOMING_CHANGES_ICON $'\uE80D ' #  - VCS_INCOMING_CHANGES_ICON $'\uE131 ' #  - #VCS_OUTGOING_CHANGES_ICON $'\uE1EC ' #  - #VCS_OUTGOING_CHANGES_ICON $'\uE80E ' #  - VCS_OUTGOING_CHANGES_ICON $'\uE132 ' #  - VCS_TAG_ICON $'\uE817 ' #  - VCS_BOOKMARK_ICON $'\uE87B' #  - VCS_COMMIT_ICON $'\uE821 ' #  - VCS_BRANCH_ICON $'\uE220 ' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON $'\uE20E ' #  - VCS_GIT_GITHUB_ICON $'\uE20E ' # - VCS_GIT_BITBUCKET_ICON $'\uE20E ' # - VCS_GIT_GITLAB_ICON $'\uE20E ' # - VCS_HG_ICON $'\uE1C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON '' - PYTHON_ICON $'\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UE138' #  - EXECUTION_TIME_ICON $'\UE89C' #  - SSH_ICON '(ssh)' - VPN_ICON '(vpn)' - KUBERNETES_ICON $'\U2388' # ⎈ - DROPBOX_ICON $'\UF16B' #  - DATE_ICON $'\uE184' #  - TIME_ICON $'\uE12E' #  ) ;; 'awesome-fontconfig') @@ -117,81 +87,9 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uF201' #  - SUDO_ICON $'\uF09C' #  - RUBY_ICON $'\uF219 ' #  - AWS_ICON $'\uF270' #  - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\uF013 ' #  - TEST_ICON $'\uF291' #  - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\U1F50B' # 🔋 - DISK_ICON $'\uF0A0 ' #  - OK_ICON $'\u2714' # ✔ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON $'\uF179' #  - WINDOWS_ICON $'\uF17A' #  - FREEBSD_ICON $'\U1F608 ' # 😈 - ANDROID_ICON $'\uE17B' #  - LINUX_ICON $'\uF17C' #  - LINUX_ARCH_ICON 'Arc' - LINUX_DEBIAN_ICON 'Deb' - LINUX_UBUNTU_ICON 'Ubu' - LINUX_CENTOS_ICON 'Cen' - LINUX_COREOS_ICON 'Cor' - LINUX_ELEMENTARY_ICON 'Elm' - LINUX_MINT_ICON 'LMi' - LINUX_FEDORA_ICON 'Fed' - LINUX_GENTOO_ICON 'Gen' - LINUX_MAGEIA_ICON 'Mag' - LINUX_OPENSUSE_ICON 'OSu' - LINUX_SABAYON_ICON 'Sab' - LINUX_SLACKWARE_ICON 'Sla' - SUNOS_ICON $'\uF185 ' #  - HOME_ICON $'\uF015' #  - HOME_SUB_ICON $'\uF07C' #  - FOLDER_ICON $'\uF115' #  - NETWORK_ICON $'\uF09E' #  - LOAD_ICON $'\uF080 ' #  - SWAP_ICON $'\uF0E4' #  - RAM_ICON $'\uF0E4' #  - SERVER_ICON $'\uF233' #  - VCS_UNTRACKED_ICON $'\uF059' #  - VCS_UNSTAGED_ICON $'\uF06A' #  - VCS_STAGED_ICON $'\uF055' #  - VCS_STASH_ICON $'\uF01C ' #  - VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  - VCS_TAG_ICON $'\uF217 ' #  - VCS_BOOKMARK_ICON $'\uF27B' #  - VCS_COMMIT_ICON $'\uF221 ' #  - VCS_BRANCH_ICON $'\uF126 ' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON $'\uF1D3 ' #  - VCS_GIT_GITHUB_ICON $'\uF113 ' #  - VCS_GIT_BITBUCKET_ICON $'\uF171 ' #  - VCS_GIT_GITLAB_ICON $'\uF296 ' #  - VCS_HG_ICON $'\uF0C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON $'\uE6A8' #  - PYTHON_ICON $'\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UF023' #  - EXECUTION_TIME_ICON $'\uF253' - SSH_ICON '(ssh)' - VPN_ICON $'\uF023' - KUBERNETES_ICON $'\U2388' # ⎈ - DROPBOX_ICON $'\UF16B' #  - DATE_ICON $'\uF073 ' #  - TIME_ICON $'\uF017 ' #  ) ;; 'awesome-mapped-fontconfig') @@ -209,82 +107,14 @@ case $POWERLEVEL9K_MODE in fi icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP #  - SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  - RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG #  - TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  - BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  - DISK_ICON '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  - OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK #  - FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  - FREEBSD_ICON $'\U1F608 ' # 😈 - LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ARCH_ICON 'Arc' - LINUX_DEBIAN_ICON 'Deb' - LINUX_UBUNTU_ICON 'Ubu' - LINUX_CENTOS_ICON 'Cen' - LINUX_COREOS_ICON 'Cor' - LINUX_ELEMENTARY_ICON 'Elm' - LINUX_MINT_ICON 'LMi' - LINUX_FEDORA_ICON 'Fed' - LINUX_GENTOO_ICON 'Gen' - LINUX_MAGEIA_ICON 'Mag' - LINUX_OPENSUSE_ICON 'OSu' - LINUX_SABAYON_ICON 'Sab' - LINUX_SLACKWARE_ICON 'Sla' - SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  - HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  - HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  - FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  - NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  - LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  - SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  - VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  - VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  - VCS_STASH_ICON '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  - VCS_INCOMING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  - VCS_OUTGOING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  - VCS_TAG_ICON '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  - VCS_BOOKMARK_ICON '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  - VCS_COMMIT_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  - VCS_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  - VCS_GIT_ICON '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  - VCS_GIT_GITHUB_ICON '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  - VCS_GIT_BITBUCKET_ICON '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  - VCS_GIT_GITLAB_ICON '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  - VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON $'\uE6A8' #  - PYTHON_ICON $'\U1F40D' # 🐍 - SWIFT_ICON $'\uE655' #  - PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  - LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  - EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  - SSH_ICON '(ssh)' - VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK - KUBERNETES_ICON $'\U2388' # ⎈ - DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  - DATE_ICON $'\uF073 ' #  - TIME_ICON $'\uF017 ' #  + LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  + RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  + LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace + LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  + RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -299,81 +129,81 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uE614 ' #  - SUDO_ICON $'\uF09C' #  - RUBY_ICON $'\uF219 ' #  - AWS_ICON $'\uF270' #  - AWS_EB_ICON $'\UF1BD ' #  - BACKGROUND_JOBS_ICON $'\uF013 ' #  - TEST_ICON $'\uF188' #  - TODO_ICON $'\uF133' #  - BATTERY_ICON $'\UF240 ' #  - DISK_ICON $'\uF0A0' #  - OK_ICON $'\uF00C' #  - FAIL_ICON $'\uF00D' #  - SYMFONY_ICON $'\uE757' #  - NODE_ICON $'\uE617 ' #  +# CARRIAGE_RETURN_ICON $'\u21B5' # ↵ +# ROOT_ICON $'\uE614 ' #  +# SUDO_ICON $'\uF09C' #  +# RUBY_ICON $'\uF219 ' #  +# AWS_ICON $'\uF270' #  +# AWS_EB_ICON $'\UF1BD ' #  +# BACKGROUND_JOBS_ICON $'\uF013 ' #  +# TEST_ICON $'\uF188' #  +# TODO_ICON $'\uF133' #  +# BATTERY_ICON $'\UF240 ' #  +# DISK_ICON $'\uF0A0' #  +# OK_ICON $'\uF00C' #  +# FAIL_ICON $'\uF00D' #  +# SYMFONY_ICON $'\uE757' #  +# NODE_ICON $'\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON $'\uF179' #  - WINDOWS_ICON $'\uF17A' #  - FREEBSD_ICON $'\UF30E ' #  - ANDROID_ICON $'\uF17B' #  - LINUX_ARCH_ICON $'\uF300' #  - LINUX_DEBIAN_ICON $'\uF302' #  - LINUX_UBUNTU_ICON $'\uF30C' #  - LINUX_CENTOS_ICON $'\uF301' #  - LINUX_COREOS_ICON $'\uF30F' #  - LINUX_ELEMENTARY_ICON $'\uF311' #  - LINUX_FEDORA_ICON $'\uF303' #  - LINUX_GENTOO_ICON $'\uF310' #  - LINUX_MINT_ICON $'\uF304' #  - LINUX_MAGEIA_ICON $'\uF306' #  - LINUX_OPENSUSE_ICON $'\uF308' #  - LINUX_SABAYON_ICON $'\uF313' #  - LINUX_SLACKWARE_ICON $'\uF30A' #  - LINUX_ICON $'\uF17C' #  - SUNOS_ICON $'\uF185 ' #  - HOME_ICON $'\uF015' #  - HOME_SUB_ICON $'\uF07C' #  - FOLDER_ICON $'\uF115' #  - NETWORK_ICON $'\uF1EB' #  - LOAD_ICON $'\uF080 ' #  - SWAP_ICON $'\uF464' #  - RAM_ICON $'\uF0E4' #  - SERVER_ICON $'\uF0AE' #  - VCS_UNTRACKED_ICON $'\uF059' #  - VCS_UNSTAGED_ICON $'\uF06A' #  - VCS_STAGED_ICON $'\uF055' #  - VCS_STASH_ICON $'\uF01C ' #  - VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  - VCS_TAG_ICON $'\uF02B ' #  - VCS_BOOKMARK_ICON $'\uF461 ' #  - VCS_COMMIT_ICON $'\uE729 ' #  - VCS_BRANCH_ICON $'\uF126 ' #  - VCS_REMOTE_BRANCH_ICON $'\uE728 ' #  - VCS_GIT_ICON $'\uF1D3 ' #  - VCS_GIT_GITHUB_ICON $'\uF113 ' #  - VCS_GIT_BITBUCKET_ICON $'\uE703 ' #  - VCS_GIT_GITLAB_ICON $'\uF296 ' #  - VCS_HG_ICON $'\uF0C3 ' #  - VCS_SVN_ICON $'\uE72D ' #  - RUST_ICON $'\uE7A8 ' #  - PYTHON_ICON $'\UE73C ' #  - SWIFT_ICON $'\uE755' #  - GO_ICON $'\uE626' #  - PUBLIC_IP_ICON $'\UF0AC' #  - LOCK_ICON $'\UF023' #  - EXECUTION_TIME_ICON $'\uF252' #  - SSH_ICON $'\uF489' #  - VPN_ICON '(vpn)' - KUBERNETES_ICON $'\U2388' # ⎈ - DROPBOX_ICON $'\UF16B' #  - DATE_ICON $'\uF073 ' #  - TIME_ICON $'\uF017 ' #  +# APPLE_ICON $'\uF179' #  +# WINDOWS_ICON $'\uF17A' #  +# FREEBSD_ICON $'\UF30E ' #  +# ANDROID_ICON $'\uF17B' #  +# LINUX_ARCH_ICON $'\uF300' #  +# LINUX_DEBIAN_ICON $'\uF302' #  +# LINUX_UBUNTU_ICON $'\uF30C' #  +# LINUX_CENTOS_ICON $'\uF301' #  +# LINUX_COREOS_ICON $'\uF30F' #  +# LINUX_ELEMENTARY_ICON $'\uF311' #  +# LINUX_FEDORA_ICON $'\uF303' #  +# LINUX_GENTOO_ICON $'\uF310' #  +# LINUX_MINT_ICON $'\uF304' #  +# LINUX_MAGEIA_ICON $'\uF306' #  +# LINUX_OPENSUSE_ICON $'\uF308' #  +# LINUX_SABAYON_ICON $'\uF313' #  +# LINUX_SLACKWARE_ICON $'\uF30A' #  +# LINUX_ICON $'\uF17C' #  +# SUNOS_ICON $'\uF185 ' #  +# HOME_ICON $'\uF015' #  +# HOME_SUB_ICON $'\uF07C' #  +# FOLDER_ICON $'\uF115' #  +# NETWORK_ICON $'\uF1EB' #  +# LOAD_ICON $'\uF080 ' #  +# SWAP_ICON $'\uF464' #  +# RAM_ICON $'\uF0E4' #  +# SERVER_ICON $'\uF0AE' #  +# VCS_UNTRACKED_ICON $'\uF059' #  +# VCS_UNSTAGED_ICON $'\uF06A' #  +# VCS_STAGED_ICON $'\uF055' #  +# VCS_STASH_ICON $'\uF01C ' #  +# VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  +# VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  +# VCS_TAG_ICON $'\uF02B ' #  +# VCS_BOOKMARK_ICON $'\uF461 ' #  +# VCS_COMMIT_ICON $'\uE729 ' #  +# VCS_BRANCH_ICON $'\uF126 ' #  +# VCS_REMOTE_BRANCH_ICON $'\uE728 ' #  +# VCS_GIT_ICON $'\uF1D3 ' #  +# VCS_GIT_GITHUB_ICON $'\uF113 ' #  +# VCS_GIT_BITBUCKET_ICON $'\uE703 ' #  +# VCS_GIT_GITLAB_ICON $'\uF296 ' #  +# VCS_HG_ICON $'\uF0C3 ' #  +# VCS_SVN_ICON $'\uE72D ' #  +# RUST_ICON $'\uE7A8 ' #  +# PYTHON_ICON $'\UE73C ' #  +# SWIFT_ICON $'\uE755' #  +# GO_ICON $'\uE626' #  +# PUBLIC_IP_ICON $'\UF0AC' #  +# LOCK_ICON $'\UF023' #  +# EXECUTION_TIME_ICON $'\uF252' #  +# SSH_ICON $'\uF489' #  +# VPN_ICON '(vpn)' +# KUBERNETES_ICON $'\U2388' # ⎈ +# DROPBOX_ICON $'\UF16B' #  +# DATE_ICON $'\uF073 ' #  +# TIME_ICON $'\uF017 ' #  ) ;; *) @@ -387,118 +217,113 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\u26A1' # ⚡ - SUDO_ICON $'\uE0A2' #  - RUBY_ICON '' - AWS_ICON 'AWS:' - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\u2699' # ⚙ - TEST_ICON '' - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\U1F50B' # 🔋 - DISK_ICON $'hdd ' - OK_ICON $'\u2714' # ✔ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ +# CARRIAGE_RETURN_ICON $'\u21B5' # ↵ +# ROOT_ICON $'\u26A1' # ⚡ +# SUDO_ICON $'\uE0A2' #  +# RUBY_ICON '' +# AWS_ICON 'AWS:' +# AWS_EB_ICON $'\U1F331 ' # 🌱 +# BACKGROUND_JOBS_ICON $'\u2699' # ⚙ +# TEST_ICON '' +# TODO_ICON $'\u2611' # ☑ +# BATTERY_ICON $'\U1F50B' # 🔋 +# DISK_ICON $'hdd ' +# OK_ICON $'\u2714' # ✔ +# FAIL_ICON $'\u2718' # ✘ +# SYMFONY_ICON 'SF' +# NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON 'OSX' - WINDOWS_ICON 'WIN' - FREEBSD_ICON 'BSD' - ANDROID_ICON 'And' - LINUX_ICON 'Lx' - LINUX_ARCH_ICON 'Arc' - LINUX_DEBIAN_ICON 'Deb' - LINUX_UBUNTU_ICON 'Ubu' - LINUX_CENTOS_ICON 'Cen' - LINUX_COREOS_ICON 'Cor' - LINUX_ELEMENTARY_ICON 'Elm' - LINUX_MINT_ICON 'LMi' - LINUX_FEDORA_ICON 'Fed' - LINUX_GENTOO_ICON 'Gen' - LINUX_MAGEIA_ICON 'Mag' - LINUX_OPENSUSE_ICON 'OSu' - LINUX_SABAYON_ICON 'Sab' - LINUX_SLACKWARE_ICON 'Sla' - SUNOS_ICON 'Sun' - HOME_ICON '' - HOME_SUB_ICON '' - FOLDER_ICON '' - NETWORK_ICON 'IP' - LOAD_ICON 'L' - SWAP_ICON 'SWP' - RAM_ICON 'RAM' - SERVER_ICON '' - VCS_UNTRACKED_ICON '?' - VCS_UNSTAGED_ICON $'\u25CF' # ● - VCS_STAGED_ICON $'\u271A' # ✚ - VCS_STASH_ICON $'\u235F' # ⍟ - VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓ - VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑ - VCS_TAG_ICON '' - VCS_BOOKMARK_ICON $'\u263F' # ☿ - VCS_COMMIT_ICON '' - VCS_BRANCH_ICON $'\uE0A0 ' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON '' - VCS_GIT_GITHUB_ICON '' - VCS_GIT_BITBUCKET_ICON '' - VCS_GIT_GITLAB_ICON '' - VCS_HG_ICON '' - VCS_SVN_ICON '' - RUST_ICON '' - PYTHON_ICON '' - SWIFT_ICON 'Swift' - GO_ICON 'Go' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UE0A2' - EXECUTION_TIME_ICON 'Dur' - SSH_ICON '(ssh)' - VPN_ICON '(vpn)' - KUBERNETES_ICON $'\U2388' # ⎈ - DROPBOX_ICON 'Dropbox' - DATE_ICON '' - TIME_ICON '' +# APPLE_ICON 'OSX' +# WINDOWS_ICON 'WIN' +# FREEBSD_ICON 'BSD' +# ANDROID_ICON 'And' +# LINUX_ICON 'Lx' +# LINUX_ARCH_ICON 'Arc' +# LINUX_DEBIAN_ICON 'Deb' +# LINUX_UBUNTU_ICON 'Ubu' +# LINUX_CENTOS_ICON 'Cen' +# LINUX_COREOS_ICON 'Cor' +# LINUX_ELEMENTARY_ICON 'Elm' +# LINUX_MINT_ICON 'LMi' +# LINUX_FEDORA_ICON 'Fed' +# LINUX_GENTOO_ICON 'Gen' +# LINUX_MAGEIA_ICON 'Mag' +# LINUX_OPENSUSE_ICON 'OSu' +# LINUX_SABAYON_ICON 'Sab' +# LINUX_SLACKWARE_ICON 'Sla' +# SUNOS_ICON 'Sun' +# HOME_ICON '' +# HOME_SUB_ICON '' +# FOLDER_ICON '' +# NETWORK_ICON 'IP' +# LOAD_ICON 'L' +# SWAP_ICON 'SWP' +# RAM_ICON 'RAM' +# SERVER_ICON '' +# VCS_UNTRACKED_ICON '?' +# VCS_UNSTAGED_ICON $'\u25CF' # ● +# VCS_STAGED_ICON $'\u271A' # ✚ +# VCS_STASH_ICON $'\u235F' # ⍟ +# VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓ +# VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑ +# VCS_TAG_ICON '' +# VCS_BOOKMARK_ICON $'\u263F' # ☿ +# VCS_COMMIT_ICON '' +# VCS_BRANCH_ICON $'\uE0A0 ' #  +# VCS_REMOTE_BRANCH_ICON $'\u2192' # → +# VCS_GIT_ICON '' +# VCS_GIT_GITHUB_ICON '' +# VCS_GIT_BITBUCKET_ICON '' +# VCS_GIT_GITLAB_ICON '' +# VCS_HG_ICON '' +# VCS_SVN_ICON '' +# RUST_ICON '' +# PYTHON_ICON '' +# SWIFT_ICON 'Swift' +# GO_ICON 'Go' +# PUBLIC_IP_ICON '' +# LOCK_ICON $'\UE0A2' +# EXECUTION_TIME_ICON 'Dur' +# SSH_ICON '(ssh)' +# VPN_ICON '(vpn)' +# KUBERNETES_ICON $'\U2388' # ⎈ +# DROPBOX_ICON 'Dropbox' +# DATE_ICON '' +# TIME_ICON '' ) ;; esac # Override the above icon settings with any user-defined variables. case $POWERLEVEL9K_MODE in - 'flat') - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons[LEFT_SEGMENT_SEPARATOR]='' - icons[RIGHT_SEGMENT_SEPARATOR]='' - icons[LEFT_SUBSEGMENT_SEPARATOR]='|' - icons[RIGHT_SUBSEGMENT_SEPARATOR]='|' - ;; - 'compatible') - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons[LEFT_SEGMENT_SEPARATOR]=$'\u2B80' # ⮀ - icons[RIGHT_SEGMENT_SEPARATOR]=$'\u2B82' # ⮂ - icons[VCS_BRANCH_ICON]='@' - ;; + 'flat') + # Set the right locale to protect special characters + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + icons[LEFT_SEGMENT_SEPARATOR]='' + icons[RIGHT_SEGMENT_SEPARATOR]='' + icons[LEFT_SUBSEGMENT_SEPARATOR]='|' + icons[RIGHT_SUBSEGMENT_SEPARATOR]='|' + ;; + 'compatible') + # Set the right locale to protect special characters + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + icons[LEFT_SEGMENT_SEPARATOR]=$'\u2B80' # ⮀ + icons[RIGHT_SEGMENT_SEPARATOR]=$'\u2B82' # ⮂ + ;; esac -if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then - icons[VCS_BRANCH_ICON]='' -fi - # Safety function for printing icons # Prints the named icon, or if that icon is undefined, the string name. function print_icon() { - local icon_name=$1 - local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} - if defined "$ICON_USER_VARIABLE"; then - echo -n "${(P)ICON_USER_VARIABLE}" - else - echo -n "${icons[$icon_name]}" - fi + local icon_name=$1 + local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} + if defined "$ICON_USER_VARIABLE"; then + echo -n "${(P)ICON_USER_VARIABLE}" + else + echo -n "${icons[$icon_name]}" + fi } # Get a list of configured icons @@ -506,15 +331,15 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. get_icon_names() { - # Iterate over a ordered list of keys of the icons array - for key in ${(@kon)icons}; do - echo -n "POWERLEVEL9K_$key: " - if [[ "${1}" == "original" ]]; then - # print the original icons as they are defined in the array above - echo "${icons[$key]}" - else - # print the icons as they are configured by the user - echo "$(print_icon "$key")" - fi - done + # Iterate over a ordered list of keys of the icons array + for key in ${(@kon)icons}; do + echo -n "POWERLEVEL9K_$key: " + if [[ "${1}" == "original" ]]; then + # print the original icons as they are defined in the array above + echo "${icons[$key]}" + else + # print the icons as they are configured by the user + echo "$(print_icon "$key")" + fi + done } diff --git a/functions/utilities.zsh b/functions/utilities.zsh index a95599226..6ec6b2a99 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -1,4 +1,13 @@ +#!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Utility functions # This file holds some utility-functions for @@ -6,6 +15,21 @@ # https://github.com/bhilburn/powerlevel9k ################################################################ +# Determine OS and version (if applicable) +case $(uname) in + Darwin) OS='macOS' ;; + CYGWIN_NT-*) OS='Windows' ;; + FreeBSD|OpenBSD|DragonFly) OS='BSD' ;; + Linux) + OS='Linux' + OS_ID="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + case $(uname -o 2>/dev/null) in + Android) OS='Android' ;; + esac + ;; + SunOS) OS='Solaris' ;; +esac + # Exits with 0 if a variable has been previously defined (even if empty) # Takes the name of a variable that should be checked. function defined() { @@ -79,106 +103,20 @@ function getRelevantItem() { done } -# OS detection -case $(uname) in - Darwin) - OS='OSX' - OS_ICON=$(print_icon 'APPLE_ICON') - ;; - CYGWIN_NT-*) - OS='Windows' - OS_ICON=$(print_icon 'WINDOWS_ICON') - ;; - FreeBSD) - OS='BSD' - OS_ICON=$(print_icon 'FREEBSD_ICON') - ;; - OpenBSD) - OS='BSD' - OS_ICON=$(print_icon 'FREEBSD_ICON') - ;; - DragonFly) - OS='BSD' - OS_ICON=$(print_icon 'FREEBSD_ICON') - ;; - Linux) - OS='Linux' - os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" - case "$os_release_id" in - "arch") - OS_ICON=$(print_icon 'LINUX_ARCH_ICON') - ;; - "debian") - OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') - ;; - "ubuntu") - OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') - ;; - "elementary") - OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') - ;; - "fedora") - OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') - ;; - "coreos") - OS_ICON=$(print_icon 'LINUX_COREOS_ICON') - ;; - "gentoo") - OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') - ;; - "mageia") - OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') - ;; - "centos") - OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') - ;; - "opensuse"|"tumbleweed") - OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') - ;; - "sabayon") - OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') - ;; - "slackware") - OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') - ;; - "linuxmint") - OS_ICON=$(print_icon 'LINUX_MINT_ICON') - ;; - *) - OS='Linux' - OS_ICON=$(print_icon 'LINUX_ICON') - ;; - esac - - # Check if we're running on Android - case $(uname -o 2>/dev/null) in - Android) - OS='Android' - OS_ICON=$(print_icon 'ANDROID_ICON') - ;; - esac - ;; - SunOS) - OS='Solaris' - OS_ICON=$(print_icon 'SUNOS_ICON') - ;; - *) - OS='' - OS_ICON='' - ;; -esac - # Determine the correct sed parameter. # # `sed` is unfortunately not consistent across OSes when it comes to flags. SED_EXTENDED_REGEX_PARAMETER="-r" -if [[ "$OS" == 'OSX' ]]; then +if [[ "$OS" == 'macOS' ]]; then local IS_BSD_SED="$(sed --version &>> /dev/null || echo "BSD sed")" if [[ -n "$IS_BSD_SED" ]]; then SED_EXTENDED_REGEX_PARAMETER="-E" fi fi +# Combine the PROMPT_ELEMENTS +POWERLEVEL9K_PROMPT_ELEMENTS=(union $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS $POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) + # Determine if the passed segment is used in the prompt # # Pass the name of the segment to this function to test for its presence in @@ -357,3 +295,17 @@ function upsearch () { popd > /dev/null fi } + +# Union of two or more arrays +# USAGE: +# union [arr1[ arr2[ ...]]] +# EXAMPLE: +# $ arr1=('a' 'b' 'c') +# $ arr2=('b' 'c' 'd') +# $ arr2=('c' 'd' 'e') +# $ union $arr1 $arr2 $arr3 +# > a b c d e +union() { + typeset -U sections=("$@") + echo $sections +} diff --git a/functions/vcs.zsh b/functions/vcs.zsh index e2e9f3a36..f4d28a883 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -1,4 +1,13 @@ +#!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # vcs # This file holds supplemental VCS functions diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14b1fd027..264e9920c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1,3 +1,4 @@ +#!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ # powerlevel9k Theme @@ -31,7 +32,7 @@ else # https://github.com/zsh-users/antigen/issues/581 p9k_directory=$PWD else - print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR work from within an (eval).%f" + print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR to work from within an (eval).%f" return 1 fi else @@ -282,22 +283,6 @@ prompt_custom() { fi } -################################################################ -# Vi Mode: show editing mode (NORMAL|INSERT) -set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" -set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" -prompt_vi_mode() { - case ${KEYMAP} in - vicmd) - "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" - ;; - main|viins|*) - if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi - "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" - ;; - esac -} - ################################################################ # Prompt processing and drawing ################################################################ @@ -395,11 +380,6 @@ NEWLINE=' [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" } -zle-keymap-select () { - zle reset-prompt - zle -R -} - set_default POWERLEVEL9K_IGNORE_TERM_COLORS false set_default POWERLEVEL9K_IGNORE_TERM_LANG false @@ -451,9 +431,9 @@ prompt_powerlevel9k_setup() { autoload -U colors && colors # load only the segments that are being used! + local segment_name for segment in $p9k_directory/segments/**/*.p9k; do - local segment_file=${segment##*/} - local segment_name=${segment_file//.p9k/} + segment_name=${${segment##*/}%.p9k} if segment_in_use "$segment_name"; then source "${segment}" fi @@ -462,10 +442,6 @@ prompt_powerlevel9k_setup() { # cleanup temporary variable unset p9k_directory - if segment_in_use "vcs"; then - powerlevel9k_vcs_init - fi - # initialize timing functions zmodload zsh/datetime @@ -478,8 +454,6 @@ prompt_powerlevel9k_setup() { # prepare prompts add-zsh-hook precmd powerlevel9k_prepare_prompts add-zsh-hook preexec powerlevel9k_preexec - - zle -N zle-keymap-select } prompt_powerlevel9k_teardown() { diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index 87117bb60..c1e0f6a04 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "BACKGROUND_JOBS_ICON" + $'\u2699' # ⚙ + $'\uE82F ' #  + $'\uF013 ' #  + '\u'$CODEPOINT_OF_AWESOME_COG' ' #  + $'\uF013 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⚙     +#register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' + ################################################################ # Segment to indicate background jobs with an icon. set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index 868301a52..fe2b8686a 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "BATTERY_ICON" + $'\U1F50B' # 🔋 + $'\uE894' #  + $'\U1F50B' # 🔋 + '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  + $'\UF240 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# 🔋  🔋   +#register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' + ################################################################ # Segment that displays the battery status in levels and colors prompt_battery() { @@ -13,7 +37,7 @@ prompt_battery() { # Set default values if the user did not configure them set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 - if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then + if [[ $OS =~ macOS && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then # obtain battery information from system local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" # return if there is no battery on system @@ -89,21 +113,23 @@ prompt_battery() { message="$bat_percent%%" fi - # override default icon if we are using battery stages - if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) - if [[ $segment > 1 ]]; then - local offset=$(( ($bat_percent / $segment) + 1 )) - # check if the stages are in an array or a string - [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]] && [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]]; then + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi fi - fi - # override the default color if we are using a color level array - if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) - local offset=$(( ($bat_percent / $segment) + 1 )) - "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + fi else # Draw the prompt_segment "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index 5ba75d36e..a7eec3fa0 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "EXECUTION_TIME_ICON" + 'Dur' + $'\UE89C' #  + $'\uF253' + '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  + $'\uF252' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#    +#register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' + ################################################################ # Display the duration the command needed to run. prompt_command_execution_time() { diff --git a/segments/core/context.p9k b/segments/core/context.p9k index 5416504a9..2ba53c762 100644 --- a/segments/core/context.p9k +++ b/segments/core/context.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print diff --git a/segments/core/date.p9k b/segments/core/date.p9k index 3fddbcf28..82164ec1b 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "DATE_ICON" + '' + $'\uE184' #  + $'\uF073 ' #  + $'\uF073 ' #  + $'\uF073 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' + ################################################################ # System date prompt_date() { diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index fbe398ff7..db9247797 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -1,5 +1,73 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +# Icon array format: +# +# +# +# +# +# +local prompt_icon=( + "HOME_ICON" + '' + $'\uE12C' #  + $'\uF015' #  + '\u'$CODEPOINT_OF_AWESOME_HOME #  + $'\uF015' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' + +prompt_icon=( + "HOME_SUB_ICON" + '' + $'\uE18D' #  + $'\uF07C' #  + '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  + $'\uF07C' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' + +prompt_icon=( + "FOLDER_ICON" + '' + $'\uE818' #  + $'\uF115' #  + '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + $'\uF115' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' + +prompt_icon=( + "LOCK_ICON" + $'\UE0A2' + $'\UE138' #  + $'\UF023' #  + '\u'$CODEPOINT_OF_AWESOME_LOCK #  + $'\UF023' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' + ################################################################ # Dir: current working directory # Parameters: diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index 8a6d70e55..d09bf153b 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "LOCK_ICON" + $'\UE0A2' + $'\UE138' #  + $'\UF023' #  + '\u'$CODEPOINT_OF_AWESOME_LOCK #  + $'\UF023' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' + ############################################################### # dir_writable: Display information about the user's permission to write in the current directory prompt_dir_writable() { diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index 087d56b33..83895b09b 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -1,3 +1,28 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "DISK_ICON" + $'hdd ' + $'\uE1AE ' #  + $'\uF0A0 ' #  + '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  + $'\uF0A0' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' + + ################################################################ # Segment that indicates usage level of current partition. set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false diff --git a/segments/core/history.p9k b/segments/core/history.p9k index 4173f19b1..66ef7f3f8 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -1,5 +1,29 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "HISTORY_ICON" + '' + '' + $'\uE29A' #  + $'\uE29A' #  + $'\uE29A' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#    +#register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' + ################################################################ # Command number (in local history) prompt_history() { - "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' + "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' } diff --git a/segments/core/host.p9k b/segments/core/host.p9k index f7d2c1948..beee6088d 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -1,3 +1,41 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SSH_ICON" + '(ssh)' + '(ssh)' + '(ssh)' + '(ssh)' + $'\uF489' #  +) +register_icon "$prompt_icon[@]" + +#  +#register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' + +prompt_icon=( + "HOST_ICON" + '' + '' + $'\uF67C' #  + $'\uF67C' #  + $'\uF67C' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#    +#register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' + + ################################################################ # Host: machine (where am I) set_default POWERLEVEL9K_HOST_TEMPLATE "%m" diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index ef74538e9..f189a4d65 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "NETWORK_ICON" + 'IP' + $'\uE1AD' #  + $'\uF09E' #  + '\u'$CODEPOINT_OF_AWESOME_RSS #  + $'\uF1EB' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' + ################################################################ # Segment to display the current IP address prompt_ip() { diff --git a/segments/core/load.p9k b/segments/core/load.p9k index 4f455c703..5a924fca5 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "LOAD_ICON" + 'L' + $'\uE190 ' #  + $'\uF080 ' #  + '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  + $'\uF080 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' + ################################################################ # Segment to display load set_default POWERLEVEL9K_LOAD_WHICH 5 diff --git a/segments/core/newline.p9k b/segments/core/newline.p9k index 9ce59a02f..2f9a3b9a6 100644 --- a/segments/core/newline.p9k +++ b/segments/core/newline.p9k @@ -1,5 +1,15 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# A newline in your prompt, so you can segments on multiple lines. +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +################################################################ +# A newline in your prompt, so you can do segments on multiple lines. prompt_newline() { local lws newline [[ "$1" == "right" ]] && return diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index 1fc030239..08ea26c1f 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -1,5 +1,341 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon + +# OS detection +case "$OS" in + "macOS") + prompt_icon=( + "APPLE_ICON" + 'macOS' + $'\uE26E' #  + $'\uF179' #  + '\u'$CODEPOINT_OF_AWESOME_APPLE #  + $'\uF179' #  + ) + register_icon "$prompt_icon[@]" + + #     + #register_icon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' + + OS_ICON='APPLE_ICON' + ;; + "Windows") + prompt_icon=( + "WINDOWS_ICON" + 'WIN' + $'\uE26F' #  + $'\uF17A' #  + $'\uF17A' #  + $'\uF17A' #  + ) + register_icon "$prompt_icon[@]" + + #     + #register_icon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' + + OS_ICON='WINDOWS_ICON' + ;; + "BSD") + prompt_icon=( + "FREEBSD_ICON" + 'BSD' + $'\U1F608 ' # 😈 + $'\U1F608 ' # 😈 + $'\U1F608 ' # 😈 + $'\UF30E ' #  + ) + register_icon "$prompt_icon[@]" + + # 😈 😈 😈  + #register_icon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' + + OS_ICON='FREEBSD_ICON' + ;; +# OpenBSD) +# OS_ICON='FREEBSD_ICON' +# ;; +# DragonFly) +# OS_ICON='FREEBSD_ICON' +# ;; + "Linux") + case "$OS_ID" in + "arch") + prompt_icon=( + "LINUX_ARCH_ICON" + 'Arc' + 'Arc' + 'Arc' + 'Arc' + $'\uF300' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' + + OS_ICON='LINUX_ARCH_ICON' + ;; + "debian") + prompt_icon=( + "LINUX_DEBIAN_ICON" + 'Deb' + 'Deb' + 'Deb' + 'Deb' + $'\uF302' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' + + OS_ICON='LINUX_DEBIAN_ICON' + ;; + "ubuntu") + prompt_icon=( + "LINUX_UBUNTU_ICON" + 'Ubu' + 'Ubu' + 'Ubu' + 'Ubu' + $'\uF30C' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' + + OS_ICON='LINUX_UBUNTU_ICON' + ;; + "elementary") + prompt_icon=( + "LINUX_ELEMENTARY_ICON" + 'Elm' + 'Elm' + 'Elm' + 'Elm' + $'\uF311' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' + + OS_ICON='LINUX_ELEMENTARY_ICON' + ;; + "fedora") + prompt_icon=( + "LINUX_FEDORA_ICON" + 'Fed' + 'Fed' + 'Fed' + 'Fed' + $'\uF303' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' + + OS_ICON='LINUX_FEDORA_ICON' + ;; + "coreos") + prompt_icon=( + "LINUX_COREOS_ICON" + 'Cor' + 'Cor' + 'Cor' + 'Cor' + $'\uF30F' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' + + OS_ICON='LINUX_COREOS_ICON' + ;; + "gentoo") + prompt_icon=( + "LINUX_GENTOO_ICON" + 'Gen' + 'Gen' + 'Gen' + 'Gen' + $'\uF310' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' + + OS_ICON='LINUX_GENTOO_ICON' + ;; + "mageia") + prompt_icon=( + "LINUX_MAGEIA_ICON" + 'Mag' + 'Mag' + 'Mag' + 'Mag' + $'\uF306' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' + + OS_ICON='LINUX_MAGEIA_ICON' + ;; + "centos") + prompt_icon=( + "LINUX_CENTOS_ICON" + 'Cen' + 'Cen' + 'Cen' + 'Cen' + $'\uF301' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' + + OS_ICON='LINUX_CENTOS_ICON' + ;; + "opensuse"|"tumbleweed") + prompt_icon=( + "LINUX_OPENSUSE_ICON" + 'OSu' + 'OSu' + 'OSu' + 'OSu' + $'\uF308' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' + + OS_ICON='LINUX_OPENSUSE_ICON' + ;; + "sabayon") + prompt_icon=( + "LINUX_SABAYON_ICON" + 'Sab' + 'Sab' + 'Sab' + 'Sab' + $'\uF313' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' + + OS_ICON='LINUX_SABAYON_ICON' + ;; + "slackware") + prompt_icon=( + "LINUX_SLACKWARE_ICON" + 'Sla' + 'Sla' + 'Sla' + 'Sla' + $'\uF30A' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' + + OS_ICON='LINUX_SLACKWARE_ICON' + ;; + "linuxmint") + prompt_icon=( + "LINUX_MINT_ICON" + 'LMi' + 'LMi' + 'LMi' + 'LMi' + $'\uF304' #  + ) + register_icon "$prompt_icon[@]" + + #  + #register_icon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' + + OS_ICON='LINUX_MINT_ICON' + ;; + *) + prompt_icon=( + "LINUX_ICON" + 'Lx' + $'\uE271' #  + $'\uF17C' #  + '\u'$CODEPOINT_OF_AWESOME_LINUX #  + $'\uF17C' #  + ) + register_icon "$prompt_icon[@]" + + #     + #register_icon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' + + OS_ICON='LINUX_ICON' + ;; + esac + ;; + "Android") + prompt_icon=( + "ANDROID_ICON" + 'And' + $'\uE270' #  + $'\uE17B' #  + $'\uF17B' #  + $'\uF17B' #  + ) + register_icon "$prompt_icon[@]" + + #     + #register_icon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' + + OS_ICON='ANDROID_ICON' + ;; + "Solaris") + prompt_icon=( + "SUNOS_ICON" + 'Sun' + $'\U1F31E ' # 🌞 + $'\uF185 ' #  + '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  + $'\uF185 ' #  + ) + register_icon "$prompt_icon[@]" + + # 🌞    + #register_icon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' + + OS_ICON='SUNOS_ICON' + ;; + *) + OS='' + OS_ICON='' + ;; +esac + +unset prompt_icon + ################################################################ # Segment to print a little OS icon prompt_os_icon() { - "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" + "$1_prompt_segment" "$0" "$2" "black" "white" $(print_icon "$OS_ICON") } diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 88d9f278c..6907e239f 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -1,3 +1,40 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "PUBLIC_IP_ICON" + '' + '' + '' + '\u'$CODEPOINT_OF_AWESOME_GLOBE #  + $'\UF0AC' #  +) +register_icon "$prompt_icon[@]" + +#   +#register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' + +prompt_icon=( + "VPN_ICON" + '(vpn)' + '(vpn)' + $'\uF023' #  + '\u'$CODEPOINT_OF_AWESOME_LOCK + '(vpn)' +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# +#register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' + ################################################################ # Public IP segment # Parameters: diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index 7d4e4bd8e..e9a97e413 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "RAM_ICON" + 'RAM' + $'\uE1E2 ' #  + $'\uF0E4' #  + '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  + $'\uF0E4' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' + ################################################################ # Segment to display free RAM and used Swap prompt_ram() { diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index 4d8059dbe..f035926cd 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "ROOT_ICON" + $'\u26A1' # ⚡ + $'\uE801' #  + $'\uF201' #  + '\u'$CODEPOINT_OF_OCTICONS_ZAP #  + $'\uE614 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⚡     +#register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' + ################################################################ # Segment to print an icon if user is root. prompt_root_indicator() { diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index bd46190d8..f71925a90 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SSH_ICON" + '(ssh)' + '(ssh)' + '(ssh)' + '(ssh)' + $'\uF489' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#  +#register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' + ################################################################ # Segment to display SSH icon when connected prompt_ssh() { diff --git a/segments/core/status.p9k b/segments/core/status.p9k index bf367c53a..f243fc31e 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -1,3 +1,55 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon +prompt_icon=( + "CARRIAGE_RETURN_ICON" + $'\u21B5' # ↵ + $'\u21B5' # ↵ + $'\u21B5' # ↵ + $'\u21B5' # ↵ + $'\u21B5' # ↵ +) +register_icon "$prompt_icon[@]" + +# ↵ ↵ ↵ ↵ ↵ +#register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' + +prompt_icon=( + "OK_ICON" + $'\u2714' # ✔ + $'\u2714' # ✔ + $'\u2714' # ✔ + '\u'$CODEPOINT_OF_AWESOME_CHECK #  + $'\uF00C' #  +) +register_icon "$prompt_icon[@]" + +# ✔ ✔ ✔   +#register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' + +prompt_icon=( + "FAIL_ICON" + $'\u2718' # ✘ + $'\u2718' # ✘ + $'\u2718' # ✘ + '\u'$CODEPOINT_OF_AWESOME_TIMES #  + $'\uF00D' #  +) +register_icon "$prompt_icon[@]" + +# ✘ ✘ ✘   +#register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' + +unset prompt_icon + ################################################################ # Status: When an error occur, return the error code, or a cross icon if option is set # Display an ok icon when no error occur, or hide the segment if option is set to false diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index 618ba465f..7ffa9b980 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SWAP_ICON" + 'SWP' + $'\uE87D' #  + $'\uF0E4' #  + '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  + $'\uF464' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +register_icon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' + ################################################################ # Segment to display Swap information prompt_swap() { diff --git a/segments/core/test_stats.p9k b/segments/core/test_stats.p9k index 52b64d8f4..3122a2b04 100644 --- a/segments/core/test_stats.p9k +++ b/segments/core/test_stats.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Show a ratio of tests vs code build_test_stats() { diff --git a/segments/core/time.p9k b/segments/core/time.p9k index e5c09186b..5abeef4aa 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -1,3 +1,28 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon +prompt_icon=( + "TIME_ICON" + '' + $'\uE12E' #  + $'\uF017 ' #  + $'\uF017 ' #  + $'\uF017 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' + ################################################################ # System time prompt_time() { diff --git a/segments/core/user.p9k b/segments/core/user.p9k index 9be134bd8..29dabdb57 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -1,3 +1,52 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "ROOT_ICON" + $'\u26A1' # ⚡ + $'\uE801' #  + $'\uF201' #  + '\u'$CODEPOINT_OF_OCTICONS_ZAP #  + $'\uE614 ' #  +) +register_icon "$prompt_icon[@]" + +# ⚡     +#register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' + +prompt_icon=( + "SUDO_ICON" + $'\uE0A2' #  + $'\uF09C' #  + $'\uF09C' #  + '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  + $'\uF09C' #  +) +register_icon "$prompt_icon[@]" + +#      +#register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' + +prompt_icon=( + "USER_ICON" + '' + '' + $'\uF2C0' #  + $'\uF2C0' #  + $'\uF2C0' #  +) +register_icon "$prompt_icon[@]" + +#    +#register_icon "SUDO_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' + ################################################################ # User: user (who am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print diff --git a/segments/core/vi_mode.p9k b/segments/core/vi_mode.p9k new file mode 100644 index 000000000..5cd5403da --- /dev/null +++ b/segments/core/vi_mode.p9k @@ -0,0 +1,32 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +################################################################ +# Vi Mode: show editing mode (NORMAL|INSERT) +set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" +set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" +prompt_vi_mode() { + case ${KEYMAP} in + vicmd) + "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + ;; + main|viins|*) + if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi + "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" + ;; + esac +} + +zle-keymap-select () { + zle reset-prompt + zle -R +} + +zle -N zle-keymap-select diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index d0851086e..3f282ab68 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "VPN_ICON" + '(vpn)' + '(vpn)' + $'\uF023' #  + '\u'$CODEPOINT_OF_AWESOME_LOCK + '(vpn)' +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# +#register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' + ################################################################ # Segment to display if VPN is active set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index cd95c47a8..49005d3a0 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "PYTHON_ICON" + '' + $'\ue63c' #  + $'\ue63c' #  + $'\U1F40D' # 🐍 + $'\UE73C ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#   🐍  +#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' + ################################################################ # Anaconda Environment prompt_anaconda() { diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index 807a37df1..d93ac3960 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "AWS_ICON" + 'AWS:' + $'\uE895' #  + $'\uF270' #  + '\u'$CODEPOINT_OF_AWESOME_SERVER #  + $'\uF270' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' + ################################################################ # AWS Profile prompt_aws() { diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index da66bbe2e..48553d3be 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "AWS_EB_ICON" + $'\U1F331 ' # 🌱 + $'\U1F331 ' # 🌱 + $'\U1F331 ' # 🌱 + $'\U1F331 ' # 🌱 + $'\UF1BD ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# 🌱 🌱 🌱 🌱  +#register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' + ################################################################ # Current Elastic Beanstalk environment prompt_aws_eb_env() { diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index c9cb442f7..61a9eaf15 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "RUBY_ICON" + '' + $'\uE847 ' #  + $'\uF219 ' #  + '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  + $'\uF219 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' + ################################################################ # Segment to display chruby information # see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH diff --git a/segments/developer/detect_virt.p9k b/segments/developer/detect_virt.p9k index 768509f67..eff69b6a6 100644 --- a/segments/developer/detect_virt.p9k +++ b/segments/developer/detect_virt.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Detection for virtualization (systemd based systems only) prompt_detect_virt() { diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index 112041870..e8b23514d 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SERVER_ICON" + '' + $'\uE895' #  + $'\uF233' #  + '\u'$CODEPOINT_OF_AWESOME_SERVER #  + $'\uF0AE' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' + ################################################################ # Docker machine prompt_docker_machine() { diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index b8024d7ba..ec504b3ad 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "GO_ICON" + 'Go' + '' + '' + '' + $'\uE626' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#  +#register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' + ################################################################ # GO prompt prompt_go_version() { diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index 4ff91a41a..a7ebedd2c 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "KUBERNETES_ICON" + $'\U2388' # ⎈ + $'\U2388' # ⎈ + $'\U2388' # ⎈ + $'\U2388' # ⎈ + $'\U2388' # ⎈ +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⎈ ⎈ ⎈ ⎈ ⎈ +#register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' + ################################################################ # Kubernetes Current Context/Namespace prompt_kubecontext() { diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index 7deb50e48..e885231f4 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "NODE_ICON" + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\uE617 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⬢ ⬢ ⬢ ⬢  +#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' + ################################################################ # Segment to display NodeEnv prompt_node_env() { diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index 64edee311..4761c71ab 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "NODE_ICON" + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\uE617 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⬢ ⬢ ⬢ ⬢  +#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' + ################################################################ # Segment to diplay Node version prompt_node_version() { diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index 14b047297..bbef5aab1 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "NODE_ICON" + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\u2B22' # ⬢ + $'\uE617 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ⬢ ⬢ ⬢ ⬢  +#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' + ################################################################ # Segment to display Node version from NVM # Only prints the segment if different than the default value diff --git a/segments/developer/php_version.p9k b/segments/developer/php_version.p9k index 88ba544b1..c46a5959d 100644 --- a/segments/developer/php_version.p9k +++ b/segments/developer/php_version.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Segment to display PHP version number prompt_php_version() { diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index 544b83ac4..abcee8828 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "PYTHON_ICON" + '' + $'\ue63c' #  + $'\ue63c' #  + $'\U1F40D' # 🐍 + $'\UE73C ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#   🐍  +#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' + ################################################################ # pyenv: current active python version (with restrictions) # https://github.com/pyenv/pyenv#choosing-the-python-version diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index cf8ce2c92..cb424993d 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "RUBY_ICON" + '' + $'\uE847 ' #  + $'\uF219 ' #  + '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  + $'\uF219 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' + ################################################################ # Segment to display rbenv information set_default POWERLEVEL9K_RBENV_ALWAYS false diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index 25c4ecbf2..4ea8b807c 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "TEST_ICON" + '' + $'\uE891' #  + $'\uF291' #  + '\u'$CODEPOINT_OF_AWESOME_BUG #  + $'\uF188' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' + ################################################################ # Segment to display RSpec test ratio prompt_rspec_stats() { diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index e5421bdd6..368670d2a 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "RUST_ICON" + '' + '' + $'\uE6A8' #  + $'\uE6A8' #  + $'\uE7A8 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#    +#register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' + ################################################################ # Segment to display Rust version number prompt_rust_version() { diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index 858b672c5..032aa3e48 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "RUBY_ICON" + '' + $'\uE847 ' #  + $'\uF219 ' #  + '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  + $'\uF219 ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' + ################################################################ # Segment to display Ruby Version Manager information prompt_rvm() { diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index 98707cd22..3cc214370 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SWIFT_ICON" + 'Swift' + '' + '' + $'\uE655' #  + $'\uE755' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#   +#register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' + ################################################################ # Segment to display Swift version prompt_swift_version() { diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index 6b93c47e6..3366e6d1a 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "TEST_ICON" + '' + $'\uE891' #  + $'\uF291' #  + '\u'$CODEPOINT_OF_AWESOME_BUG #  + $'\uF188' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' + ################################################################ # Symfony2-PHPUnit test ratio prompt_symfony2_tests() { diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index b7c0b2b27..d73ae2c65 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "SYMFONY_ICON" + 'SF' + 'SF' + 'SF' + 'SF' + $'\uE757' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#  +#register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' + ################################################################ # Segment to display Symfony2-Version prompt_symfony2_version() { diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index 3a64d26b2..07f2c73de 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -1,3 +1,241 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "VCS_UNTRACKED_ICON" + '?' + $'\uE16C' #  + $'\uF059' #  + '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  + $'\uF059' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' + +prompt_icon=( + "VCS_UNSTAGED_ICON" + $'\u25CF' # ● + $'\uE17C' #  + $'\uF06A' #  + '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  + $'\uF06A' #  +) +register_icon "$prompt_icon[@]" + +# ●     +#register_icon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' + +prompt_icon=( + "VCS_STAGED_ICON" + $'\u271A' # ✚ + $'\uE168' #  + $'\uF055' #  + '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  + $'\uF055' #  +) +register_icon "$prompt_icon[@]" + +# ✚     +#register_icon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' + +prompt_icon=( + "VCS_STASH_ICON" + $'\u235F' # ⍟ + $'\uE133 ' #  + $'\uF01C ' #  + '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  + $'\uF01C ' #  +) +register_icon "$prompt_icon[@]" + +# ⍟     +#register_icon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' + +prompt_icon=( + "VCS_INCOMING_CHANGES_ICON" + $'\u2193' # ↓ + $'\uE131 ' #  + $'\uF01A ' #  + '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  + $'\uF01A ' #  +) +register_icon "$prompt_icon[@]" + +# ↓     +#register_icon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' + +prompt_icon=( + "VCS_OUTGOING_CHANGES_ICON" + $'\u2191' # ↑ + $'\uE132 ' #  + $'\uF01B ' #  + '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  + $'\uF01B ' #  +) +register_icon "$prompt_icon[@]" + +# ↑     +#register_icon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' + +prompt_icon=( + "VCS_TAG_ICON" + '' + $'\uE817 ' #  + $'\uF217 ' #  + '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  + $'\uF02B ' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' + +prompt_icon=( + "VCS_BOOKMARK_ICON" + $'\u263F' # ☿ + $'\uE87B' #  + $'\uF27B' #  + '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  + $'\uF461 ' #  +) +register_icon "$prompt_icon[@]" + +# ☿     +#register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' + +prompt_icon=( + "VCS_COMMIT_ICON" + '' + $'\uE821 ' #  + $'\uF221 ' #  + '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  + $'\uE729 ' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' + +if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then + local branch_icon + [[ $POWERLEVEL9K_MODE == 'compatible' ]] && branch_icon="@" || branch_icon=$'\uE0A0 ' #  + prompt_icon=( + "VCS_BRANCH_ICON" + $branch_icon + $'\uE220 ' #  + $'\uF126 ' #  + '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  + $'\uF126 ' #  + ) + register_icon "$prompt_icon[@]" + + #      + #register_icon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' +fi + +prompt_icon=( + "VCS_REMOTE_BRANCH_ICON" + $'\u2192' # → + $'\u2192' # → + $'\u2192' # → + '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  + $'\uE728 ' #  +) +register_icon "$prompt_icon[@]" + +# → → →   +#register_icon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' + +prompt_icon=( + "VCS_GIT_ICON" + '' + $'\uE20E ' #  + $'\uF1D3 ' #  + '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  + $'\uF1D3 ' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' + +prompt_icon=( + "VCS_GIT_GITHUB_ICON" + '' + $'\uE20E ' # + $'\uF113 ' #  + '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  + $'\uF113 ' #  +) +register_icon "$prompt_icon[@]" + +#    +#register_icon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' + +prompt_icon=( + "VCS_GIT_BITBUCKET_ICON" + '' + $'\uE20E ' # + $'\uF171 ' #  + '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  + $'\uE703 ' #  +) +register_icon "$prompt_icon[@]" + +#    +#register_icon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' + +prompt_icon=( + "VCS_GIT_GITLAB_ICON" + '' + $'\uE20E ' # + $'\uF296 ' #  + '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  + $'\uF296 ' #  +) +register_icon "$prompt_icon[@]" + +#    +#register_icon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' + +prompt_icon=( + "VCS_HG_ICON" + '' + $'\uE1C3 ' #  + $'\uF0C3 ' #  + '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  + $'\uF0C3 ' #  +) +register_icon "$prompt_icon[@]" + +#     +#register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' + +prompt_icon=( + "VCS_SVN_ICON" + '' + '(svn) ' + '(svn) ' + '(svn) ' + $'\uE72D ' #  +) +register_icon "$prompt_icon[@]" + +#  +#register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' + +unset prompt_icon + + ################################################################ # VCS segment: shows the state of your repository, if you are in a folder under # version control @@ -90,3 +328,5 @@ prompt_vcs() { "$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi } + +powerlevel9k_vcs_init diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index d425d0bec..cc400834c 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "PYTHON_ICON" + '' + $'\ue63c' #  + $'\ue63c' #  + $'\U1F40D' # 🐍 + $'\UE73C ' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#   🐍  +#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' + ################################################################ # Virtualenv: current working virtualenv # More information on virtualenv (Python): diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index fbf0a1fb1..065dbca79 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "DROPBOX_ICON" + 'Dropbox' + $'\UF16B' #  + $'\UF16B' #  + '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  + $'\UF16B' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +#     +#register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' + ################################################################ # Dropbox status prompt_dropbox() { diff --git a/segments/other/icons_test.p9k b/segments/other/icons_test.p9k index fc3b47d49..6f04ad2ac 100644 --- a/segments/other/icons_test.p9k +++ b/segments/other/icons_test.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Test icons prompt_icons_test() { diff --git a/segments/other/openfoam.p9k b/segments/other/openfoam.p9k index db87faec7..deb8a68cc 100644 --- a/segments/other/openfoam.p9k +++ b/segments/other/openfoam.p9k @@ -1,3 +1,13 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + ################################################################ # Display openfoam information prompt_openfoam() { diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index b5d6172b3..08c1e0804 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -1,3 +1,27 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +local prompt_icon=( + "TODO_ICON" + $'\u2611' # ☑ + $'\u2611' # ☑ + $'\u2611' # ☑ + '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  + $'\uF133' #  +) +register_icon "$prompt_icon[@]" +unset prompt_icon + +# ☑ ☑ ☑   +#register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' + ################################################################ # todo.sh: shows the number of tasks in your todo.sh file prompt_todo() { From 626a17de60fb45e5f7c14202deb06959efd2620a Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 15:20:35 +0400 Subject: [PATCH 03/55] Updated test suite to source segments --- test/powerlevel9k.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 5f6b6f27f..65915fa52 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -10,6 +10,7 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* + source segments/**/* # Unset mode, so that user settings # do not interfere with tests From 16f0578379105ea61a1897a7d47548105d8bfabd Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 15:47:35 +0400 Subject: [PATCH 04/55] Update for Travis testing (remove local kw) --- segments/core/background_jobs.p9k | 2 +- segments/core/battery.p9k | 2 +- segments/core/command_execution_time.p9k | 2 +- segments/core/date.p9k | 2 +- segments/core/dir.p9k | 2 +- segments/core/dir_writable.p9k | 2 +- segments/core/disk_usage.p9k | 2 +- segments/core/history.p9k | 2 +- segments/core/host.p9k | 2 +- segments/core/ip.p9k | 2 +- segments/core/load.p9k | 2 +- segments/core/os_icon.p9k | 2 -- segments/core/public_ip.p9k | 2 +- segments/core/ram.p9k | 2 +- segments/core/root_indicator.p9k | 2 +- segments/core/ssh.p9k | 2 +- segments/core/status.p9k | 1 - segments/core/swap.p9k | 2 +- segments/core/time.p9k | 1 - segments/core/user.p9k | 2 +- segments/core/vpn_ip.p9k | 2 +- segments/developer/anaconda.p9k | 2 +- segments/developer/aws.p9k | 2 +- segments/developer/aws_eb_env.p9k | 2 +- segments/developer/chruby.p9k | 2 +- segments/developer/docker_machine.p9k | 2 +- segments/developer/go_version.p9k | 2 +- segments/developer/kubecontext.p9k | 2 +- segments/developer/node_env.p9k | 2 +- segments/developer/node_version.p9k | 2 +- segments/developer/nvm.p9k | 2 +- segments/developer/pyenv.p9k | 2 +- segments/developer/rbenv.p9k | 2 +- segments/developer/rspec_stats.p9k | 2 +- segments/developer/rust_version.p9k | 2 +- segments/developer/rvm.p9k | 2 +- segments/developer/swift_version.p9k | 2 +- segments/developer/symfony2_tests.p9k | 2 +- segments/developer/symfony2_version.p9k | 2 +- segments/developer/vcs.p9k | 2 +- segments/developer/virtualenv.p9k | 2 +- segments/other/dropbox.p9k | 2 +- segments/other/todo.p9k | 2 +- test/powerlevel9k.spec | 1 - 44 files changed, 40 insertions(+), 45 deletions(-) diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index c1e0f6a04..6f8891206 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "BACKGROUND_JOBS_ICON" $'\u2699' # ⚙ $'\uE82F ' #  diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index fe2b8686a..c5b3f095a 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "BATTERY_ICON" $'\U1F50B' # 🔋 $'\uE894' #  diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index a7eec3fa0..4edb3bc29 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' #  diff --git a/segments/core/date.p9k b/segments/core/date.p9k index 82164ec1b..d8d4bbb54 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "DATE_ICON" '' $'\uE184' #  diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index db9247797..5f069ac2b 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -15,7 +15,7 @@ # # # -local prompt_icon=( +prompt_icon=( "HOME_ICON" '' $'\uE12C' #  diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index d09bf153b..ca37bd1fa 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "LOCK_ICON" $'\UE0A2' $'\UE138' #  diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index 83895b09b..bb8a3baf2 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "DISK_ICON" $'hdd ' $'\uE1AE ' #  diff --git a/segments/core/history.p9k b/segments/core/history.p9k index 66ef7f3f8..baf0d3a9f 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "HISTORY_ICON" '' '' diff --git a/segments/core/host.p9k b/segments/core/host.p9k index beee6088d..2b3f05ce6 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SSH_ICON" '(ssh)' '(ssh)' diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index f189a4d65..ca41644c0 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "NETWORK_ICON" 'IP' $'\uE1AD' #  diff --git a/segments/core/load.p9k b/segments/core/load.p9k index 5a924fca5..d4e3053a5 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "LOAD_ICON" 'L' $'\uE190 ' #  diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index 08ea26c1f..19f693e20 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -8,8 +8,6 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon - # OS detection case "$OS" in "macOS") diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 6907e239f..656a3cdbf 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "PUBLIC_IP_ICON" '' '' diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index e9a97e413..cee56f7cd 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "RAM_ICON" 'RAM' $'\uE1E2 ' #  diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index f035926cd..10fa7fde5 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "ROOT_ICON" $'\u26A1' # ⚡ $'\uE801' #  diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index f71925a90..fd7dff1cd 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SSH_ICON" '(ssh)' '(ssh)' diff --git a/segments/core/status.p9k b/segments/core/status.p9k index f243fc31e..67ddf6282 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -8,7 +8,6 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon prompt_icon=( "CARRIAGE_RETURN_ICON" $'\u21B5' # ↵ diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index 7ffa9b980..40433add6 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SWAP_ICON" 'SWP' $'\uE87D' #  diff --git a/segments/core/time.p9k b/segments/core/time.p9k index 5abeef4aa..1e493973a 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -8,7 +8,6 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon prompt_icon=( "TIME_ICON" '' diff --git a/segments/core/user.p9k b/segments/core/user.p9k index 29dabdb57..38043ee43 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "ROOT_ICON" $'\u26A1' # ⚡ $'\uE801' #  diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index 3f282ab68..9baf580c4 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "VPN_ICON" '(vpn)' '(vpn)' diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index 49005d3a0..19efc2b67 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "PYTHON_ICON" '' $'\ue63c' #  diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index d93ac3960..bcf6e6a7a 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "AWS_ICON" 'AWS:' $'\uE895' #  diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index 48553d3be..f2b6cdb2b 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "AWS_EB_ICON" $'\U1F331 ' # 🌱 $'\U1F331 ' # 🌱 diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index 61a9eaf15..b2ad40b44 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "RUBY_ICON" '' $'\uE847 ' #  diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index e8b23514d..1726843d4 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SERVER_ICON" '' $'\uE895' #  diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index ec504b3ad..0e046fa85 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "GO_ICON" 'Go' '' diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index a7ebedd2c..882fc0e89 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "KUBERNETES_ICON" $'\U2388' # ⎈ $'\U2388' # ⎈ diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index e885231f4..01fb5018f 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "NODE_ICON" $'\u2B22' # ⬢ $'\u2B22' # ⬢ diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index 4761c71ab..53bd99942 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "NODE_ICON" $'\u2B22' # ⬢ $'\u2B22' # ⬢ diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index bbef5aab1..939355720 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "NODE_ICON" $'\u2B22' # ⬢ $'\u2B22' # ⬢ diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index abcee8828..979c4dda6 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "PYTHON_ICON" '' $'\ue63c' #  diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index cb424993d..43bc75352 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "RUBY_ICON" '' $'\uE847 ' #  diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index 4ea8b807c..3c09d2c41 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "TEST_ICON" '' $'\uE891' #  diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index 368670d2a..db07a16f9 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "RUST_ICON" '' '' diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index 032aa3e48..3ac73b525 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "RUBY_ICON" '' $'\uE847 ' #  diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index 3cc214370..bda934010 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SWIFT_ICON" 'Swift' '' diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index 3366e6d1a..eb841502c 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "TEST_ICON" '' $'\uE891' #  diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index d73ae2c65..1be6e30f2 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "SYMFONY_ICON" 'SF' 'SF' diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index 07f2c73de..a37acf60a 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "VCS_UNTRACKED_ICON" '?' $'\uE16C' #  diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index cc400834c..d8175d069 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "PYTHON_ICON" '' $'\ue63c' #  diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index 065dbca79..f938819f2 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "DROPBOX_ICON" 'Dropbox' $'\UF16B' #  diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index 08c1e0804..01035acbf 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -8,7 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -local prompt_icon=( +prompt_icon=( "TODO_ICON" $'\u2611' # ☑ $'\u2611' # ☑ diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 65915fa52..5f6b6f27f 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -10,7 +10,6 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* - source segments/**/* # Unset mode, so that user settings # do not interfere with tests From 3e25617969817a32f971995d5efb7350159e19f8 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:12:09 +0400 Subject: [PATCH 05/55] Update to register_icon --- segments/core/background_jobs.p9k | 22 +- segments/core/battery.p9k | 22 +- segments/core/command_execution_time.p9k | 22 +- segments/core/date.p9k | 22 +- segments/core/dir.p9k | 89 +++--- segments/core/dir_writable.p9k | 22 +- segments/core/disk_usage.p9k | 22 +- segments/core/history.p9k | 22 +- segments/core/host.p9k | 43 ++- segments/core/ip.p9k | 22 +- segments/core/load.p9k | 22 +- segments/core/os_icon.p9k | 382 +++++++++++------------ segments/core/public_ip.p9k | 42 +-- segments/core/ram.p9k | 22 +- segments/core/root_indicator.p9k | 22 +- segments/core/ssh.p9k | 22 +- segments/core/status.p9k | 63 ++-- segments/core/swap.p9k | 20 +- segments/core/time.p9k | 22 +- segments/core/user.p9k | 61 ++-- segments/core/vpn_ip.p9k | 22 +- segments/developer/anaconda.p9k | 22 +- segments/developer/aws.p9k | 22 +- segments/developer/aws_eb_env.p9k | 22 +- segments/developer/chruby.p9k | 22 +- segments/developer/docker_machine.p9k | 22 +- segments/developer/go_version.p9k | 22 +- segments/developer/kubecontext.p9k | 22 +- segments/developer/node_env.p9k | 24 +- segments/developer/node_version.p9k | 24 +- segments/developer/nvm.p9k | 24 +- segments/developer/pyenv.p9k | 22 +- segments/developer/rbenv.p9k | 22 +- segments/developer/rspec_stats.p9k | 22 +- segments/developer/rust_version.p9k | 22 +- segments/developer/rvm.p9k | 22 +- segments/developer/swift_version.p9k | 22 +- segments/developer/symfony2_tests.p9k | 22 +- segments/developer/symfony2_version.p9k | 22 +- segments/developer/vcs.p9k | 374 +++++++++++----------- segments/developer/virtualenv.p9k | 22 +- segments/other/dropbox.p9k | 22 +- segments/other/todo.p9k | 22 +- 43 files changed, 921 insertions(+), 929 deletions(-) diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index 6f8891206..88d5040ea 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "BACKGROUND_JOBS_ICON" - $'\u2699' # ⚙ - $'\uE82F ' #  - $'\uF013 ' #  - '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - $'\uF013 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "BACKGROUND_JOBS_ICON" +# $'\u2699' # ⚙ +# $'\uE82F ' #  +# $'\uF013 ' #  +# '\u'$CODEPOINT_OF_AWESOME_COG' ' #  +# $'\uF013 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # ⚙     -#register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' +register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' ################################################################ # Segment to indicate background jobs with an icon. diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index c5b3f095a..2d462d602 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "BATTERY_ICON" - $'\U1F50B' # 🔋 - $'\uE894' #  - $'\U1F50B' # 🔋 - '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  - $'\UF240 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "BATTERY_ICON" +# $'\U1F50B' # 🔋 +# $'\uE894' #  +# $'\U1F50B' # 🔋 +# '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  +# $'\UF240 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # 🔋  🔋   -#register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' +register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' ################################################################ # Segment that displays the battery status in levels and colors diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index 4edb3bc29..d3072197d 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "EXECUTION_TIME_ICON" - 'Dur' - $'\UE89C' #  - $'\uF253' - '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  - $'\uF252' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "EXECUTION_TIME_ICON" +# 'Dur' +# $'\UE89C' #  +# $'\uF253' +# '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  +# $'\uF252' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #    -#register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' +register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' ################################################################ # Display the duration the command needed to run. diff --git a/segments/core/date.p9k b/segments/core/date.p9k index d8d4bbb54..ad1c677c0 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "DATE_ICON" - '' - $'\uE184' #  - $'\uF073 ' #  - $'\uF073 ' #  - $'\uF073 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "DATE_ICON" +# '' +# $'\uE184' #  +# $'\uF073 ' #  +# $'\uF073 ' #  +# $'\uF073 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' +register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' ################################################################ # System date diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index 5f069ac2b..326fd8a7a 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -8,65 +8,58 @@ # https://gist.github.com/3712874 ################################################################ -# Icon array format: -# -# -# -# -# -# -prompt_icon=( - "HOME_ICON" - '' - $'\uE12C' #  - $'\uF015' #  - '\u'$CODEPOINT_OF_AWESOME_HOME #  - $'\uF015' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "HOME_ICON" +# '' +# $'\uE12C' #  +# $'\uF015' #  +# '\u'$CODEPOINT_OF_AWESOME_HOME #  +# $'\uF015' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' +register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' -prompt_icon=( - "HOME_SUB_ICON" - '' - $'\uE18D' #  - $'\uF07C' #  - '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  - $'\uF07C' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "HOME_SUB_ICON" +# '' +# $'\uE18D' #  +# $'\uF07C' #  +# '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  +# $'\uF07C' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' +register_icon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' -prompt_icon=( - "FOLDER_ICON" - '' - $'\uE818' #  - $'\uF115' #  - '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  - $'\uF115' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "FOLDER_ICON" +# '' +# $'\uE818' #  +# $'\uF115' #  +# '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  +# $'\uF115' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' +register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' -prompt_icon=( - "LOCK_ICON" - $'\UE0A2' - $'\UE138' #  - $'\UF023' #  - '\u'$CODEPOINT_OF_AWESOME_LOCK #  - $'\UF023' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "LOCK_ICON" +# $'\UE0A2' +# $'\UE138' #  +# $'\UF023' #  +# '\u'$CODEPOINT_OF_AWESOME_LOCK #  +# $'\UF023' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ################################################################ # Dir: current working directory diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index ca37bd1fa..ac7b1dabb 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "LOCK_ICON" - $'\UE0A2' - $'\UE138' #  - $'\UF023' #  - '\u'$CODEPOINT_OF_AWESOME_LOCK #  - $'\UF023' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "LOCK_ICON" +# $'\UE0A2' +# $'\UE138' #  +# $'\UF023' #  +# '\u'$CODEPOINT_OF_AWESOME_LOCK #  +# $'\UF023' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ############################################################### # dir_writable: Display information about the user's permission to write in the current directory diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index bb8a3baf2..fda9e80bc 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "DISK_ICON" - $'hdd ' - $'\uE1AE ' #  - $'\uF0A0 ' #  - '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  - $'\uF0A0' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "DISK_ICON" +# $'hdd ' +# $'\uE1AE ' #  +# $'\uF0A0 ' #  +# '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  +# $'\uF0A0' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' +register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' ################################################################ diff --git a/segments/core/history.p9k b/segments/core/history.p9k index baf0d3a9f..cabc22797 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "HISTORY_ICON" - '' - '' - $'\uE29A' #  - $'\uE29A' #  - $'\uE29A' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "HISTORY_ICON" +# '' +# '' +# $'\uE29A' #  +# $'\uE29A' #  +# $'\uE29A' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #    -#register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' +register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' ################################################################ # Command number (in local history) diff --git a/segments/core/host.p9k b/segments/core/host.p9k index 2b3f05ce6..c791e10ab 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -8,33 +8,32 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SSH_ICON" - '(ssh)' - '(ssh)' - '(ssh)' - '(ssh)' - $'\uF489' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "SSH_ICON" +# '(ssh)' +# '(ssh)' +# '(ssh)' +# '(ssh)' +# $'\uF489' #  +# ) +# register_icon "$prompt_icon[@]" #  -#register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' +register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' -prompt_icon=( - "HOST_ICON" - '' - '' - $'\uF67C' #  - $'\uF67C' #  - $'\uF67C' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "HOST_ICON" +# '' +# '' +# $'\uF67C' #  +# $'\uF67C' #  +# $'\uF67C' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #    -#register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' - +register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' ################################################################ # Host: machine (where am I) diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index ca41644c0..ac4284aaa 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "NETWORK_ICON" - 'IP' - $'\uE1AD' #  - $'\uF09E' #  - '\u'$CODEPOINT_OF_AWESOME_RSS #  - $'\uF1EB' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "NETWORK_ICON" +# 'IP' +# $'\uE1AD' #  +# $'\uF09E' #  +# '\u'$CODEPOINT_OF_AWESOME_RSS #  +# $'\uF1EB' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' +register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' ################################################################ # Segment to display the current IP address diff --git a/segments/core/load.p9k b/segments/core/load.p9k index d4e3053a5..552d03d90 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "LOAD_ICON" - 'L' - $'\uE190 ' #  - $'\uF080 ' #  - '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  - $'\uF080 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "LOAD_ICON" +# 'L' +# $'\uE190 ' #  +# $'\uF080 ' #  +# '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  +# $'\uF080 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' +register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' ################################################################ # Segment to display load diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index 19f693e20..ad8fc833e 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -11,50 +11,50 @@ # OS detection case "$OS" in "macOS") - prompt_icon=( - "APPLE_ICON" - 'macOS' - $'\uE26E' #  - $'\uF179' #  - '\u'$CODEPOINT_OF_AWESOME_APPLE #  - $'\uF179' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "APPLE_ICON" + # 'macOS' + # $'\uE26E' #  + # $'\uF179' #  + # '\u'$CODEPOINT_OF_AWESOME_APPLE #  + # $'\uF179' #  + # ) + # register_icon "$prompt_icon[@]" #     - #register_icon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' + register_icon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' OS_ICON='APPLE_ICON' ;; "Windows") - prompt_icon=( - "WINDOWS_ICON" - 'WIN' - $'\uE26F' #  - $'\uF17A' #  - $'\uF17A' #  - $'\uF17A' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "WINDOWS_ICON" + # 'WIN' + # $'\uE26F' #  + # $'\uF17A' #  + # $'\uF17A' #  + # $'\uF17A' #  + # ) + # register_icon "$prompt_icon[@]" #     - #register_icon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' + register_icon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' OS_ICON='WINDOWS_ICON' ;; "BSD") - prompt_icon=( - "FREEBSD_ICON" - 'BSD' - $'\U1F608 ' # 😈 - $'\U1F608 ' # 😈 - $'\U1F608 ' # 😈 - $'\UF30E ' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "FREEBSD_ICON" + # 'BSD' + # $'\U1F608 ' # 😈 + # $'\U1F608 ' # 😈 + # $'\U1F608 ' # 😈 + # $'\UF30E ' #  + # ) + # register_icon "$prompt_icon[@]" # 😈 😈 😈  - #register_icon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' + register_icon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' OS_ICON='FREEBSD_ICON' ;; @@ -67,260 +67,260 @@ case "$OS" in "Linux") case "$OS_ID" in "arch") - prompt_icon=( - "LINUX_ARCH_ICON" - 'Arc' - 'Arc' - 'Arc' - 'Arc' - $'\uF300' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_ARCH_ICON" + # 'Arc' + # 'Arc' + # 'Arc' + # 'Arc' + # $'\uF300' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' + register_icon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' OS_ICON='LINUX_ARCH_ICON' ;; "debian") - prompt_icon=( - "LINUX_DEBIAN_ICON" - 'Deb' - 'Deb' - 'Deb' - 'Deb' - $'\uF302' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_DEBIAN_ICON" + # 'Deb' + # 'Deb' + # 'Deb' + # 'Deb' + # $'\uF302' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' + register_icon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' OS_ICON='LINUX_DEBIAN_ICON' ;; "ubuntu") - prompt_icon=( - "LINUX_UBUNTU_ICON" - 'Ubu' - 'Ubu' - 'Ubu' - 'Ubu' - $'\uF30C' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_UBUNTU_ICON" + # 'Ubu' + # 'Ubu' + # 'Ubu' + # 'Ubu' + # $'\uF30C' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' + register_icon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' OS_ICON='LINUX_UBUNTU_ICON' ;; "elementary") - prompt_icon=( - "LINUX_ELEMENTARY_ICON" - 'Elm' - 'Elm' - 'Elm' - 'Elm' - $'\uF311' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_ELEMENTARY_ICON" + # 'Elm' + # 'Elm' + # 'Elm' + # 'Elm' + # $'\uF311' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' + register_icon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' OS_ICON='LINUX_ELEMENTARY_ICON' ;; "fedora") - prompt_icon=( - "LINUX_FEDORA_ICON" - 'Fed' - 'Fed' - 'Fed' - 'Fed' - $'\uF303' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_FEDORA_ICON" + # 'Fed' + # 'Fed' + # 'Fed' + # 'Fed' + # $'\uF303' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' + register_icon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' OS_ICON='LINUX_FEDORA_ICON' ;; "coreos") - prompt_icon=( - "LINUX_COREOS_ICON" - 'Cor' - 'Cor' - 'Cor' - 'Cor' - $'\uF30F' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_COREOS_ICON" + # 'Cor' + # 'Cor' + # 'Cor' + # 'Cor' + # $'\uF30F' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' + register_icon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' OS_ICON='LINUX_COREOS_ICON' ;; "gentoo") - prompt_icon=( - "LINUX_GENTOO_ICON" - 'Gen' - 'Gen' - 'Gen' - 'Gen' - $'\uF310' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_GENTOO_ICON" + # 'Gen' + # 'Gen' + # 'Gen' + # 'Gen' + # $'\uF310' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' + register_icon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' OS_ICON='LINUX_GENTOO_ICON' ;; "mageia") - prompt_icon=( - "LINUX_MAGEIA_ICON" - 'Mag' - 'Mag' - 'Mag' - 'Mag' - $'\uF306' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_MAGEIA_ICON" + # 'Mag' + # 'Mag' + # 'Mag' + # 'Mag' + # $'\uF306' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' + register_icon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' OS_ICON='LINUX_MAGEIA_ICON' ;; "centos") - prompt_icon=( - "LINUX_CENTOS_ICON" - 'Cen' - 'Cen' - 'Cen' - 'Cen' - $'\uF301' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_CENTOS_ICON" + # 'Cen' + # 'Cen' + # 'Cen' + # 'Cen' + # $'\uF301' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' + register_icon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' OS_ICON='LINUX_CENTOS_ICON' ;; "opensuse"|"tumbleweed") - prompt_icon=( - "LINUX_OPENSUSE_ICON" - 'OSu' - 'OSu' - 'OSu' - 'OSu' - $'\uF308' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_OPENSUSE_ICON" + # 'OSu' + # 'OSu' + # 'OSu' + # 'OSu' + # $'\uF308' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' + register_icon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' OS_ICON='LINUX_OPENSUSE_ICON' ;; "sabayon") - prompt_icon=( - "LINUX_SABAYON_ICON" - 'Sab' - 'Sab' - 'Sab' - 'Sab' - $'\uF313' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_SABAYON_ICON" + # 'Sab' + # 'Sab' + # 'Sab' + # 'Sab' + # $'\uF313' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' + register_icon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' OS_ICON='LINUX_SABAYON_ICON' ;; "slackware") - prompt_icon=( - "LINUX_SLACKWARE_ICON" - 'Sla' - 'Sla' - 'Sla' - 'Sla' - $'\uF30A' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_SLACKWARE_ICON" + # 'Sla' + # 'Sla' + # 'Sla' + # 'Sla' + # $'\uF30A' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' + register_icon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' OS_ICON='LINUX_SLACKWARE_ICON' ;; "linuxmint") - prompt_icon=( - "LINUX_MINT_ICON" - 'LMi' - 'LMi' - 'LMi' - 'LMi' - $'\uF304' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_MINT_ICON" + # 'LMi' + # 'LMi' + # 'LMi' + # 'LMi' + # $'\uF304' #  + # ) + # register_icon "$prompt_icon[@]" #  - #register_icon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' + register_icon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' OS_ICON='LINUX_MINT_ICON' ;; *) - prompt_icon=( - "LINUX_ICON" - 'Lx' - $'\uE271' #  - $'\uF17C' #  - '\u'$CODEPOINT_OF_AWESOME_LINUX #  - $'\uF17C' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "LINUX_ICON" + # 'Lx' + # $'\uE271' #  + # $'\uF17C' #  + # '\u'$CODEPOINT_OF_AWESOME_LINUX #  + # $'\uF17C' #  + # ) + # register_icon "$prompt_icon[@]" #     - #register_icon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' + register_icon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' OS_ICON='LINUX_ICON' ;; esac ;; "Android") - prompt_icon=( - "ANDROID_ICON" - 'And' - $'\uE270' #  - $'\uE17B' #  - $'\uF17B' #  - $'\uF17B' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "ANDROID_ICON" + # 'And' + # $'\uE270' #  + # $'\uE17B' #  + # $'\uF17B' #  + # $'\uF17B' #  + # ) + # register_icon "$prompt_icon[@]" #     - #register_icon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' + register_icon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' OS_ICON='ANDROID_ICON' ;; "Solaris") - prompt_icon=( - "SUNOS_ICON" - 'Sun' - $'\U1F31E ' # 🌞 - $'\uF185 ' #  - '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  - $'\uF185 ' #  - ) - register_icon "$prompt_icon[@]" + # prompt_icon=( + # "SUNOS_ICON" + # 'Sun' + # $'\U1F31E ' # 🌞 + # $'\uF185 ' #  + # '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  + # $'\uF185 ' #  + # ) + # register_icon "$prompt_icon[@]" # 🌞    - #register_icon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' + register_icon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' OS_ICON='SUNOS_ICON' ;; @@ -330,7 +330,7 @@ case "$OS" in ;; esac -unset prompt_icon +# unset prompt_icon ################################################################ # Segment to print a little OS icon diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 656a3cdbf..12788933e 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -8,32 +8,32 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "PUBLIC_IP_ICON" - '' - '' - '' - '\u'$CODEPOINT_OF_AWESOME_GLOBE #  - $'\UF0AC' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "PUBLIC_IP_ICON" +# '' +# '' +# '' +# '\u'$CODEPOINT_OF_AWESOME_GLOBE #  +# $'\UF0AC' #  +# ) +# register_icon "$prompt_icon[@]" #   -#register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' +register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' -prompt_icon=( - "VPN_ICON" - '(vpn)' - '(vpn)' - $'\uF023' #  - '\u'$CODEPOINT_OF_AWESOME_LOCK - '(vpn)' -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "VPN_ICON" +# '(vpn)' +# '(vpn)' +# $'\uF023' #  +# '\u'$CODEPOINT_OF_AWESOME_LOCK +# '(vpn)' +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # -#register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' +register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' ################################################################ # Public IP segment diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index cee56f7cd..c18cfa4e6 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "RAM_ICON" - 'RAM' - $'\uE1E2 ' #  - $'\uF0E4' #  - '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - $'\uF0E4' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "RAM_ICON" +# 'RAM' +# $'\uE1E2 ' #  +# $'\uF0E4' #  +# '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  +# $'\uF0E4' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' +register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' ################################################################ # Segment to display free RAM and used Swap diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index 10fa7fde5..a705de971 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "ROOT_ICON" - $'\u26A1' # ⚡ - $'\uE801' #  - $'\uF201' #  - '\u'$CODEPOINT_OF_OCTICONS_ZAP #  - $'\uE614 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "ROOT_ICON" +# $'\u26A1' # ⚡ +# $'\uE801' #  +# $'\uF201' #  +# '\u'$CODEPOINT_OF_OCTICONS_ZAP #  +# $'\uE614 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # ⚡     -#register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' +register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' ################################################################ # Segment to print an icon if user is root. diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index fd7dff1cd..3425c133a 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SSH_ICON" - '(ssh)' - '(ssh)' - '(ssh)' - '(ssh)' - $'\uF489' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "SSH_ICON" +# '(ssh)' +# '(ssh)' +# '(ssh)' +# '(ssh)' +# $'\uF489' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #  -#register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' +register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' ################################################################ # Segment to display SSH icon when connected diff --git a/segments/core/status.p9k b/segments/core/status.p9k index 67ddf6282..873894a00 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -8,46 +8,45 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "CARRIAGE_RETURN_ICON" - $'\u21B5' # ↵ - $'\u21B5' # ↵ - $'\u21B5' # ↵ - $'\u21B5' # ↵ - $'\u21B5' # ↵ -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "CARRIAGE_RETURN_ICON" +# $'\u21B5' # ↵ +# $'\u21B5' # ↵ +# $'\u21B5' # ↵ +# $'\u21B5' # ↵ +# $'\u21B5' # ↵ +# ) +# register_icon "$prompt_icon[@]" # ↵ ↵ ↵ ↵ ↵ -#register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' +register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' -prompt_icon=( - "OK_ICON" - $'\u2714' # ✔ - $'\u2714' # ✔ - $'\u2714' # ✔ - '\u'$CODEPOINT_OF_AWESOME_CHECK #  - $'\uF00C' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "OK_ICON" +# $'\u2714' # ✔ +# $'\u2714' # ✔ +# $'\u2714' # ✔ +# '\u'$CODEPOINT_OF_AWESOME_CHECK #  +# $'\uF00C' #  +# ) +# register_icon "$prompt_icon[@]" # ✔ ✔ ✔   -#register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' +register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' -prompt_icon=( - "FAIL_ICON" - $'\u2718' # ✘ - $'\u2718' # ✘ - $'\u2718' # ✘ - '\u'$CODEPOINT_OF_AWESOME_TIMES #  - $'\uF00D' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "FAIL_ICON" +# $'\u2718' # ✘ +# $'\u2718' # ✘ +# $'\u2718' # ✘ +# '\u'$CODEPOINT_OF_AWESOME_TIMES #  +# $'\uF00D' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # ✘ ✘ ✘   -#register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' - -unset prompt_icon +register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' ################################################################ # Status: When an error occur, return the error code, or a cross icon if option is set diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index 40433add6..b0d2198e5 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -8,16 +8,16 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SWAP_ICON" - 'SWP' - $'\uE87D' #  - $'\uF0E4' #  - '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - $'\uF464' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "SWAP_ICON" +# 'SWP' +# $'\uE87D' #  +# $'\uF0E4' #  +# '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  +# $'\uF464' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     register_icon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' diff --git a/segments/core/time.p9k b/segments/core/time.p9k index 1e493973a..1ad56f810 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "TIME_ICON" - '' - $'\uE12E' #  - $'\uF017 ' #  - $'\uF017 ' #  - $'\uF017 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "TIME_ICON" +# '' +# $'\uE12E' #  +# $'\uF017 ' #  +# $'\uF017 ' #  +# $'\uF017 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' +register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' ################################################################ # System time diff --git a/segments/core/user.p9k b/segments/core/user.p9k index 38043ee43..4fc40f0a0 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -8,44 +8,45 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "ROOT_ICON" - $'\u26A1' # ⚡ - $'\uE801' #  - $'\uF201' #  - '\u'$CODEPOINT_OF_OCTICONS_ZAP #  - $'\uE614 ' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "ROOT_ICON" +# $'\u26A1' # ⚡ +# $'\uE801' #  +# $'\uF201' #  +# '\u'$CODEPOINT_OF_OCTICONS_ZAP #  +# $'\uE614 ' #  +# ) +# register_icon "$prompt_icon[@]" # ⚡     -#register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' +register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' -prompt_icon=( - "SUDO_ICON" - $'\uE0A2' #  - $'\uF09C' #  - $'\uF09C' #  - '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  - $'\uF09C' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "SUDO_ICON" +# $'\uE0A2' #  +# $'\uF09C' #  +# $'\uF09C' #  +# '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  +# $'\uF09C' #  +# ) +# register_icon "$prompt_icon[@]" #      -#register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' +register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' -prompt_icon=( - "USER_ICON" - '' - '' - $'\uF2C0' #  - $'\uF2C0' #  - $'\uF2C0' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "USER_ICON" +# '' +# '' +# $'\uF2C0' #  +# $'\uF2C0' #  +# $'\uF2C0' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #    -#register_icon "SUDO_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' +register_icon "SUDO_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' ################################################################ # User: user (who am I) diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index 9baf580c4..816bc2dc8 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "VPN_ICON" - '(vpn)' - '(vpn)' - $'\uF023' #  - '\u'$CODEPOINT_OF_AWESOME_LOCK - '(vpn)' -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "VPN_ICON" +# '(vpn)' +# '(vpn)' +# $'\uF023' #  +# '\u'$CODEPOINT_OF_AWESOME_LOCK +# '(vpn)' +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # -#register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' +register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' ################################################################ # Segment to display if VPN is active diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index 19efc2b67..0a66236ee 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "PYTHON_ICON" - '' - $'\ue63c' #  - $'\ue63c' #  - $'\U1F40D' # 🐍 - $'\UE73C ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "PYTHON_ICON" +# '' +# $'\ue63c' #  +# $'\ue63c' #  +# $'\U1F40D' # 🐍 +# $'\UE73C ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #   🐍  -#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # Anaconda Environment diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index bcf6e6a7a..9cae0197e 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "AWS_ICON" - 'AWS:' - $'\uE895' #  - $'\uF270' #  - '\u'$CODEPOINT_OF_AWESOME_SERVER #  - $'\uF270' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "AWS_ICON" +# 'AWS:' +# $'\uE895' #  +# $'\uF270' #  +# '\u'$CODEPOINT_OF_AWESOME_SERVER #  +# $'\uF270' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' +register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' ################################################################ # AWS Profile diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index f2b6cdb2b..f147416bf 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "AWS_EB_ICON" - $'\U1F331 ' # 🌱 - $'\U1F331 ' # 🌱 - $'\U1F331 ' # 🌱 - $'\U1F331 ' # 🌱 - $'\UF1BD ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "AWS_EB_ICON" +# $'\U1F331 ' # 🌱 +# $'\U1F331 ' # 🌱 +# $'\U1F331 ' # 🌱 +# $'\U1F331 ' # 🌱 +# $'\UF1BD ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # 🌱 🌱 🌱 🌱  -#register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' +register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' ################################################################ # Current Elastic Beanstalk environment diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index b2ad40b44..d58969377 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "RUBY_ICON" - '' - $'\uE847 ' #  - $'\uF219 ' #  - '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - $'\uF219 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "RUBY_ICON" +# '' +# $'\uE847 ' #  +# $'\uF219 ' #  +# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  +# $'\uF219 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ # Segment to display chruby information diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index 1726843d4..9c8b2dec9 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SERVER_ICON" - '' - $'\uE895' #  - $'\uF233' #  - '\u'$CODEPOINT_OF_AWESOME_SERVER #  - $'\uF0AE' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "SERVER_ICON" +# '' +# $'\uE895' #  +# $'\uF233' #  +# '\u'$CODEPOINT_OF_AWESOME_SERVER #  +# $'\uF0AE' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' +register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' ################################################################ # Docker machine diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index 0e046fa85..1c4848e20 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "GO_ICON" - 'Go' - '' - '' - '' - $'\uE626' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "GO_ICON" +# 'Go' +# '' +# '' +# '' +# $'\uE626' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #  -#register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' +register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' ################################################################ # GO prompt diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index 882fc0e89..9b9cc98bb 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "KUBERNETES_ICON" - $'\U2388' # ⎈ - $'\U2388' # ⎈ - $'\U2388' # ⎈ - $'\U2388' # ⎈ - $'\U2388' # ⎈ -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "KUBERNETES_ICON" +# $'\U2388' # ⎈ +# $'\U2388' # ⎈ +# $'\U2388' # ⎈ +# $'\U2388' # ⎈ +# $'\U2388' # ⎈ +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # ⎈ ⎈ ⎈ ⎈ ⎈ -#register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' +register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' ################################################################ # Kubernetes Current Context/Namespace diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index 01fb5018f..8351664b5 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "NODE_ICON" - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\uE617 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "NODE_ICON" +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\uE617 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon -# ⬢ ⬢ ⬢ ⬢  -#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +# ⬢ ⬢ ⬢ ⬢  +register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # Segment to display NodeEnv diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index 53bd99942..da10e84f9 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "NODE_ICON" - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\uE617 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "NODE_ICON" +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\uE617 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon -# ⬢ ⬢ ⬢ ⬢  -#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +# ⬢ ⬢ ⬢ ⬢  +register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # Segment to diplay Node version diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index 939355720..8f9afd661 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "NODE_ICON" - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\u2B22' # ⬢ - $'\uE617 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "NODE_ICON" +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\u2B22' # ⬢ +# $'\uE617 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon -# ⬢ ⬢ ⬢ ⬢  -#register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +# ⬢ ⬢ ⬢ ⬢  +register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # Segment to display Node version from NVM diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index 979c4dda6..8012e17b5 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "PYTHON_ICON" - '' - $'\ue63c' #  - $'\ue63c' #  - $'\U1F40D' # 🐍 - $'\UE73C ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "PYTHON_ICON" +# '' +# $'\ue63c' #  +# $'\ue63c' #  +# $'\U1F40D' # 🐍 +# $'\UE73C ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #   🐍  -#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # pyenv: current active python version (with restrictions) diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index 43bc75352..951683766 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "RUBY_ICON" - '' - $'\uE847 ' #  - $'\uF219 ' #  - '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - $'\uF219 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "RUBY_ICON" +# '' +# $'\uE847 ' #  +# $'\uF219 ' #  +# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  +# $'\uF219 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ # Segment to display rbenv information diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index 3c09d2c41..60686cee2 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "TEST_ICON" - '' - $'\uE891' #  - $'\uF291' #  - '\u'$CODEPOINT_OF_AWESOME_BUG #  - $'\uF188' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "TEST_ICON" +# '' +# $'\uE891' #  +# $'\uF291' #  +# '\u'$CODEPOINT_OF_AWESOME_BUG #  +# $'\uF188' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' ################################################################ # Segment to display RSpec test ratio diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index db07a16f9..8e146995d 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "RUST_ICON" - '' - '' - $'\uE6A8' #  - $'\uE6A8' #  - $'\uE7A8 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "RUST_ICON" +# '' +# '' +# $'\uE6A8' #  +# $'\uE6A8' #  +# $'\uE7A8 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #    -#register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' +register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' ################################################################ # Segment to display Rust version number diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index 3ac73b525..8aa4ccf65 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "RUBY_ICON" - '' - $'\uE847 ' #  - $'\uF219 ' #  - '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - $'\uF219 ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "RUBY_ICON" +# '' +# $'\uE847 ' #  +# $'\uF219 ' #  +# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  +# $'\uF219 ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ # Segment to display Ruby Version Manager information diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index bda934010..4794e25c4 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SWIFT_ICON" - 'Swift' - '' - '' - $'\uE655' #  - $'\uE755' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "SWIFT_ICON" +# 'Swift' +# '' +# '' +# $'\uE655' #  +# $'\uE755' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #   -#register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' +register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' ################################################################ # Segment to display Swift version diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index eb841502c..9dc7a0ae3 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "TEST_ICON" - '' - $'\uE891' #  - $'\uF291' #  - '\u'$CODEPOINT_OF_AWESOME_BUG #  - $'\uF188' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "TEST_ICON" +# '' +# $'\uE891' #  +# $'\uF291' #  +# '\u'$CODEPOINT_OF_AWESOME_BUG #  +# $'\uF188' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' ################################################################ # Symfony2-PHPUnit test ratio diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index 1be6e30f2..85191275b 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "SYMFONY_ICON" - 'SF' - 'SF' - 'SF' - 'SF' - $'\uE757' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "SYMFONY_ICON" +# 'SF' +# 'SF' +# 'SF' +# 'SF' +# $'\uE757' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #  -#register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' +register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' ################################################################ # Segment to display Symfony2-Version diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index a37acf60a..d024a9cdc 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -8,232 +8,232 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "VCS_UNTRACKED_ICON" - '?' - $'\uE16C' #  - $'\uF059' #  - '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  - $'\uF059' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "VCS_UNTRACKED_ICON" +# '?' +# $'\uE16C' #  +# $'\uF059' #  +# '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  +# $'\uF059' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' - -prompt_icon=( - "VCS_UNSTAGED_ICON" - $'\u25CF' # ● - $'\uE17C' #  - $'\uF06A' #  - '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  - $'\uF06A' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' + +# prompt_icon=( +# "VCS_UNSTAGED_ICON" +# $'\u25CF' # ● +# $'\uE17C' #  +# $'\uF06A' #  +# '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  +# $'\uF06A' #  +# ) +# register_icon "$prompt_icon[@]" # ●     -#register_icon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' - -prompt_icon=( - "VCS_STAGED_ICON" - $'\u271A' # ✚ - $'\uE168' #  - $'\uF055' #  - '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  - $'\uF055' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' + +# prompt_icon=( +# "VCS_STAGED_ICON" +# $'\u271A' # ✚ +# $'\uE168' #  +# $'\uF055' #  +# '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  +# $'\uF055' #  +# ) +# register_icon "$prompt_icon[@]" # ✚     -#register_icon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' - -prompt_icon=( - "VCS_STASH_ICON" - $'\u235F' # ⍟ - $'\uE133 ' #  - $'\uF01C ' #  - '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  - $'\uF01C ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' + +# prompt_icon=( +# "VCS_STASH_ICON" +# $'\u235F' # ⍟ +# $'\uE133 ' #  +# $'\uF01C ' #  +# '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  +# $'\uF01C ' #  +# ) +# register_icon "$prompt_icon[@]" # ⍟     -#register_icon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' - -prompt_icon=( - "VCS_INCOMING_CHANGES_ICON" - $'\u2193' # ↓ - $'\uE131 ' #  - $'\uF01A ' #  - '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  - $'\uF01A ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' + +# prompt_icon=( +# "VCS_INCOMING_CHANGES_ICON" +# $'\u2193' # ↓ +# $'\uE131 ' #  +# $'\uF01A ' #  +# '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  +# $'\uF01A ' #  +# ) +# register_icon "$prompt_icon[@]" # ↓     -#register_icon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' - -prompt_icon=( - "VCS_OUTGOING_CHANGES_ICON" - $'\u2191' # ↑ - $'\uE132 ' #  - $'\uF01B ' #  - '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  - $'\uF01B ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' + +# prompt_icon=( +# "VCS_OUTGOING_CHANGES_ICON" +# $'\u2191' # ↑ +# $'\uE132 ' #  +# $'\uF01B ' #  +# '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  +# $'\uF01B ' #  +# ) +# register_icon "$prompt_icon[@]" # ↑     -#register_icon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' - -prompt_icon=( - "VCS_TAG_ICON" - '' - $'\uE817 ' #  - $'\uF217 ' #  - '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  - $'\uF02B ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' + +# prompt_icon=( +# "VCS_TAG_ICON" +# '' +# $'\uE817 ' #  +# $'\uF217 ' #  +# '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  +# $'\uF02B ' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' - -prompt_icon=( - "VCS_BOOKMARK_ICON" - $'\u263F' # ☿ - $'\uE87B' #  - $'\uF27B' #  - '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  - $'\uF461 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' + +# prompt_icon=( +# "VCS_BOOKMARK_ICON" +# $'\u263F' # ☿ +# $'\uE87B' #  +# $'\uF27B' #  +# '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  +# $'\uF461 ' #  +# ) +# register_icon "$prompt_icon[@]" # ☿     -#register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' - -prompt_icon=( - "VCS_COMMIT_ICON" - '' - $'\uE821 ' #  - $'\uF221 ' #  - '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  - $'\uE729 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' + +# prompt_icon=( +# "VCS_COMMIT_ICON" +# '' +# $'\uE821 ' #  +# $'\uF221 ' #  +# '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  +# $'\uE729 ' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' +register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then local branch_icon [[ $POWERLEVEL9K_MODE == 'compatible' ]] && branch_icon="@" || branch_icon=$'\uE0A0 ' #  - prompt_icon=( - "VCS_BRANCH_ICON" - $branch_icon - $'\uE220 ' #  - $'\uF126 ' #  - '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - $'\uF126 ' #  - ) - register_icon "$prompt_icon[@]" - - #      - #register_icon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + # prompt_icon=( + # "VCS_BRANCH_ICON" + # $branch_icon + # $'\uE220 ' #  + # $'\uF126 ' #  + # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  + # $'\uF126 ' #  + # ) + # register_icon "$prompt_icon[@]" + + #     + register_icon "VCS_BRANCH_ICON" $branch_icon $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' fi -prompt_icon=( - "VCS_REMOTE_BRANCH_ICON" - $'\u2192' # → - $'\u2192' # → - $'\u2192' # → - '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  - $'\uE728 ' #  -) -register_icon "$prompt_icon[@]" +# prompt_icon=( +# "VCS_REMOTE_BRANCH_ICON" +# $'\u2192' # → +# $'\u2192' # → +# $'\u2192' # → +# '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  +# $'\uE728 ' #  +# ) +# register_icon "$prompt_icon[@]" # → → →   -#register_icon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' - -prompt_icon=( - "VCS_GIT_ICON" - '' - $'\uE20E ' #  - $'\uF1D3 ' #  - '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  - $'\uF1D3 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' + +# prompt_icon=( +# "VCS_GIT_ICON" +# '' +# $'\uE20E ' #  +# $'\uF1D3 ' #  +# '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  +# $'\uF1D3 ' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' - -prompt_icon=( - "VCS_GIT_GITHUB_ICON" - '' - $'\uE20E ' # - $'\uF113 ' #  - '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  - $'\uF113 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' + +# prompt_icon=( +# "VCS_GIT_GITHUB_ICON" +# '' +# $'\uE20E ' # +# $'\uF113 ' #  +# '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  +# $'\uF113 ' #  +# ) +# register_icon "$prompt_icon[@]" #    -#register_icon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' - -prompt_icon=( - "VCS_GIT_BITBUCKET_ICON" - '' - $'\uE20E ' # - $'\uF171 ' #  - '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  - $'\uE703 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' + +# prompt_icon=( +# "VCS_GIT_BITBUCKET_ICON" +# '' +# $'\uE20E ' # +# $'\uF171 ' #  +# '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  +# $'\uE703 ' #  +# ) +# register_icon "$prompt_icon[@]" #    -#register_icon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' - -prompt_icon=( - "VCS_GIT_GITLAB_ICON" - '' - $'\uE20E ' # - $'\uF296 ' #  - '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  - $'\uF296 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' + +# prompt_icon=( +# "VCS_GIT_GITLAB_ICON" +# '' +# $'\uE20E ' # +# $'\uF296 ' #  +# '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  +# $'\uF296 ' #  +# ) +# register_icon "$prompt_icon[@]" #    -#register_icon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' - -prompt_icon=( - "VCS_HG_ICON" - '' - $'\uE1C3 ' #  - $'\uF0C3 ' #  - '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  - $'\uF0C3 ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' + +# prompt_icon=( +# "VCS_HG_ICON" +# '' +# $'\uE1C3 ' #  +# $'\uF0C3 ' #  +# '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  +# $'\uF0C3 ' #  +# ) +# register_icon "$prompt_icon[@]" #     -#register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' - -prompt_icon=( - "VCS_SVN_ICON" - '' - '(svn) ' - '(svn) ' - '(svn) ' - $'\uE72D ' #  -) -register_icon "$prompt_icon[@]" +register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' + +# prompt_icon=( +# "VCS_SVN_ICON" +# '' +# '(svn) ' +# '(svn) ' +# '(svn) ' +# $'\uE72D ' #  +# ) +# register_icon "$prompt_icon[@]" #  -#register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' +register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' -unset prompt_icon +# unset prompt_icon ################################################################ diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index d8175d069..0bfb3056f 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "PYTHON_ICON" - '' - $'\ue63c' #  - $'\ue63c' #  - $'\U1F40D' # 🐍 - $'\UE73C ' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "PYTHON_ICON" +# '' +# $'\ue63c' #  +# $'\ue63c' #  +# $'\U1F40D' # 🐍 +# $'\UE73C ' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #   🐍  -#register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # Virtualenv: current working virtualenv diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index f938819f2..cad7e84c7 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "DROPBOX_ICON" - 'Dropbox' - $'\UF16B' #  - $'\UF16B' #  - '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  - $'\UF16B' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "DROPBOX_ICON" +# 'Dropbox' +# $'\UF16B' #  +# $'\UF16B' #  +# '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  +# $'\UF16B' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon #     -#register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' +register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' ################################################################ # Dropbox status diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index 01035acbf..6a0ac185a 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -8,19 +8,19 @@ # https://gist.github.com/3712874 ################################################################ -prompt_icon=( - "TODO_ICON" - $'\u2611' # ☑ - $'\u2611' # ☑ - $'\u2611' # ☑ - '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  - $'\uF133' #  -) -register_icon "$prompt_icon[@]" -unset prompt_icon +# prompt_icon=( +# "TODO_ICON" +# $'\u2611' # ☑ +# $'\u2611' # ☑ +# $'\u2611' # ☑ +# '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  +# $'\uF133' #  +# ) +# register_icon "$prompt_icon[@]" +# unset prompt_icon # ☑ ☑ ☑   -#register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' +register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' ################################################################ # todo.sh: shows the number of tasks in your todo.sh file From 124e4ed0aa91dabce203dd8433a61012f9a738f6 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:19:03 +0400 Subject: [PATCH 06/55] Updates to register_icon --- functions/icons.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index a3a816218..02683c488 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -53,7 +53,8 @@ esac # register_icon "$prompt_icon[@]" # unset prompt_icon register_icon() { - local arr=("$@") + local arr + arr=("$@") icons[${arr[1]}]=${arr[$map]} } From 8e911e5705ad94eaaf48b5d16903a03e4aedb9a8 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:23:56 +0400 Subject: [PATCH 07/55] Changed declaration of arr variable --- functions/icons.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 02683c488..b8f8f8757 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -22,7 +22,7 @@ # `compatible`. This shows all icons in regular symbols. ################################################################ -typeset -gAH icons +typeset -gAH icons arr local map case $POWERLEVEL9K_MODE in @@ -53,7 +53,6 @@ esac # register_icon "$prompt_icon[@]" # unset prompt_icon register_icon() { - local arr arr=("$@") icons[${arr[1]}]=${arr[$map]} } From bcf27571e94da98a2eb7597528facca8936500b9 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:35:54 +0400 Subject: [PATCH 08/55] Update to tests for Travis --- functions/icons.zsh | 23 +++++++++++------------ test/powerlevel9k.spec | 3 +++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index b8f8f8757..e65cc322e 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -22,16 +22,7 @@ # `compatible`. This shows all icons in regular symbols. ################################################################ -typeset -gAH icons arr - -local map -case $POWERLEVEL9K_MODE in - 'flat'|'awesome-patched') map=3 ;; - 'awesome-fontconfig') map=4 ;; - 'awesome-mapped-fontconfig') map=5 ;; - 'nerdfont-complete'|'nerdfont-fontconfig') map=6 ;; - *) map=2 ;; -esac +typeset -gAH icons ################################################################ # This function allows a segment to register the icons that it requires. @@ -53,8 +44,16 @@ esac # register_icon "$prompt_icon[@]" # unset prompt_icon register_icon() { - arr=("$@") - icons[${arr[1]}]=${arr[$map]} + local map + case $POWERLEVEL9K_MODE in + 'flat'|'awesome-patched') map=$3 ;; + 'awesome-fontconfig') map=$4 ;; + 'awesome-mapped-fontconfig') map=$5 ;; + 'nerdfont-complete'|'nerdfont-fontconfig') map=$6 ;; + *) map=$2 ;; + esac + # local arr=("$@") + icons[$1]=${map} } # Initialize the icon list according to the user's `POWERLEVEL9K_MODE`. diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 5f6b6f27f..dff0a69e2 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -14,6 +14,9 @@ function setUp() { # Unset mode, so that user settings # do not interfere with tests unset POWERLEVEL9K_MODE + + # Load all segments that need to be tested so that they can be sourced + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator background_jobs command_execution_time go_version kubecontext rust_version vcs) } function testJoinedSegments() { From 75dc99b8d3667dc4ff1ec88eafcc3c6ea5fa62c2 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:40:08 +0400 Subject: [PATCH 09/55] Update to command_execution_time test --- test/segments/command_execution_time.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec index e8be508fb..11386c5a4 100755 --- a/test/segments/command_execution_time.spec +++ b/test/segments/command_execution_time.spec @@ -9,6 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source segments/core/command_execution_time.p9k } function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() { @@ -93,4 +94,4 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { unset _P9K_COMMAND_DURATION } -source shunit2/source/2.1/src/shunit2 \ No newline at end of file +source shunit2/source/2.1/src/shunit2 From bccac4aa0acaa4acb2f3ba562ed95baa87b508a3 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 16:47:37 +0400 Subject: [PATCH 10/55] Updated Travis tests for segments --- test/powerlevel9k.spec | 2 +- test/segments/go_version.spec | 1 + test/segments/kubecontext.spec | 1 + test/segments/rust_version.spec | 1 + test/segments/vcs.spec | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index dff0a69e2..cad88a9a9 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -16,7 +16,7 @@ function setUp() { unset POWERLEVEL9K_MODE # Load all segments that need to be tested so that they can be sourced - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator background_jobs command_execution_time go_version kubecontext rust_version vcs) + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator background_jobs) } function testJoinedSegments() { diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 347ba4c06..9c7e28e8f 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -9,6 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source segments/develper/go_version.p9k } function mockGo() { diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index 4f1d2c5e5..bde909953 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -9,6 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source segments/developer/kubecontext.p9k } function mockKubectl() { diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index a96686719..0be94d249 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -9,6 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source segments/developer/rust_version.p9k } function mockRust() { diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index c33b564da..dd87b4092 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -9,6 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source segments/developer/vcs.p9k } function testColorOverridingForCleanStateWorks() { From 75fbdd0c0b0f4eca8296ac58a10b47ef36cc9635 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sun, 11 Mar 2018 17:10:41 +0400 Subject: [PATCH 11/55] Updates to Travis tests --- functions/icons.zsh | 144 ---------------------------------- segments/developer/vcs.p9k | 6 +- test/segments/go_version.spec | 2 +- 3 files changed, 4 insertions(+), 148 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index e65cc322e..84ba0f51f 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -128,81 +128,9 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  -# CARRIAGE_RETURN_ICON $'\u21B5' # ↵ -# ROOT_ICON $'\uE614 ' #  -# SUDO_ICON $'\uF09C' #  -# RUBY_ICON $'\uF219 ' #  -# AWS_ICON $'\uF270' #  -# AWS_EB_ICON $'\UF1BD ' #  -# BACKGROUND_JOBS_ICON $'\uF013 ' #  -# TEST_ICON $'\uF188' #  -# TODO_ICON $'\uF133' #  -# BATTERY_ICON $'\UF240 ' #  -# DISK_ICON $'\uF0A0' #  -# OK_ICON $'\uF00C' #  -# FAIL_ICON $'\uF00D' #  -# SYMFONY_ICON $'\uE757' #  -# NODE_ICON $'\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ -# APPLE_ICON $'\uF179' #  -# WINDOWS_ICON $'\uF17A' #  -# FREEBSD_ICON $'\UF30E ' #  -# ANDROID_ICON $'\uF17B' #  -# LINUX_ARCH_ICON $'\uF300' #  -# LINUX_DEBIAN_ICON $'\uF302' #  -# LINUX_UBUNTU_ICON $'\uF30C' #  -# LINUX_CENTOS_ICON $'\uF301' #  -# LINUX_COREOS_ICON $'\uF30F' #  -# LINUX_ELEMENTARY_ICON $'\uF311' #  -# LINUX_FEDORA_ICON $'\uF303' #  -# LINUX_GENTOO_ICON $'\uF310' #  -# LINUX_MINT_ICON $'\uF304' #  -# LINUX_MAGEIA_ICON $'\uF306' #  -# LINUX_OPENSUSE_ICON $'\uF308' #  -# LINUX_SABAYON_ICON $'\uF313' #  -# LINUX_SLACKWARE_ICON $'\uF30A' #  -# LINUX_ICON $'\uF17C' #  -# SUNOS_ICON $'\uF185 ' #  -# HOME_ICON $'\uF015' #  -# HOME_SUB_ICON $'\uF07C' #  -# FOLDER_ICON $'\uF115' #  -# NETWORK_ICON $'\uF1EB' #  -# LOAD_ICON $'\uF080 ' #  -# SWAP_ICON $'\uF464' #  -# RAM_ICON $'\uF0E4' #  -# SERVER_ICON $'\uF0AE' #  -# VCS_UNTRACKED_ICON $'\uF059' #  -# VCS_UNSTAGED_ICON $'\uF06A' #  -# VCS_STAGED_ICON $'\uF055' #  -# VCS_STASH_ICON $'\uF01C ' #  -# VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  -# VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  -# VCS_TAG_ICON $'\uF02B ' #  -# VCS_BOOKMARK_ICON $'\uF461 ' #  -# VCS_COMMIT_ICON $'\uE729 ' #  -# VCS_BRANCH_ICON $'\uF126 ' #  -# VCS_REMOTE_BRANCH_ICON $'\uE728 ' #  -# VCS_GIT_ICON $'\uF1D3 ' #  -# VCS_GIT_GITHUB_ICON $'\uF113 ' #  -# VCS_GIT_BITBUCKET_ICON $'\uE703 ' #  -# VCS_GIT_GITLAB_ICON $'\uF296 ' #  -# VCS_HG_ICON $'\uF0C3 ' #  -# VCS_SVN_ICON $'\uE72D ' #  -# RUST_ICON $'\uE7A8 ' #  -# PYTHON_ICON $'\UE73C ' #  -# SWIFT_ICON $'\uE755' #  -# GO_ICON $'\uE626' #  -# PUBLIC_IP_ICON $'\UF0AC' #  -# LOCK_ICON $'\UF023' #  -# EXECUTION_TIME_ICON $'\uF252' #  -# SSH_ICON $'\uF489' #  -# VPN_ICON '(vpn)' -# KUBERNETES_ICON $'\U2388' # ⎈ -# DROPBOX_ICON $'\UF16B' #  -# DATE_ICON $'\uF073 ' #  -# TIME_ICON $'\uF017 ' #  ) ;; *) @@ -216,81 +144,9 @@ case $POWERLEVEL9K_MODE in LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  -# CARRIAGE_RETURN_ICON $'\u21B5' # ↵ -# ROOT_ICON $'\u26A1' # ⚡ -# SUDO_ICON $'\uE0A2' #  -# RUBY_ICON '' -# AWS_ICON 'AWS:' -# AWS_EB_ICON $'\U1F331 ' # 🌱 -# BACKGROUND_JOBS_ICON $'\u2699' # ⚙ -# TEST_ICON '' -# TODO_ICON $'\u2611' # ☑ -# BATTERY_ICON $'\U1F50B' # 🔋 -# DISK_ICON $'hdd ' -# OK_ICON $'\u2714' # ✔ -# FAIL_ICON $'\u2718' # ✘ -# SYMFONY_ICON 'SF' -# NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ -# APPLE_ICON 'OSX' -# WINDOWS_ICON 'WIN' -# FREEBSD_ICON 'BSD' -# ANDROID_ICON 'And' -# LINUX_ICON 'Lx' -# LINUX_ARCH_ICON 'Arc' -# LINUX_DEBIAN_ICON 'Deb' -# LINUX_UBUNTU_ICON 'Ubu' -# LINUX_CENTOS_ICON 'Cen' -# LINUX_COREOS_ICON 'Cor' -# LINUX_ELEMENTARY_ICON 'Elm' -# LINUX_MINT_ICON 'LMi' -# LINUX_FEDORA_ICON 'Fed' -# LINUX_GENTOO_ICON 'Gen' -# LINUX_MAGEIA_ICON 'Mag' -# LINUX_OPENSUSE_ICON 'OSu' -# LINUX_SABAYON_ICON 'Sab' -# LINUX_SLACKWARE_ICON 'Sla' -# SUNOS_ICON 'Sun' -# HOME_ICON '' -# HOME_SUB_ICON '' -# FOLDER_ICON '' -# NETWORK_ICON 'IP' -# LOAD_ICON 'L' -# SWAP_ICON 'SWP' -# RAM_ICON 'RAM' -# SERVER_ICON '' -# VCS_UNTRACKED_ICON '?' -# VCS_UNSTAGED_ICON $'\u25CF' # ● -# VCS_STAGED_ICON $'\u271A' # ✚ -# VCS_STASH_ICON $'\u235F' # ⍟ -# VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓ -# VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑ -# VCS_TAG_ICON '' -# VCS_BOOKMARK_ICON $'\u263F' # ☿ -# VCS_COMMIT_ICON '' -# VCS_BRANCH_ICON $'\uE0A0 ' #  -# VCS_REMOTE_BRANCH_ICON $'\u2192' # → -# VCS_GIT_ICON '' -# VCS_GIT_GITHUB_ICON '' -# VCS_GIT_BITBUCKET_ICON '' -# VCS_GIT_GITLAB_ICON '' -# VCS_HG_ICON '' -# VCS_SVN_ICON '' -# RUST_ICON '' -# PYTHON_ICON '' -# SWIFT_ICON 'Swift' -# GO_ICON 'Go' -# PUBLIC_IP_ICON '' -# LOCK_ICON $'\UE0A2' -# EXECUTION_TIME_ICON 'Dur' -# SSH_ICON '(ssh)' -# VPN_ICON '(vpn)' -# KUBERNETES_ICON $'\U2388' # ⎈ -# DROPBOX_ICON 'Dropbox' -# DATE_ICON '' -# TIME_ICON '' ) ;; esac diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index d024a9cdc..51fc7a7f7 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -127,7 +127,7 @@ register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_O if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then local branch_icon - [[ $POWERLEVEL9K_MODE == 'compatible' ]] && branch_icon="@" || branch_icon=$'\uE0A0 ' #  + [[ $POWERLEVEL9K_MODE == 'compatible' ]] && branch_icon="@ " || branch_icon=$'\uE0A0 ' #  # prompt_icon=( # "VCS_BRANCH_ICON" # $branch_icon @@ -138,8 +138,8 @@ if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then # ) # register_icon "$prompt_icon[@]" - #     - register_icon "VCS_BRANCH_ICON" $branch_icon $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + #     + register_icon "VCS_BRANCH_ICON" ${branch_icon} $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' fi # prompt_icon=( diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 9c7e28e8f..622722236 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -9,7 +9,7 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/develper/go_version.p9k + source segments/developer/go_version.p9k } function mockGo() { From 9ff8d1bd655b3240ab0f0579e9a9f7a738021bca Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 12 Mar 2018 09:24:11 +0400 Subject: [PATCH 12/55] Update for vcs test --- segments/developer/vcs.p9k | 51 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index 51fc7a7f7..db369fb66 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -126,29 +126,42 @@ register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOI register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then - local branch_icon - [[ $POWERLEVEL9K_MODE == 'compatible' ]] && branch_icon="@ " || branch_icon=$'\uE0A0 ' #  - # prompt_icon=( - # "VCS_BRANCH_ICON" - # $branch_icon - # $'\uE220 ' #  - # $'\uF126 ' #  - # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - # $'\uF126 ' #  - # ) - # register_icon "$prompt_icon[@]" - - #     - register_icon "VCS_BRANCH_ICON" ${branch_icon} $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + if [[ $POWERLEVEL9K_MODE != 'compatible' ]]; then + # prompt_icon=( + # "VCS_BRANCH_ICON" + # $'\uE0A0 ' #  + # $'\uE220 ' #  + # $'\uF126 ' #  + # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  + # $'\uF126 ' #  + # ) + # register_icon "$prompt_icon[@]" + + #      + register_icon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + else + # prompt_icon=( + # "VCS_BRANCH_ICON" + # "@ " + # $'\uE220 ' #  + # $'\uF126 ' #  + # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  + # $'\uF126 ' #  + # ) + # register_icon "$prompt_icon[@]" + + #     + register_icon "VCS_BRANCH_ICON" "@ " $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + fi fi # prompt_icon=( # "VCS_REMOTE_BRANCH_ICON" -# $'\u2192' # → -# $'\u2192' # → -# $'\u2192' # → -# '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  -# $'\uE728 ' #  +# $'\u2192' # → +# $'\u2192' # → +# $'\u2192' # → +# '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  +# $'\uE728 ' #  # ) # register_icon "$prompt_icon[@]" From 81fe390576870a49f9629d02070db1964a8a0c83 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 13 Mar 2018 18:47:41 +0400 Subject: [PATCH 13/55] Updated segment_in_use Created single list of all segments - POWERLEVEL9K_PROMPT_SEGMENTS --- functions/utilities.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 6ec6b2a99..deaf2a8ec 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -115,7 +115,14 @@ if [[ "$OS" == 'macOS' ]]; then fi # Combine the PROMPT_ELEMENTS -POWERLEVEL9K_PROMPT_ELEMENTS=(union $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS $POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) +#POWERLEVEL9K_PROMPT_ELEMENTS=(union $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS $POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) +local -a POWERLEVEL9K_PROMPT_ELEMENTS +for (( i=0; i <= ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}; i++ )) do + POWERLEVEL9K_PROMPT_ELEMENTS+=${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[$i]%_joined} +done +for (( i=0; i <= ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}; i++ )) do + POWERLEVEL9K_PROMPT_ELEMENTS+=${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[$i]%_joined} +done # Determine if the passed segment is used in the prompt # @@ -124,7 +131,7 @@ POWERLEVEL9K_PROMPT_ELEMENTS=(union $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS $POWERLEV # * $1: The segment to be tested. segment_in_use() { local key=$1 - if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then + if [[ -n "${POWERLEVEL9K_PROMPT_ELEMENTS[(r)$key]}" ]]; then return 0 else return 1 From e81e99c7238001cff5d3d65a36f5601e3ea0fe3a Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 13 Mar 2018 19:04:39 +0400 Subject: [PATCH 14/55] Updated comments for segments --- segments/core/background_jobs.p9k | 12 +- segments/core/battery.p9k | 12 +- segments/core/command_execution_time.p9k | 12 +- segments/core/date.p9k | 12 +- segments/core/dir.p9k | 45 +---- segments/core/dir_writable.p9k | 12 +- segments/core/disk_usage.p9k | 12 +- segments/core/history.p9k | 12 +- segments/core/host.p9k | 23 +-- segments/core/ip.p9k | 12 +- segments/core/load.p9k | 12 +- segments/core/os_icon.p9k | 211 ----------------------- segments/core/public_ip.p9k | 27 +-- segments/core/ram.p9k | 12 +- segments/core/root_indicator.p9k | 12 +- segments/core/ssh.p9k | 12 +- segments/core/status.p9k | 36 +--- segments/core/swap.p9k | 12 +- segments/core/time.p9k | 12 +- segments/core/user.p9k | 38 +--- segments/core/vpn_ip.p9k | 12 +- segments/developer/anaconda.p9k | 21 +-- segments/developer/aws.p9k | 12 +- segments/developer/aws_eb_env.p9k | 12 +- segments/developer/chruby.p9k | 12 +- segments/developer/docker_machine.p9k | 12 +- segments/developer/go_version.p9k | 12 +- segments/developer/kubecontext.p9k | 12 +- segments/developer/node_env.p9k | 12 +- segments/developer/node_version.p9k | 12 +- segments/developer/nvm.p9k | 12 +- segments/developer/pyenv.p9k | 12 +- segments/developer/rbenv.p9k | 12 +- segments/developer/rspec_stats.p9k | 12 +- segments/developer/rust_version.p9k | 12 +- segments/developer/rvm.p9k | 12 +- segments/developer/swift_version.p9k | 12 +- segments/developer/symfony2_tests.p9k | 12 +- segments/developer/symfony2_version.p9k | 12 +- segments/developer/vcs.p9k | 195 +-------------------- segments/developer/virtualenv.p9k | 12 +- segments/other/dropbox.p9k | 12 +- segments/other/todo.p9k | 12 +- 43 files changed, 53 insertions(+), 963 deletions(-) diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index 88d5040ea..8f3536a2d 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "BACKGROUND_JOBS_ICON" -# $'\u2699' # ⚙ -# $'\uE82F ' #  -# $'\uF013 ' #  -# '\u'$CODEPOINT_OF_AWESOME_COG' ' #  -# $'\uF013 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⚙     register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index 2d462d602..fbf174070 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "BATTERY_ICON" -# $'\U1F50B' # 🔋 -# $'\uE894' #  -# $'\U1F50B' # 🔋 -# '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  -# $'\UF240 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # 🔋  🔋   register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index d3072197d..8c74ccafb 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "EXECUTION_TIME_ICON" -# 'Dur' -# $'\UE89C' #  -# $'\uF253' -# '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  -# $'\uF252' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #    register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' diff --git a/segments/core/date.p9k b/segments/core/date.p9k index ad1c677c0..a42d2da3b 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "DATE_ICON" -# '' -# $'\uE184' #  -# $'\uF073 ' #  -# $'\uF073 ' #  -# $'\uF073 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index 326fd8a7a..a5504f5b4 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -8,56 +8,13 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "HOME_ICON" -# '' -# $'\uE12C' #  -# $'\uF015' #  -# '\u'$CODEPOINT_OF_AWESOME_HOME #  -# $'\uF015' #  -# ) -# register_icon "$prompt_icon[@]" - +# Register icons #     register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' - -# prompt_icon=( -# "HOME_SUB_ICON" -# '' -# $'\uE18D' #  -# $'\uF07C' #  -# '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  -# $'\uF07C' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' - -# prompt_icon=( -# "FOLDER_ICON" -# '' -# $'\uE818' #  -# $'\uF115' #  -# '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  -# $'\uF115' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' - -# prompt_icon=( -# "LOCK_ICON" -# $'\UE0A2' -# $'\UE138' #  -# $'\UF023' #  -# '\u'$CODEPOINT_OF_AWESOME_LOCK #  -# $'\UF023' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - #     register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index ac7b1dabb..a50b120ff 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "LOCK_ICON" -# $'\UE0A2' -# $'\UE138' #  -# $'\UF023' #  -# '\u'$CODEPOINT_OF_AWESOME_LOCK #  -# $'\UF023' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index fda9e80bc..956954929 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "DISK_ICON" -# $'hdd ' -# $'\uE1AE ' #  -# $'\uF0A0 ' #  -# '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  -# $'\uF0A0' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' diff --git a/segments/core/history.p9k b/segments/core/history.p9k index cabc22797..c4bd06b10 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "HISTORY_ICON" -# '' -# '' -# $'\uE29A' #  -# $'\uE29A' #  -# $'\uE29A' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #    register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' diff --git a/segments/core/host.p9k b/segments/core/host.p9k index c791e10ab..bc4e8dc6c 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -8,30 +8,9 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SSH_ICON" -# '(ssh)' -# '(ssh)' -# '(ssh)' -# '(ssh)' -# $'\uF489' #  -# ) -# register_icon "$prompt_icon[@]" - +# Register icons #  register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' - -# prompt_icon=( -# "HOST_ICON" -# '' -# '' -# $'\uF67C' #  -# $'\uF67C' #  -# $'\uF67C' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - #    register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index ac4284aaa..347a52ede 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "NETWORK_ICON" -# 'IP' -# $'\uE1AD' #  -# $'\uF09E' #  -# '\u'$CODEPOINT_OF_AWESOME_RSS #  -# $'\uF1EB' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' diff --git a/segments/core/load.p9k b/segments/core/load.p9k index 552d03d90..0cacc3c2d 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "LOAD_ICON" -# 'L' -# $'\uE190 ' #  -# $'\uF080 ' #  -# '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  -# $'\uF080 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index ad8fc833e..90dbf7386 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -11,51 +11,18 @@ # OS detection case "$OS" in "macOS") - # prompt_icon=( - # "APPLE_ICON" - # 'macOS' - # $'\uE26E' #  - # $'\uF179' #  - # '\u'$CODEPOINT_OF_AWESOME_APPLE #  - # $'\uF179' #  - # ) - # register_icon "$prompt_icon[@]" - #     register_icon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' - OS_ICON='APPLE_ICON' ;; "Windows") - # prompt_icon=( - # "WINDOWS_ICON" - # 'WIN' - # $'\uE26F' #  - # $'\uF17A' #  - # $'\uF17A' #  - # $'\uF17A' #  - # ) - # register_icon "$prompt_icon[@]" - #     register_icon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' - OS_ICON='WINDOWS_ICON' ;; "BSD") - # prompt_icon=( - # "FREEBSD_ICON" - # 'BSD' - # $'\U1F608 ' # 😈 - # $'\U1F608 ' # 😈 - # $'\U1F608 ' # 😈 - # $'\UF30E ' #  - # ) - # register_icon "$prompt_icon[@]" - # 😈 😈 😈  register_icon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' - OS_ICON='FREEBSD_ICON' ;; # OpenBSD) @@ -67,261 +34,85 @@ case "$OS" in "Linux") case "$OS_ID" in "arch") - # prompt_icon=( - # "LINUX_ARCH_ICON" - # 'Arc' - # 'Arc' - # 'Arc' - # 'Arc' - # $'\uF300' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' - OS_ICON='LINUX_ARCH_ICON' ;; "debian") - # prompt_icon=( - # "LINUX_DEBIAN_ICON" - # 'Deb' - # 'Deb' - # 'Deb' - # 'Deb' - # $'\uF302' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' - OS_ICON='LINUX_DEBIAN_ICON' ;; "ubuntu") - # prompt_icon=( - # "LINUX_UBUNTU_ICON" - # 'Ubu' - # 'Ubu' - # 'Ubu' - # 'Ubu' - # $'\uF30C' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' - OS_ICON='LINUX_UBUNTU_ICON' ;; "elementary") - # prompt_icon=( - # "LINUX_ELEMENTARY_ICON" - # 'Elm' - # 'Elm' - # 'Elm' - # 'Elm' - # $'\uF311' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' - OS_ICON='LINUX_ELEMENTARY_ICON' ;; "fedora") - # prompt_icon=( - # "LINUX_FEDORA_ICON" - # 'Fed' - # 'Fed' - # 'Fed' - # 'Fed' - # $'\uF303' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' - OS_ICON='LINUX_FEDORA_ICON' ;; "coreos") - # prompt_icon=( - # "LINUX_COREOS_ICON" - # 'Cor' - # 'Cor' - # 'Cor' - # 'Cor' - # $'\uF30F' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' - OS_ICON='LINUX_COREOS_ICON' ;; "gentoo") - # prompt_icon=( - # "LINUX_GENTOO_ICON" - # 'Gen' - # 'Gen' - # 'Gen' - # 'Gen' - # $'\uF310' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' - OS_ICON='LINUX_GENTOO_ICON' ;; "mageia") - # prompt_icon=( - # "LINUX_MAGEIA_ICON" - # 'Mag' - # 'Mag' - # 'Mag' - # 'Mag' - # $'\uF306' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' - OS_ICON='LINUX_MAGEIA_ICON' ;; "centos") - # prompt_icon=( - # "LINUX_CENTOS_ICON" - # 'Cen' - # 'Cen' - # 'Cen' - # 'Cen' - # $'\uF301' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' - OS_ICON='LINUX_CENTOS_ICON' ;; "opensuse"|"tumbleweed") - # prompt_icon=( - # "LINUX_OPENSUSE_ICON" - # 'OSu' - # 'OSu' - # 'OSu' - # 'OSu' - # $'\uF308' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' - OS_ICON='LINUX_OPENSUSE_ICON' ;; "sabayon") - # prompt_icon=( - # "LINUX_SABAYON_ICON" - # 'Sab' - # 'Sab' - # 'Sab' - # 'Sab' - # $'\uF313' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' - OS_ICON='LINUX_SABAYON_ICON' ;; "slackware") - # prompt_icon=( - # "LINUX_SLACKWARE_ICON" - # 'Sla' - # 'Sla' - # 'Sla' - # 'Sla' - # $'\uF30A' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' - OS_ICON='LINUX_SLACKWARE_ICON' ;; "linuxmint") - # prompt_icon=( - # "LINUX_MINT_ICON" - # 'LMi' - # 'LMi' - # 'LMi' - # 'LMi' - # $'\uF304' #  - # ) - # register_icon "$prompt_icon[@]" - #  register_icon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' - OS_ICON='LINUX_MINT_ICON' ;; *) - # prompt_icon=( - # "LINUX_ICON" - # 'Lx' - # $'\uE271' #  - # $'\uF17C' #  - # '\u'$CODEPOINT_OF_AWESOME_LINUX #  - # $'\uF17C' #  - # ) - # register_icon "$prompt_icon[@]" - #     register_icon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' - OS_ICON='LINUX_ICON' ;; esac ;; "Android") - # prompt_icon=( - # "ANDROID_ICON" - # 'And' - # $'\uE270' #  - # $'\uE17B' #  - # $'\uF17B' #  - # $'\uF17B' #  - # ) - # register_icon "$prompt_icon[@]" - #     register_icon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' - OS_ICON='ANDROID_ICON' ;; "Solaris") - # prompt_icon=( - # "SUNOS_ICON" - # 'Sun' - # $'\U1F31E ' # 🌞 - # $'\uF185 ' #  - # '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  - # $'\uF185 ' #  - # ) - # register_icon "$prompt_icon[@]" - # 🌞    register_icon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' - OS_ICON='SUNOS_ICON' ;; *) @@ -330,8 +121,6 @@ case "$OS" in ;; esac -# unset prompt_icon - ################################################################ # Segment to print a little OS icon prompt_os_icon() { diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 12788933e..810d0c31c 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -8,32 +8,11 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "PUBLIC_IP_ICON" -# '' -# '' -# '' -# '\u'$CODEPOINT_OF_AWESOME_GLOBE #  -# $'\UF0AC' #  -# ) -# register_icon "$prompt_icon[@]" - +# Register icons #   register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' - -# prompt_icon=( -# "VPN_ICON" -# '(vpn)' -# '(vpn)' -# $'\uF023' #  -# '\u'$CODEPOINT_OF_AWESOME_LOCK -# '(vpn)' -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - -# -register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' +#    +register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\uF023' ################################################################ # Public IP segment diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index c18cfa4e6..28a9df3ba 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "RAM_ICON" -# 'RAM' -# $'\uE1E2 ' #  -# $'\uF0E4' #  -# '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  -# $'\uF0E4' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index a705de971..5bbc3b21b 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "ROOT_ICON" -# $'\u26A1' # ⚡ -# $'\uE801' #  -# $'\uF201' #  -# '\u'$CODEPOINT_OF_OCTICONS_ZAP #  -# $'\uE614 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⚡     register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index 3425c133a..e52e826df 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SSH_ICON" -# '(ssh)' -# '(ssh)' -# '(ssh)' -# '(ssh)' -# $'\uF489' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #  register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' diff --git a/segments/core/status.p9k b/segments/core/status.p9k index 873894a00..1271de266 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -8,43 +8,11 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "CARRIAGE_RETURN_ICON" -# $'\u21B5' # ↵ -# $'\u21B5' # ↵ -# $'\u21B5' # ↵ -# $'\u21B5' # ↵ -# $'\u21B5' # ↵ -# ) -# register_icon "$prompt_icon[@]" - -# ↵ ↵ ↵ ↵ ↵ +# Register icons +# ↵ ↵ ↵ ↵ ↵ register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' - -# prompt_icon=( -# "OK_ICON" -# $'\u2714' # ✔ -# $'\u2714' # ✔ -# $'\u2714' # ✔ -# '\u'$CODEPOINT_OF_AWESOME_CHECK #  -# $'\uF00C' #  -# ) -# register_icon "$prompt_icon[@]" - # ✔ ✔ ✔   register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' - -# prompt_icon=( -# "FAIL_ICON" -# $'\u2718' # ✘ -# $'\u2718' # ✘ -# $'\u2718' # ✘ -# '\u'$CODEPOINT_OF_AWESOME_TIMES #  -# $'\uF00D' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - # ✘ ✘ ✘   register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index b0d2198e5..23ea9513b 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SWAP_ICON" -# 'SWP' -# $'\uE87D' #  -# $'\uF0E4' #  -# '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  -# $'\uF464' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' diff --git a/segments/core/time.p9k b/segments/core/time.p9k index 1ad56f810..5c382f1ef 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "TIME_ICON" -# '' -# $'\uE12E' #  -# $'\uF017 ' #  -# $'\uF017 ' #  -# $'\uF017 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' diff --git a/segments/core/user.p9k b/segments/core/user.p9k index 4fc40f0a0..1308e2999 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -8,45 +8,13 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "ROOT_ICON" -# $'\u26A1' # ⚡ -# $'\uE801' #  -# $'\uF201' #  -# '\u'$CODEPOINT_OF_OCTICONS_ZAP #  -# $'\uE614 ' #  -# ) -# register_icon "$prompt_icon[@]" - +# Register icons # ⚡     register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' - -# prompt_icon=( -# "SUDO_ICON" -# $'\uE0A2' #  -# $'\uF09C' #  -# $'\uF09C' #  -# '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  -# $'\uF09C' #  -# ) -# register_icon "$prompt_icon[@]" - #      register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' - -# prompt_icon=( -# "USER_ICON" -# '' -# '' -# $'\uF2C0' #  -# $'\uF2C0' #  -# $'\uF2C0' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - -#    -register_icon "SUDO_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' +#    +register_icon "USER_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' ################################################################ # User: user (who am I) diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index 816bc2dc8..0d33bc5f9 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "VPN_ICON" -# '(vpn)' -# '(vpn)' -# $'\uF023' #  -# '\u'$CODEPOINT_OF_AWESOME_LOCK -# '(vpn)' -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index 0a66236ee..da895fc9e 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -8,20 +8,16 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "PYTHON_ICON" -# '' -# $'\ue63c' #  -# $'\ue63c' #  -# $'\U1F40D' # 🐍 -# $'\UE73C ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +################################################################ +# Register segment icon #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +################################################################ +# Register segment default values +set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" +set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" + ################################################################ # Anaconda Environment prompt_anaconda() { @@ -29,9 +25,6 @@ prompt_anaconda() { # variant works even if both are set. _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then - # config - can be overwritten in users' zshrc file. - set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" - set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' fi } diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index 9cae0197e..361565aee 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "AWS_ICON" -# 'AWS:' -# $'\uE895' #  -# $'\uF270' #  -# '\u'$CODEPOINT_OF_AWESOME_SERVER #  -# $'\uF270' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index f147416bf..8ac238d55 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "AWS_EB_ICON" -# $'\U1F331 ' # 🌱 -# $'\U1F331 ' # 🌱 -# $'\U1F331 ' # 🌱 -# $'\U1F331 ' # 🌱 -# $'\UF1BD ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # 🌱 🌱 🌱 🌱  register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index d58969377..3a68a1919 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "RUBY_ICON" -# '' -# $'\uE847 ' #  -# $'\uF219 ' #  -# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  -# $'\uF219 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index 9c8b2dec9..7095f25c1 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SERVER_ICON" -# '' -# $'\uE895' #  -# $'\uF233' #  -# '\u'$CODEPOINT_OF_AWESOME_SERVER #  -# $'\uF0AE' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index 1c4848e20..1f11e89cb 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "GO_ICON" -# 'Go' -# '' -# '' -# '' -# $'\uE626' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #  register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index 9b9cc98bb..7591ef33a 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "KUBERNETES_ICON" -# $'\U2388' # ⎈ -# $'\U2388' # ⎈ -# $'\U2388' # ⎈ -# $'\U2388' # ⎈ -# $'\U2388' # ⎈ -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⎈ ⎈ ⎈ ⎈ ⎈ register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index 8351664b5..8063b246c 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "NODE_ICON" -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\uE617 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index da10e84f9..83398d86d 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "NODE_ICON" -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\uE617 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index 8f9afd661..2d320acbd 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "NODE_ICON" -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\u2B22' # ⬢ -# $'\uE617 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index 8012e17b5..0b6a65530 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "PYTHON_ICON" -# '' -# $'\ue63c' #  -# $'\ue63c' #  -# $'\U1F40D' # 🐍 -# $'\UE73C ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index 951683766..e80384a4b 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "RUBY_ICON" -# '' -# $'\uE847 ' #  -# $'\uF219 ' #  -# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  -# $'\uF219 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index 60686cee2..dc64fa2aa 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "TEST_ICON" -# '' -# $'\uE891' #  -# $'\uF291' #  -# '\u'$CODEPOINT_OF_AWESOME_BUG #  -# $'\uF188' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index 8e146995d..0bf911ddf 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "RUST_ICON" -# '' -# '' -# $'\uE6A8' #  -# $'\uE6A8' #  -# $'\uE7A8 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #    register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index 8aa4ccf65..9d2401e17 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "RUBY_ICON" -# '' -# $'\uE847 ' #  -# $'\uF219 ' #  -# '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  -# $'\uF219 ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index 4794e25c4..76d8cc3d2 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SWIFT_ICON" -# 'Swift' -# '' -# '' -# $'\uE655' #  -# $'\uE755' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #   register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index 9dc7a0ae3..d30a23d74 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "TEST_ICON" -# '' -# $'\uE891' #  -# $'\uF291' #  -# '\u'$CODEPOINT_OF_AWESOME_BUG #  -# $'\uF188' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index 85191275b..01b57179a 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "SYMFONY_ICON" -# 'SF' -# 'SF' -# 'SF' -# 'SF' -# $'\uE757' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #  register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index db369fb66..c2046a9fb 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -8,241 +8,48 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "VCS_UNTRACKED_ICON" -# '?' -# $'\uE16C' #  -# $'\uF059' #  -# '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  -# $'\uF059' #  -# ) -# register_icon "$prompt_icon[@]" - +# Register icons #     register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' - -# prompt_icon=( -# "VCS_UNSTAGED_ICON" -# $'\u25CF' # ● -# $'\uE17C' #  -# $'\uF06A' #  -# '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  -# $'\uF06A' #  -# ) -# register_icon "$prompt_icon[@]" - # ●     register_icon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' - -# prompt_icon=( -# "VCS_STAGED_ICON" -# $'\u271A' # ✚ -# $'\uE168' #  -# $'\uF055' #  -# '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  -# $'\uF055' #  -# ) -# register_icon "$prompt_icon[@]" - # ✚     register_icon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' - -# prompt_icon=( -# "VCS_STASH_ICON" -# $'\u235F' # ⍟ -# $'\uE133 ' #  -# $'\uF01C ' #  -# '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  -# $'\uF01C ' #  -# ) -# register_icon "$prompt_icon[@]" - # ⍟     register_icon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' - -# prompt_icon=( -# "VCS_INCOMING_CHANGES_ICON" -# $'\u2193' # ↓ -# $'\uE131 ' #  -# $'\uF01A ' #  -# '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  -# $'\uF01A ' #  -# ) -# register_icon "$prompt_icon[@]" - # ↓     register_icon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' - -# prompt_icon=( -# "VCS_OUTGOING_CHANGES_ICON" -# $'\u2191' # ↑ -# $'\uE132 ' #  -# $'\uF01B ' #  -# '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  -# $'\uF01B ' #  -# ) -# register_icon "$prompt_icon[@]" - # ↑     register_icon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' - -# prompt_icon=( -# "VCS_TAG_ICON" -# '' -# $'\uE817 ' #  -# $'\uF217 ' #  -# '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  -# $'\uF02B ' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' - -# prompt_icon=( -# "VCS_BOOKMARK_ICON" -# $'\u263F' # ☿ -# $'\uE87B' #  -# $'\uF27B' #  -# '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  -# $'\uF461 ' #  -# ) -# register_icon "$prompt_icon[@]" - # ☿     register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' - -# prompt_icon=( -# "VCS_COMMIT_ICON" -# '' -# $'\uE821 ' #  -# $'\uF221 ' #  -# '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  -# $'\uE729 ' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then if [[ $POWERLEVEL9K_MODE != 'compatible' ]]; then - # prompt_icon=( - # "VCS_BRANCH_ICON" - # $'\uE0A0 ' #  - # $'\uE220 ' #  - # $'\uF126 ' #  - # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - # $'\uF126 ' #  - # ) - # register_icon "$prompt_icon[@]" - #      register_icon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' else - # prompt_icon=( - # "VCS_BRANCH_ICON" - # "@ " - # $'\uE220 ' #  - # $'\uF126 ' #  - # '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - # $'\uF126 ' #  - # ) - # register_icon "$prompt_icon[@]" - #     register_icon "VCS_BRANCH_ICON" "@ " $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' fi fi -# prompt_icon=( -# "VCS_REMOTE_BRANCH_ICON" -# $'\u2192' # → -# $'\u2192' # → -# $'\u2192' # → -# '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  -# $'\uE728 ' #  -# ) -# register_icon "$prompt_icon[@]" - # → → →   register_icon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' - -# prompt_icon=( -# "VCS_GIT_ICON" -# '' -# $'\uE20E ' #  -# $'\uF1D3 ' #  -# '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  -# $'\uF1D3 ' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' - -# prompt_icon=( -# "VCS_GIT_GITHUB_ICON" -# '' -# $'\uE20E ' # -# $'\uF113 ' #  -# '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  -# $'\uF113 ' #  -# ) -# register_icon "$prompt_icon[@]" - #    register_icon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' - -# prompt_icon=( -# "VCS_GIT_BITBUCKET_ICON" -# '' -# $'\uE20E ' # -# $'\uF171 ' #  -# '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  -# $'\uE703 ' #  -# ) -# register_icon "$prompt_icon[@]" - #    register_icon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' - -# prompt_icon=( -# "VCS_GIT_GITLAB_ICON" -# '' -# $'\uE20E ' # -# $'\uF296 ' #  -# '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  -# $'\uF296 ' #  -# ) -# register_icon "$prompt_icon[@]" - #    register_icon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' - -# prompt_icon=( -# "VCS_HG_ICON" -# '' -# $'\uE1C3 ' #  -# $'\uF0C3 ' #  -# '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  -# $'\uF0C3 ' #  -# ) -# register_icon "$prompt_icon[@]" - #     register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' - -# prompt_icon=( -# "VCS_SVN_ICON" -# '' -# '(svn) ' -# '(svn) ' -# '(svn) ' -# $'\uE72D ' #  -# ) -# register_icon "$prompt_icon[@]" - #  register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index 0bfb3056f..a2fe32674 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "PYTHON_ICON" -# '' -# $'\ue63c' #  -# $'\ue63c' #  -# $'\U1F40D' # 🐍 -# $'\UE73C ' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index cad7e84c7..635244624 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "DROPBOX_ICON" -# 'Dropbox' -# $'\UF16B' #  -# $'\UF16B' #  -# '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  -# $'\UF16B' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons #     register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index 6a0ac185a..b51f95104 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -8,17 +8,7 @@ # https://gist.github.com/3712874 ################################################################ -# prompt_icon=( -# "TODO_ICON" -# $'\u2611' # ☑ -# $'\u2611' # ☑ -# $'\u2611' # ☑ -# '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  -# $'\uF133' #  -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon - +# Register icons # ☑ ☑ ☑   register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' From f64b37f5f11682360e1130bfcfa09c2cd38f83ad Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 14 Mar 2018 16:50:19 +0400 Subject: [PATCH 15/55] Updated powerlevel9k.spec --- test/powerlevel9k.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index cad88a9a9..92b71127f 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -10,6 +10,7 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* + source segments/core/* # Unset mode, so that user settings # do not interfere with tests From 9736bde2bc8b2d8fd08618ef55e1c78466b5e6ca Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 14 Mar 2018 16:58:05 +0400 Subject: [PATCH 16/55] 2nd update to powerlevel9k.spec --- test/powerlevel9k.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 92b71127f..bfd9f1ac8 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -10,7 +10,9 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* - source segments/core/* + source segments/core/dir.p9k + source segments/core/background_jobs.p9k + source segments/core/root_indicator.p9k # Unset mode, so that user settings # do not interfere with tests @@ -87,6 +89,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { # Re-Source the icons, as the POWERLEVEL9K_MODE is directly # evaluated there. source functions/icons.zsh + source segments/core/dir.p9k cd /tmp From 6ebb30177bfabd9f37c8b0deedea98415879517e Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 14 Mar 2018 17:01:34 +0400 Subject: [PATCH 17/55] Updated dir.spec --- test/segments/dir.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 66009a862..d992eb8f2 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -1,6 +1,9 @@ #!/usr/bin/env zsh #vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +# Resource the dir.p9k component +source segments/core/dir.p9k + # Required for shunit2 to run correctly setopt shwordsplit SHUNIT_PARENT=$0 From bde36e6abf3360b1fa5f889799c9e9eead403fb9 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 14 Mar 2018 17:05:01 +0400 Subject: [PATCH 18/55] 2nd update to dir.spec --- test/segments/dir.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index d992eb8f2..18f948a6a 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -1,7 +1,8 @@ #!/usr/bin/env zsh #vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -# Resource the dir.p9k component +# Resource the relevant code +source functions/* source segments/core/dir.p9k # Required for shunit2 to run correctly From a017e362304614406fc4e040ab8096c661c290eb Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 14 Mar 2018 17:11:20 +0400 Subject: [PATCH 19/55] dir.spc - updated setUp() --- test/segments/dir.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 18f948a6a..c1a98d01c 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -1,10 +1,6 @@ #!/usr/bin/env zsh #vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -# Resource the relevant code -source functions/* -source segments/core/dir.p9k - # Required for shunit2 to run correctly setopt shwordsplit SHUNIT_PARENT=$0 @@ -13,6 +9,8 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme + source functions/* + source segments/core/dir.p9k # Every test should at least use the dir segment POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) From cd386bed34cf4789e1d1640fae016c6bd7d84020 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 21 Mar 2018 17:02:57 +0400 Subject: [PATCH 20/55] Update to dir segment #776 --- segments/core/dir.p9k | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index a5504f5b4..2560f5221 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -183,7 +183,7 @@ prompt_dir() { fi ;; *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + current_path="$(print "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" ;; esac fi From 1358e3a3a162e7a7a6c1cf2a78cdb9a44e60c91f Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 21 Mar 2018 17:08:29 +0400 Subject: [PATCH 21/55] Added function: serialize_segment This is the beginning of moving from the current generator (sync) to a new generator (async). TODO: Update all segments to use serialize_segment instead of calling left_prompt_segment or right_prompt_segment directly. --- powerlevel9k.zsh-theme | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 264e9920c..9980d1b28 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -262,6 +262,104 @@ right_prompt_segment() { last_right_element_index=$current_index } +############################################################### +# This function wraps left_prompt_segment and right_prompt_segment to serializes a segment (for compatibility with the async branch) +# +# Parameters for serialize_segment: +# * $1 Name: string - Name of the segment +# * $2 State: string - The state the segment is in +# * $3 Alignment: string - left|right +# * $4 Index: integer +# * $5 Joined: bool - If the segment should be joined +# * $6 Background: string - The default background color of the segment +# * $7 Foreground: string - The default foreground color of the segment +# * $8 Content: string - Content of the segment +# * $9 Visual identifier: string - Icon of the segment +# * $10 Condition: string - The condition, if the segment should be printed (gets evaluated) +# +# Parameters for [left|right]_prompt_segment: +# * $1: Name of the function that was originally invoked (mandatory). +# Necessary, to make the dynamic color-overwrite mechanism work. +# * $2: The array index of the current segment +# * $3: Background color +# * $4: Foreground color +# * $5: Bold +# * $6: The segment content +# * $7: An identifying icon (must be a key of the icons array) +# The latter three can be omitted, +serialize_segment() { + local NAME="${1}" + local STATE="${2}" + local ALIGNMENT="${3}" + local INDEX="${4}" + local JOINED="${5}" + + local STATEFUL_NAME="${(U)NAME#prompt_}" + [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${(U)STATE}" + + # Overwrite given background-color by user defined variable for this segment. + local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" + local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" + [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" + + # Overwrite given foreground-color by user defined variable for this segment. + local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" + local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" + [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" + + # Overwrite given bold directive by user defined variable for this segment. + local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" + local BOLD="${(P)BOLD_USER_VARIABLE}" + [[ -z "${BOLD}" ]] && BOLD=false + + local CONTENT="${8}" + + local VISUAL_IDENTIFIER + if [[ -n "${9}" ]]; then + VISUAL_IDENTIFIER="$(print_icon ${9})" + if [[ -n "${VISUAL_IDENTIFIER}" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + set_default "${visual_identifier_color_variable}" "${FOREGROUND}" + VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" + # Add an whitespace if we print more than just the visual identifier + if [[ -n "${CONTENT}" ]]; then + [[ "${ALIGNMENT}" == "left" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " + [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" + fi + fi + fi + # Conditions have three layers: + # 1. All segments should not print + # a segment, if they provide no + # content (default condition). + # 2. All segments could define a + # default condition on their + # own, overriding the previous + # one. + # 3. Users could set a condition + # for each segment. This is + # the trump card, and has + # highest precedence. + local CONDITION + local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" + if defined "${SEGMENT_CONDITION}"; then + CONDITION="${(P)SEGMENT_CONDITION}" + elif [[ -n "${10}" ]]; then + CONDITION="${10}" + else + CONDITION='[[ -n "${8}" ]]' + fi + # Precompile condition. + eval "${CONDITION}" && CONDITION=true || CONDITION=false + +# if ! ${CONDITION}; then +# continue +# fi + + "$3_prompt_segment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" "${CONDITION}" +} + ################################################################ # Prompt Segment Definitions ################################################################ From 51c3be287b8e5ed01e0f56c2f3116968479d3c6f Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 22 Mar 2018 15:09:31 +0400 Subject: [PATCH 22/55] Added generators folder and updated segments * Moved all generator code to a separate folder - generator/default.p9k * Changed all segment calls to use serialize_segment * Added zsh-async and generator/zsh-async.p9k for EXPERIMENTAL async support --- generator/default.p9k | 488 ++++++++++++++++ generator/zsh-async.p9k | 683 +++++++++++++++++++++++ powerlevel9k.zsh-theme | 498 +---------------- segments/core/background_jobs.p9k | 2 +- segments/core/battery.p9k | 4 +- segments/core/command_execution_time.p9k | 2 +- segments/core/context.p9k | 2 +- segments/core/date.p9k | 2 +- segments/core/dir.p9k | 2 +- segments/core/dir_writable.p9k | 2 +- segments/core/disk_usage.p9k | 2 +- segments/core/history.p9k | 2 +- segments/core/host.p9k | 2 +- segments/core/ip.p9k | 2 +- segments/core/load.p9k | 2 +- segments/core/os_icon.p9k | 2 +- segments/core/public_ip.p9k | 2 +- segments/core/ram.p9k | 2 +- segments/core/root_indicator.p9k | 2 +- segments/core/ssh.p9k | 2 +- segments/core/status.p9k | 6 +- segments/core/swap.p9k | 2 +- segments/core/test_stats.p9k | 25 - segments/core/time.p9k | 2 +- segments/core/user.p9k | 2 +- segments/core/vi_mode.p9k | 4 +- segments/core/vpn_ip.p9k | 2 +- segments/developer/anaconda.p9k | 2 +- segments/developer/aws.p9k | 2 +- segments/developer/aws_eb_env.p9k | 2 +- segments/developer/chruby.p9k | 2 +- segments/developer/detect_virt.p9k | 4 +- segments/developer/docker_machine.p9k | 2 +- segments/developer/go_version.p9k | 2 +- segments/developer/kubecontext.p9k | 2 +- segments/developer/node_env.p9k | 2 +- segments/developer/node_version.p9k | 2 +- segments/developer/nvm.p9k | 2 +- segments/developer/php_version.p9k | 2 +- segments/developer/pyenv.p9k | 2 +- segments/developer/rbenv.p9k | 2 +- segments/developer/rspec_stats.p9k | 5 +- segments/developer/rust_version.p9k | 2 +- segments/developer/rvm.p9k | 2 +- segments/developer/swift_version.p9k | 2 +- segments/developer/symfony2_tests.p9k | 5 +- segments/developer/symfony2_version.p9k | 2 +- segments/developer/test_stats.p9k | 34 ++ segments/developer/vcs.p9k | 7 +- segments/developer/virtualenv.p9k | 2 +- segments/other/dropbox.p9k | 2 +- segments/other/icons_test.p9k | 2 +- segments/other/openfoam.p9k | 4 +- segments/other/todo.p9k | 2 +- 54 files changed, 1290 insertions(+), 559 deletions(-) create mode 100644 generator/default.p9k create mode 100644 generator/zsh-async.p9k delete mode 100644 segments/core/test_stats.p9k create mode 100644 segments/developer/test_stats.p9k diff --git a/generator/default.p9k b/generator/default.p9k new file mode 100644 index 000000000..ad6960bd9 --- /dev/null +++ b/generator/default.p9k @@ -0,0 +1,488 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +################################################################ +# DEFAULT ENGINE - Synchronous +################################################################ + +################################################################ +# Prompt Segment Constructors +# +# Methodology behind user-defined variables overwriting colors: +# The first parameter to the segment constructors is the calling function's +# name. From this function name, we strip the "prompt_"-prefix and +# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed +# with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable +# name. So each new segment is user-overwritten by a variable following +# this naming convention. +################################################################ + +# The `CURRENT_BG` variable is used to remember what the last BG color used was +# when building the left-hand prompt. Because the RPROMPT is created from +# right-left but reads the opposite, this isn't necessary for the other side. +CURRENT_BG='NONE' + +# Begin a left prompt segment +# Takes seven arguments: +# * $1 Name: string - Name of the function that was originally invoked (mandatory). +# * $2 Index: integer +# * $3 Background: string +# * $4 Foreground: string +# * $5 Bold: bool +# * $6 Content: string +# * $7 Visual identifier: string - Icon (must be a key of the icons array) +# The latter three can be omitted, +set_default last_left_element_index 1 +set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " +left_prompt_segment() { + local current_index=$2 + # Check if the segment should be joined with the previous one + local joined + segmentShouldBeJoined $current_index $last_left_element_index "$POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false + + # Overwrite given background-color by user defined variable for this segment. + local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND + local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} + [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" + + # Overwrite given foreground-color by user defined variable for this segment. + local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND + local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} + [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" + + local bg fg + [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then + echo -n "$bg%F{$CURRENT_BG}" + if [[ $joined == false ]]; then + # Middle segment + echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + fi + elif isSameColor "$CURRENT_BG" "$3"; then + # Middle segment with same color as previous segment + # We take the current foreground color as color for our + # subsegment (or the default color). This should have + # enough contrast. + local complement + [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "${bg}${complement}" + if [[ $joined == false ]]; then + echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + fi + else + # First segment + echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + fi + + local visual_identifier + if [[ -n $7 ]]; then + visual_identifier="$7" + if [[ -n "$visual_identifier" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $4 + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # Add an whitespace if we print more than just the visual identifier + [[ -n "$6" ]] && visual_identifier="$visual_identifier " + fi + fi + + # Print the visual identifier + echo -n "${visual_identifier}" + # Print the content of the segment, if there is any + [[ -n "$6" ]] && echo -n "${fg}${6}" + echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" + + CURRENT_BG=$3 + last_left_element_index=$current_index +} + +# End the left prompt, closes the final segment. +left_prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" + else + echo -n "%k" + fi + echo -n "%f$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" + CURRENT_BG='' +} + +CURRENT_RIGHT_BG='NONE' + +# Begin a right prompt segment +# Takes seven arguments: +# * $1 Name: string - Name of the function that was originally invoked (mandatory). +# * $2 Index: integer +# * $3 Background: string +# * $4 Foreground: string +# * $5 Bold: bool +# * $6 Content: string +# * $7 Visual identifier: string - Icon (must be a key of the icons array) +# No ending for the right prompt segment is needed (unlike the left prompt, above). +set_default last_right_element_index 1 +set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " +right_prompt_segment() { + local current_index=$2 + + # Check if the segment should be joined with the previous one + local joined + segmentShouldBeJoined $current_index $last_right_element_index "$POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false + + # Overwrite given background-color by user defined variable for this segment. + local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND + local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} + [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" + + # Overwrite given foreground-color by user defined variable for this segment. + local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND + local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} + [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" + + local bg fg + [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. + if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then + if isSameColor "$CURRENT_RIGHT_BG" "$3"; then + # Middle segment with same color as previous segment + # We take the current foreground color as color for our + # subsegment (or the default color). This should have + # enough contrast. + local complement + [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" + else + # Use the new BG color for the foreground with separator + echo -n "$(foregroundColor $3)$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f" + fi + fi + + local visual_identifier + if [[ -n "$7" ]]; then + visual_identifier="$7" + if [[ -n "$visual_identifier" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $4 + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # Add an whitespace if we print more than just the visual identifier + [[ -n "$6" ]] && visual_identifier=" $visual_identifier" + fi + fi + + echo -n "${bg}${fg}" + + # Print whitespace only if segment is not joined or first right segment + [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + + # Print segment content if there is any + [[ -n "$6" ]] && echo -n "${6}" + # Print the visual identifier + echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + + CURRENT_RIGHT_BG=$3 + last_right_element_index=$current_index +} + +############################################################### +# This function wraps left_prompt_segment and right_prompt_segment to serializes a segment (for compatibility with the async branch) +# +# Parameters for serialize_segment: +# * $1 Name: string - Name of the segment +# * $2 State: string - The state the segment is in +# * $3 Alignment: string - left|right +# * $4 Index: integer +# * $5 Joined: bool - If the segment should be joined +# * $6 Background: string - The default background color of the segment +# * $7 Foreground: string - The default foreground color of the segment +# * $8 Content: string - Content of the segment +# * $9 Visual identifier: string - Icon of the segment +# * $10 Condition: string - The condition, if the segment should be printed (gets evaluated) +# +# Parameters for [left|right]_prompt_segment: +# * $1 Name: string - Name of the function that was originally invoked (mandatory). +# * $2 Index: integer +# * $3 Background: string +# * $4 Foreground: string +# * $5 Bold: bool +# * $6 Content: string +# * $7 Visual identifier: string - Icon (must be a key of the icons array) +# The latter three can be omitted, +serialize_segment() { + local NAME="${1}" + local STATE="${2}" + local ALIGNMENT="${3}" + local INDEX="${4}" + local JOINED="${5}" + + local STATEFUL_NAME="${(U)NAME#prompt_}" + [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${(U)STATE}" + + # Overwrite given background-color by user defined variable for this segment. + local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" + local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" + [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" + + # Overwrite given foreground-color by user defined variable for this segment. + local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" + local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" + [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" + + # Overwrite given bold directive by user defined variable for this segment. + local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" + local BOLD="${(P)BOLD_USER_VARIABLE}" + [[ -z "${BOLD}" ]] && BOLD=false || BOLD=true + + local CONTENT="${8}" + + local VISUAL_IDENTIFIER + if [[ -n "${9}" ]]; then + VISUAL_IDENTIFIER="$(print_icon ${9})" + if [[ -n "${VISUAL_IDENTIFIER}" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + set_default "${visual_identifier_color_variable}" "${FOREGROUND}" + VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" + # Add an whitespace if we print more than just the visual identifier + if [[ -n "${CONTENT}" ]]; then + [[ "${ALIGNMENT}" == "left" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " + [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" + fi + fi + fi + # Conditions have three layers: + # 1. All segments should not print + # a segment, if they provide no + # content (default condition). + # 2. All segments could define a + # default condition on their + # own, overriding the previous + # one. + # 3. Users could set a condition + # for each segment. This is + # the trump card, and has + # highest precedence. + local CONDITION + local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" + if defined "${SEGMENT_CONDITION}"; then + CONDITION="${(P)SEGMENT_CONDITION}" + elif [[ -n "${10}" ]]; then + CONDITION="${10}" + else + CONDITION='[[ -n "${8}" ]]' + fi + # Precompile condition. + eval "${CONDITION}" && CONDITION=true || CONDITION=false + +# if ! ${CONDITION}; then +# continue +# fi + [[ $CONDITION == true ]] && "$3_prompt_segment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" +} + +################################################################ +# Prompt Segment Definitions +################################################################ + +# The `CURRENT_BG` variable is used to remember what the last BG color used was +# when building the left-hand prompt. Because the RPROMPT is created from +# right-left but reads the opposite, this isn't necessary for the other side. +CURRENT_BG='NONE' + +################################################################ +# The 'custom` prompt provides a way for users to invoke commands and display +# the output in a segment. +prompt_custom() { + local command=POWERLEVEL9K_CUSTOM_$4:u + local segment_content="$(eval ${(P)command})" + + if [[ -n $segment_content ]]; then + serialize_segment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + fi +} + +################################################################ +# Prompt processing and drawing +################################################################ +# Main prompt +build_left_prompt() { + local index=1 + local element joined + for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do + # Check if segment should be joined + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false + + # Remove joined information in direct calls + element="${element%_joined}" + + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "left" "$index" $joined $element[8,-1] + else + "prompt_$element" "left" "$index" $joined + fi + + index=$((index + 1)) + done + + left_prompt_end +} + +# Right prompt +build_right_prompt() { + local index=1 + local joined + for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do + # Check if segment should be joined + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false + + # Remove joined information in direct calls + element="${element%_joined}" + + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "right" "$index" $joined $element[8,-1] + else + "prompt_$element" "right" "$index" $joined + fi + + index=$((index + 1)) + done +} + +powerlevel9k_preexec() { + _P9K_TIMER_START=$EPOCHREALTIME +} + +set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +powerlevel9k_prepare_prompts() { + RETVAL=$? + RETVALS=( "$pipestatus[@]" ) + + _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + + # Reset start time + _P9K_TIMER_START=0x7FFFFFFF + + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) +$(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' + if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then + # The right prompt should be on the same line as the first line of the left + # prompt. To do so, there is just a quite ugly workaround: Before zsh draws + # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we + # advise it to go one line down. See: + # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 + local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters + RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up + RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down + else + RPROMPT_PREFIX='' + RPROMPT_SUFFIX='' + fi + else + PROMPT='%f%b%k$(build_left_prompt)' + RPROMPT_PREFIX='' + RPROMPT_SUFFIX='' + fi + + if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then + RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' + fi + +NEWLINE=' +' + + if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + NEWLINES="" + repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } + PROMPT="$NEWLINES$PROMPT" + fi + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" +} + +set_default POWERLEVEL9K_IGNORE_TERM_COLORS false +set_default POWERLEVEL9K_IGNORE_TERM_LANG false + +prompt_powerlevel9k_setup() { + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) + + # Disable false display of command execution time + _P9K_TIMER_START=0x7FFFFFFF + + # The prompt function will set these prompt_* options after the setup function + # returns. We need prompt_subst so we can safely run commands in the prompt + # without them being double expanded and we need prompt_percent to expand the + # common percent escape sequences. + prompt_opts=(cr percent sp subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" + + # Display a warning if the terminal does not support 256 colors + termColors + + # If the terminal `LANG` is set to `C`, this theme will not work at all. + if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + local term_lang + term_lang=$(echo $LANG) + if [[ $term_lang == 'C' ]]; then + print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" + print -P "\t%F{red}WARNING!%f Please set your 'LANG' to a UTF-8 language, like 'en_US.UTF-8'" + print -P "\t%F{red}WARNING!%f _before_ loading this theme in your \~\.zshrc. Putting" + print -P "\t%F{red}WARNING!%f %F{blue}export LANG=\"en_US.UTF-8\"%f at the top of your \~\/.zshrc is sufficient." + fi + fi + + defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) + defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) + + # Display a warning if deprecated segments are in use. + typeset -AH deprecated_segments + # old => new + deprecated_segments=( + 'longstatus' 'status' + ) + print_deprecation_warning deprecated_segments + + # initialize colors + autoload -U colors && colors + + # initialize timing functions + zmodload zsh/datetime + + # Initialize math functions + zmodload zsh/mathfunc + + # initialize hooks + autoload -Uz add-zsh-hook + + # prepare prompts + add-zsh-hook precmd powerlevel9k_prepare_prompts + add-zsh-hook preexec powerlevel9k_preexec +} + +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROMPT= +} diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k new file mode 100644 index 000000000..3c8fd03cc --- /dev/null +++ b/generator/zsh-async.p9k @@ -0,0 +1,683 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# @title powerlevel9k ZSH-Async Engine +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +# Christo Kotze (onaforeignshore) +## +# @dependency +# [zsh-async](https://github.com/mafredri/zsh-async) +## +# @info +# This file contains an async generator for the powerlevel9k +# project. It makes use of zsh-async in order to build the +# prompts asynchronously. +## + +# Please note that this is A WORK IN PROGRESS, so use at your own risk! + +# Debugging +#ASYNC_DEBUG=1 + +################################################################ +# Prompt Segment Constructors +################################################################ + +############################################################### +# @description +# Spawn a subshell to convert the data into a left prompt segment +## +# @arg +# $1 string Name - The stateful name of the function that was originally invoked (mandatory). +# $2 integer Index - Segment array index +# $3 string Background - Segment background color +# $4 string Foreground - Segment foreground color +# $5 boolean Bold - Whether the segment should be bold +# $6 string Content - Segment content +# $7 string Visual Identifier - Segment icon +## +POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " +left_prompt_segment() { + # Name the parameters and add %K and %F to color variables + local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" BOLD="${5}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" + # Check if it should be bold + [[ ${BOLD} == "true" ]] && local BD="%B" || local BD="" + # Set the colors + local SEGMENT="${BG}${FG}" + # Add the visual identifier if it exists + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}" + # Add the content + if [[ -n ${CONTENT} ]]; then + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" + [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b" || SEGMENT+="${CONTENT}" + fi + # Return the result to the main process, delimited by "·|·" + [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" +} + +############################################################### +# @description +# Spawn a subshell to convert the data into a right prompt segment +## +# @arg +# $1 string Name - The stateful name of the function that was originally invoked (mandatory). +# $2 integer Index - Segment array index +# $3 string Background - Segment background color +# $4 string Foreground - Segment foreground color +# $5 boolean Bold - Whether the segment should be bold +# $6 string Content - Segment content +# $7 string Visual Identifier - Segment icon +## +POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " +right_prompt_segment() { + # Name the parameters and add %K and %F to color variables + local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" + # Check if it should be bold + [[ ${BOLD} == "true" ]] && local BD="%B" || local BD="" + # Set the colors + local SEGMENT="${BG}${FG}" + if [[ ${(L)POWERLEVEL9K_RPROMPT_ICON_LEFT} == "true" ]]; then # Visual identifier before content + # Add the visual identifier if it exists + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + # Add the content + [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b" || SEGMENT+="${CONTENT}" + else # Content before visual identifier + # Add the content + SEGMENT+="${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b${BG}${FG}" || SEGMENT+="${CONTENT}" + # Add the visual identifier if it exists + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + fi + # Return the result to the main process, delimited by "·|·" + [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" +} + +############################################################### +# @description +# This function determines the background of the previous VISIBLE segment in the left prompt. +## +# @arg +# $1 integer Index - Left prompt source segment index +## +last_left_bg() { + # Name the parameters + local CURRENT_INDEX="${1}" LAST_BG=0 + # Start at the segment before the current segment and work to the left + for (( i = ${CURRENT_INDEX} - 1; i > 0; i-- )); do + # If the segment is not empty, we have our color + if [[ ${P9K_LP_CONTENT[$i]} != "·" ]]; then + local LAST_BG="${P9K_LP_BACKGROUND[$i]}" + break + fi + done + echo "$LAST_BG" +} + +############################################################### +# @description +# This function determines the background of the previous VISIBLE segment in the right prompt. +## +# @arg +# $1 integer Index - Right prompt source segment index +## +last_right_bg() { + # Name the parameters + local CURRENT_INDEX="${1}" LAST_BG=0 + # Start at the segment before the current segment and work to the left + for (( i = ${CURRENT_INDEX} - 1; i > 0; i-- )); do + # If the segment is not empty, we have our color + if [[ ${P9K_RP_CONTENT[$i]} != "·" ]]; then + local LAST_BG="${P9K_RP_BACKGROUND[$i]}" + break + fi + done + echo "$LAST_BG" +} + +update_left_prompt() { + local LBG LAST_LBG LSEGMENTS + # Determine how many segments are visible in the left prompt + LSEGMENTS=${#P9K_LP_CONTENT} + # Build the left prompt string + LEFT_PROMPT="" + for (( i = 1; i <= ${LSEGMENTS}; i++ )); do + if [[ "${P9K_LP_CONTENT[$i]}" != "·" ]]; then + LBG=${P9K_LP_BACKGROUND[$i]} + LFG=${P9K_LP_FOREGROUND[$i]} + if [[ $i != 1 ]]; then # If it is not the first segment... + # Find previous left segment background + LAST_LBG=$(last_left_bg $i) + if [[ $P9K_LP_JOINED[$i] == "false" ]]; then # If the segment are not joined... + if [[ "${LBG}" == "${LAST_LBG}" ]]; then # Are the backgrounds the same... + # We take the current foreground color as color for our subsegment, and + # add a left sub segment separator. This should have enough contrast. + LEFT_PROMPT+="%K{${LBG}}%F{${LFG}}${_POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR} " + else + # Add a left segment separator + LEFT_PROMPT+="%K{${LBG}}%F{${LAST_LBG}}${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR} " + fi + fi + else # ...otherwise it is the first segment and there is no previous background + [[ "${POWERLEVEL9K_FANCY_EDGE}" == "true" ]] && LEFT_PROMPT+="%F{${LBG}}${_POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR}" + LEFT_PROMPT+="%K{${LBG}} " + fi + # Add the segment to the left prompt string + LEFT_PROMPT+="${P9K_LP_CONTENT[$i]} " + fi + done + # Prompt is complete, so find the background of the last segment + local LBI=$((${#P9K_LP_CONTENT} + 1)) + LBG=$(last_left_bg ${LBI}) + # Add the last left segment separator and the suffix + LEFT_PROMPT+="%F{${LBG}}%k${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR}%f%b " + # Set the left prompt + PROMPT=${LEFT_PROMPT_PREFIX}${LEFT_PROMPT}${LEFT_PROMPT_SUFFIX} + # About .reset-prompt see: + # https://github.com/sorin-ionescu/prezto/issues/1026 + # https://github.com/zsh-users/zsh-autosuggestions/issues/107#issuecomment-183824034 + zle .reset-prompt +} + +update_right_prompt() { + local RBG LAST_RBG RSEGMENTS + # Determine how many segments are visible in the left prompt + RSEGMENTS=${#P9K_RP_CONTENT} + # Build the left prompt string + RIGHT_PROMPT="" + for (( i = 1; i <= ${RSEGMENTS}; i++ )); do + if [[ "${P9K_RP_CONTENT[$i]}" != "·" ]]; then + RBG=${P9K_RP_BACKGROUND[$i]} + RFG=${P9K_RP_FOREGROUND[$i]} + # Find previous right segment background + LAST_RBG=$(last_right_bg $i) + # Should the segment not be joined? + if [[ $P9K_RP_JOINED[$i] == "false" ]]; then + # Are the backgrounds the same... + if [[ "${RBG}" == "${LAST_RBG}" ]]; then + # We take the current foreground color as color for our subsegment, + # and add a sub segment separator. This should have enough contrast. + RIGHT_PROMPT+="%K{${RBG}}%F{${RFG}}${_POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR}" + else + # ...otherwise add a right segment separator + RIGHT_PROMPT+="%K{${LAST_RBG}}%F{${RBG}}${_POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR}" + fi + fi + # Add the segment to the right prompt string + RIGHT_PROMPT+="${P9K_RP_CONTENT[$i]} " + fi + done + [[ "${POWERLEVEL9K_FANCY_EDGE}" == "true" ]] && RIGHT_PROMPT+="%k%F{$RBG}${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR}%f" + # Set the left prompt + RPROMPT=${RIGHT_PROMPT_PREFIX}${RIGHT_PROMPT}${RIGHT_PROMPT_SUFFIX} + # About .reset-prompt see: + # https://github.com/sorin-ionescu/prezto/issues/1026 + # https://github.com/zsh-users/zsh-autosuggestions/issues/107#issuecomment-183824034 + zle .reset-prompt +} + +################################################################ +# Async functions +################################################################ + +############################################################### +# @description +# This function is the heart of the async engine. Whenever a +# subshell is completed, this function is called to deal with +# the generated output. +## +# @arg +# $1 string Job - The name of the calling function or job +# $2 number Code - Return code (If the value is -1, then it is likely that there is a bug) +# $3 string Output - Resulting (stdout) output from the job +# $4 number Exec_Time - Execution time, floating point (in seconds) +# $5 string Err - Resulting (stderr) output from the job +## +p9k_async_callback() { + # Name the parameters (CODE, EXEC_TIME and ERR are not currently used, but are included for possible future use) + local JOB="${1}" CODE="${2}" OUTPUT="${3}" EXEC_TIME="${4}" ERR="${5}" + + # Determine which function returned output... + case $JOB in + p9k_serialize_segment) # Segment code was converted into data + # Make sure we received the data + if [[ -n $OUTPUT ]]; then + # split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 + #local ar=("${(@f)OUTPUT}") # split on newline (@f) + local ar=("${(@s:·|·:)OUTPUT}") # split on delimiter "·|·" (@s::) + # Name the parameters + local STATEFUL_NAME=${ar[1]} ALIGNMENT=${(L)ar[2]} INDEX=${ar[3]} JOINED=${ar[4]} BACKGROUND=${ar[5]} FOREGROUND=${ar[6]} BOLD=${ar[7]} CONTENT=${ar[8]} VISUAL_IDENTIFIER=${ar[9]} CONDITION=${ar[10]} + + # If $INDEX is not a number, then don't process the output + # See: https://www.zsh.org/mla/users/2007/msg00086.html + [[ ${INDEX} != <-> ]] && break + + # Conditions have three layers: + # 1. No segment should print if they provide no content (default condition). + # 2. Segments can define a default condition on their own, overriding the previous one. + # 3. Users can set a condition for each segment. This is the trump card, and has highest precedence. + local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" + if defined "${SEGMENT_CONDITION}"; then + CONDITION="${(P)SEGMENT_CONDITION}" + elif [[ -n "${CONDITION}" && "$CONDITION[0,1]" == "[" ]]; then + CONDITION="${CONDITION}" + else + CONDITION='[[ -n "${CONTENT}" ]]' + fi + # Compile the condition to determine if we should process this segment or not. + eval "${CONDITION}" && CONDITION=true || CONDITION=false + + if [[ ${CONDITION} == true ]]; then # If the segments condition to print was met, add it... + if [[ "${ALIGNMENT}" == "left" ]]; then # If it is a left prompt segment... + # Store the background, foreground and joined states in separate arrays + P9K_LP_BACKGROUND[$INDEX]="${BACKGROUND}" + P9K_LP_FOREGROUND[$INDEX]="${FOREGROUND}" + P9K_LP_JOINED[$INDEX]="${JOINED}" + # Send the data to a subshell to be converted into a left prompt segment + async_job "p9k" left_prompt_segment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + else # ...it is a right prompt segment + # Store the background, foreground and joined states in separate arrays + P9K_RP_BACKGROUND[$INDEX]="${BACKGROUND}" + P9K_RP_FOREGROUND[$INDEX]="${FOREGROUND}" + P9K_RP_JOINED[$INDEX]="${JOINED}" + # Send the data to a subshell to be converted into a left prompt segment + async_job "p9k" right_prompt_segment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + fi + else # ...otherwise set the prompt content array to "·" (no segemnt) + [[ "${ALIGNMENT}" == "left" ]] && P9K_LP_CONTENT[${INDEX}]="·" || P9K_RP_CONTENT[${INDEX}]="·" + fi + fi + ;; + left_prompt_segment) # Data was converted into a left prompt segment + # Make sure we received the segment data + if [[ -n $OUTPUT ]]; then + # Split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 + local ar=("${(@s:·|·:)OUTPUT}") # split on delimiter "·|·" + + # If $ar[1] (the index) is a number, then store the segment in the left prompt contents array + # See: https://www.zsh.org/mla/users/2007/msg00086.html + [[ ${ar[1]} == <-> ]] && P9K_LP_CONTENT[${ar[1]}]="${ar[2]}" + # Update the left prompt + update_left_prompt + fi + ;; + right_prompt_segment) # Data was converted into a right prompt segment + # Make sure we received the segment data + if [[ -n $OUTPUT ]]; then + # Split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 + #local ar=("${(@f)output}") # split on newline + local ar=("${(@s:·|·:)OUTPUT}") # split on delimiter "·|·" + + # If $ar[1] (the index) is a number, then store the segment in the right prompt contents array + # See: https://www.zsh.org/mla/users/2007/msg00086.html + [[ ${ar[1]} == <-> ]] && P9K_RP_CONTENT[${ar[1]}]="${ar[2]}" + # Update the right prompt + update_right_prompt + fi + ;; + esac +} + +################################################################ +# Caching functions +################################################################ + +############################################################### +# @description +# This function processes the segment code in a subshell. +# When done, the resulting data is sent to `p9k_async_callback`. +## +# @arg +# $1 string Name - Segment name +# $2 string State - Segment state +# $3 string Alignment - left|right +# $4 integer Index - Segment array index +# $5 boolean Joined - If the segment should be joined +# $6 string Background - Segment background color +# $7 string Foreground - Segment foreground color +# $8 string Content - Segment content +# $9 string Visual identifier - Segment icon +# $10 string Condition - The condition, if the segment should be printed (gets evaluated) +## +p9k_serialize_segment() { + local NAME="${(U)1}" STATE="${(U)2}" ALIGNMENT="${3}" INDEX="${4}" JOINED="${5}" CONTENT="${8}" CONDITION="${10}" + + ################################################################ + # Methodology behind user-defined variables overwriting colors: + # + # The first parameter to the segment constructors is the calling function's + # name. From this function name, we strip the "prompt_"-prefix and + # uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed + # with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable + # name. So each new segment is user-overwritten by a variable following + # this naming convention. + ## + + # Determine the stateful name of the segment + local STATEFUL_NAME="${NAME#PROMPT_}" + [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${STATE}" + + # Overwrite given background-color by user defined variable for this segment. + local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" + local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" + [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" + + # Overwrite given foreground-color by user defined variable for this segment. + local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" + local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" + [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" + + # Overwrite given bold directive by user defined variable for this segment. + local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" + local BOLD="${(P)BOLD_USER_VARIABLE}" + [[ -z "${BOLD}" ]] && BOLD="false" || BOLD="true" + + # Precompile the Visual Identifier with color and spacing + local VISUAL_IDENTIFIER + if [[ -n "${9}" ]]; then + VISUAL_IDENTIFIER="$(print_icon ${9})" + if [[ -n "${VISUAL_IDENTIFIER}" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + local visual_identifier_color="${(P)visual_identifier_color_variable}" + # only add color to icon if override color is set and not equal to foreground + if [[ -n "${visual_identifier_color}" && "${visual_identifier_color}" != "${FOREGROUND}" ]]; then + VISUAL_IDENTIFIER="%F{${visual_identifier_color}}${VISUAL_IDENTIFIER}%F{${FOREGROUND}}" + fi + # Add an whitespace if we print more than just the visual identifier + if [[ -n "${CONTENT}" ]]; then + [[ "${POWERLEVEL9K_RPROMPT_ICON_LEFT}" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " || + [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" + fi + fi + fi + # Return the data to the main process, delimited with "·|·" + echo "$STATEFUL_NAME·|·$ALIGNMENT·|·$INDEX·|·$JOINED·|·$BACKGROUND·|·$FOREGROUND·|·$BOLD·|·$CONTENT·|·$VISUAL_IDENTIFIER·|·$CONDITION" +} + +############################################################### +# @description +# This function is a wrapper function that starts off the async +# process and passes the parameters from the segment code to the +# subshells. +## +# @arg +# $@ misc The parameters passed from the segment code +## +serialize_segment() { + (async_job "p9k" "p9k_serialize_segment" "${@}") +} + +################################################################ +# Prompt processing and drawing +################################################################ + +################################################################ +# The 'custom` prompt provides a way for users to invoke commands and display +# the output in a segment. +prompt_custom() { + local command=POWERLEVEL9K_CUSTOM_$4:u + local segment_content="$(eval ${(P)command})" + + if [[ -n $segment_content ]]; then + serialize_segment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + fi +} + +############################################################### +# @description +# This function loops through the left prompt elements and calls +# the related segment functions. +## +# @noarg +## +build_left_prompt() { + local index=1 + local joined + for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do + # Check if segment should be joined + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false + + # Remove joined information in direct calls + element="${element%_joined}" + + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "left" "${index}" "${element[8,-1]}" "${joined}" &! + else + # Could we display placeholders? + # -> At most it could be static ones, but + # e.g. states are the result of calculation.. + "prompt_$element" "left" "${index}" "${joined}" &! + fi + index=$((index + 1)) + done +} + +############################################################### +# @description +# This function loops through the right prompt elements and calls +# the related segment functions. +## +# @noarg +## +build_right_prompt() { + local index=1 + local joined + for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do + # Check if segment should be joined + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false + + # Remove joined information in direct calls + element="${element%_joined}" + + # Check if it is a custom command, otherwise interpet it as + # a prompt. + if [[ $element[0,7] =~ "custom_" ]]; then + "prompt_custom" "right" "$index" $joined "${element[8,-1]}" &! + else + "prompt_$element" "right" "$index" "${joined}" &! + fi + index=$((index + 1)) + done +} + +############################################################### +# @description +# This function is a hook that runs before the command runs. +# It sets the start timer. +## +# @noarg +## +powerlevel9k_preexec() { + # The Timer is started here, but the end + # is taken in powerlevel_prepare_prompts, + # as this method is a precmd hook and runs + # right before the prompt gets rendered. So + # we can calculate the duration there. + _P9K_TIMER_START=${EPOCHREALTIME} +} + +############################################################### +# @description +# This function is a hook that is run before the prompts are created. +# If sets all the required variables for the prompts and then +# calls the prompt segment building functions. +## +# @noarg +## +powerlevel9k_prepare_prompts() { + setopt localoptions noshwordsplit + + # stop any running async jobs + async_flush_jobs "p9k" + + # Arrays to hold the left and right prompt segment data + if [[ ${#P9K_LP_CONTENT} -ne ${#P9K_LP_ELEMENTS} ]]; then + P9K_LP_CONTENT=() + P9K_LP_BACKGROUND=() + P9K_LP_FOREGROUND=() + P9K_LP_JOINED=() + fi + if [[ ${#P9K_RP_CONTENT} -ne ${#P9K_RP_ELEMENTS} ]]; then + P9K_RP_CONTENT=() + P9K_RP_BACKGROUND=() + P9K_RP_FOREGROUND=() + P9K_RP_JOINED=() + fi + + # Timing calculation + _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + # Reset start time - Maximum integer on 32-bit CPUs + [[ "$ARCH" == "x64" ]] && _P9K_TIMER_START=99999999999 || _P9K_TIMER_START=2147483647 + # I decided to use the value above for better supporting 32-bit CPUs, since the previous value "99999999999" was + # causing issues on my Android phone, which is powered by an armv7l + # We don't have to change that until 19 January of 2038! :) + + # Reset the prompts + PROMPT="" + RPROMPT="" + LEFT_PROMPT_PREFIX="" + LEFT_PROMPT_SUFFIX="" + RIGHT_PROMPT_PREFIX="" + RIGHT_PROMPT_SUFFIX="" + + # The prompt function will set these prompt_* options after the setup function + # returns. We need prompt_subst so we can safely run commands in the prompt + # without them being double expanded and we need prompt_percent to expand the + # common percent escape sequences. + prompt_opts=(cr percent subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" + + local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters + + # Preset multiline prompt + if [[ "${POWERLEVEL9K_PROMPT_ON_NEWLINE}" == true ]]; then + LEFT_PROMPT_PREFIX="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" + LEFT_PROMPT_SUFFIX=" +$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" + if [[ "${POWERLEVEL9K_RPROMPT_ON_NEWLINE}" != true ]]; then + # The right prompt should be on the same line as the first line of the left + # prompt. To do so, there is just a quite ugly workaround: Before zsh draws + # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we + # advise it to go one line down. See: + # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 + RIGHT_PROMPT_PREFIX='%{'$'\e[1A''%}' # one line up + RIGHT_PROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down + fi + fi + + # Precompile the Segment Separators here! + _POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR="$(print_icon 'LEFT_SEGMENT_SEPARATOR')" + _POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR="$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')" + _POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR="$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" + _POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR="$(print_icon 'RIGHT_SEGMENT_SEPARATOR')" + _POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR="$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')" + + # Call the prompt building functions + build_left_prompt + if [[ "${(L)POWERLEVEL9K_DISABLE_RPROMPT}" != "true" ]]; then + build_right_prompt + fi +} + +p9k_chpwd() { + powerlevel9k_prepare_prompts + powerlevel9k_preexec +} + +############################################################### +# @description +# This is the main function. It does the necessary checks, +# loads the required resources and sets the required hooks. +## +# @noarg +## +prompt_powerlevel9k_setup() { + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) + + # Disable false display of command execution time + _P9K_TIMER_START=0x7FFFFFFF + + # The prompt function will set these prompt_* options after the setup function + # returns. We need prompt_subst so we can safely run commands in the prompt + # without them being double expanded and we need prompt_percent to expand the + # common percent escape sequences. + prompt_opts=(cr percent sp subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" + + # Display a warning if the terminal does not support 256 colors + termColors + + # If the terminal `LANG` is set to `C`, this theme will not work at all. + if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + local term_lang + term_lang=$(echo $LANG) + if [[ $term_lang == 'C' ]]; then + print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" + print -P "\t%F{red}WARNING!%f Please set your 'LANG' to a UTF-8 language, like 'en_US.UTF-8'" + print -P "\t%F{red}WARNING!%f _before_ loading this theme in your \~\.zshrc. Putting" + print -P "\t%F{red}WARNING!%f %F{blue}export LANG=\"en_US.UTF-8\"%f at the top of your \~\/.zshrc is sufficient." + fi + fi + + defined P9K_LP_ELEMENTS || P9K_LP_ELEMENTS=(context dir rbenv vcs) + defined P9K_RP_ELEMENTS || P9K_RP_ELEMENTS=(status root_indicator background_jobs history time) + + # Display a warning if deprecated segments are in use. + typeset -AH deprecated_segments + # old => new + deprecated_segments=( + 'longstatus' 'status' + ) + print_deprecation_warning deprecated_segments + + # initialize colors + autoload -U colors && colors + + # initialize timing functions + zmodload zsh/datetime + + # Initialize math functions + zmodload zsh/mathfunc + + # initialize hooks + autoload -Uz add-zsh-hook + + # initialize prompt arrays + declare -A P9K_LP_CONTENT + declare -A P9K_RP_CONTENT + + # initialize zsh async + #autoload -Uz async && async + source $p9k_directory/zsh-async/async.zsh + + # initialize async worker + (( !${p9k_async_init:-0} )) && { + async_start_worker "p9k" -n + async_register_callback "p9k" "p9k_async_callback" + p9k_async_init=1 + } + + # prepare prompts + add-zsh-hook precmd powerlevel9k_prepare_prompts + add-zsh-hook preexec powerlevel9k_preexec + + # initialize zle + zle + + # hook into chpwd for bindkey support + chpwd_functions=(${chpwd_functions[@]} "p9k_chpwd") +} diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9980d1b28..79124bc50 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -61,12 +61,6 @@ source "${p9k_directory}/functions/utilities.zsh" source "${p9k_directory}/functions/colors.zsh" -################################################################ -# Source VCS_INFO hooks / helper functions -################################################################ - -source "${p9k_directory}/functions/vcs.zsh" - ################################################################ # Color Scheme ################################################################ @@ -80,485 +74,33 @@ else fi ################################################################ -# Prompt Segment Constructors -# -# Methodology behind user-defined variables overwriting colors: -# The first parameter to the segment constructors is the calling function's -# name. From this function name, we strip the "prompt_"-prefix and -# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed -# with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable -# name. So each new segment is user-overwritten by a variable following -# this naming convention. +# Load Prompt Segment Definitions ################################################################ -# The `CURRENT_BG` variable is used to remember what the last BG color used was -# when building the left-hand prompt. Because the RPROMPT is created from -# right-left but reads the opposite, this isn't necessary for the other side. -CURRENT_BG='NONE' - -# Begin a left prompt segment -# Takes four arguments: -# * $1: Name of the function that was originally invoked (mandatory). -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: The array index of the current segment -# * $3: Background color -# * $4: Foreground color -# * $5: The segment content -# * $6: An identifying icon (must be a key of the icons array) -# The latter three can be omitted, -set_default last_left_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " -left_prompt_segment() { - local current_index=$2 - # Check if the segment should be joined with the previous one - local joined - segmentShouldBeJoined $current_index $last_left_element_index "$POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false - - # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND - local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} - [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" - - # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND - local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} - [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" - - local bg fg - [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" - [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" - - if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then - echo -n "$bg%F{$CURRENT_BG}" - if [[ $joined == false ]]; then - # Middle segment - echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - elif isSameColor "$CURRENT_BG" "$3"; then - # Middle segment with same color as previous segment - # We take the current foreground color as color for our - # subsegment (or the default color). This should have - # enough contrast. - local complement - [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" - echo -n "${bg}${complement}" - if [[ $joined == false ]]; then - echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - else - # First segment - echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - - local visual_identifier - if [[ -n $6 ]]; then - visual_identifier="$(print_icon $6)" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier="$visual_identifier " - fi - fi - - # Print the visual identifier - echo -n "${visual_identifier}" - # Print the content of the segment, if there is any - [[ -n "$5" ]] && echo -n "${fg}${5}" - echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" - - CURRENT_BG=$3 - last_left_element_index=$current_index -} - -# End the left prompt, closes the final segment. -left_prompt_end() { - if [[ -n $CURRENT_BG ]]; then - echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" - else - echo -n "%k" - fi - echo -n "%f$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" - CURRENT_BG='' -} - -CURRENT_RIGHT_BG='NONE' - -# Begin a right prompt segment -# Takes four arguments: -# * $1: Name of the function that was originally invoked (mandatory). -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: The array index of the current segment -# * $3: Background color -# * $4: Foreground color -# * $5: The segment content -# * $6: An identifying icon (must be a key of the icons array) -# No ending for the right prompt segment is needed (unlike the left prompt, above). -set_default last_right_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " -right_prompt_segment() { - local current_index=$2 - - # Check if the segment should be joined with the previous one - local joined - segmentShouldBeJoined $current_index $last_right_element_index "$POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false - - # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND - local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} - [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" - - # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND - local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} - [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" - - local bg fg - [[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)" - [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" - - # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. - if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then - if isSameColor "$CURRENT_RIGHT_BG" "$3"; then - # Middle segment with same color as previous segment - # We take the current foreground color as color for our - # subsegment (or the default color). This should have - # enough contrast. - local complement - [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" - echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" - else - # Use the new BG color for the foreground with separator - echo -n "$(foregroundColor $3)$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f" - fi - fi - - local visual_identifier - if [[ -n "$6" ]]; then - visual_identifier="$(print_icon $6)" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier=" $visual_identifier" - fi - fi - - echo -n "${bg}${fg}" - - # Print whitespace only if segment is not joined or first right segment - [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" - - # Print segment content if there is any - [[ -n "$5" ]] && echo -n "${5}" - # Print the visual identifier - echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" - - CURRENT_RIGHT_BG=$3 - last_right_element_index=$current_index -} - -############################################################### -# This function wraps left_prompt_segment and right_prompt_segment to serializes a segment (for compatibility with the async branch) -# -# Parameters for serialize_segment: -# * $1 Name: string - Name of the segment -# * $2 State: string - The state the segment is in -# * $3 Alignment: string - left|right -# * $4 Index: integer -# * $5 Joined: bool - If the segment should be joined -# * $6 Background: string - The default background color of the segment -# * $7 Foreground: string - The default foreground color of the segment -# * $8 Content: string - Content of the segment -# * $9 Visual identifier: string - Icon of the segment -# * $10 Condition: string - The condition, if the segment should be printed (gets evaluated) -# -# Parameters for [left|right]_prompt_segment: -# * $1: Name of the function that was originally invoked (mandatory). -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: The array index of the current segment -# * $3: Background color -# * $4: Foreground color -# * $5: Bold -# * $6: The segment content -# * $7: An identifying icon (must be a key of the icons array) -# The latter three can be omitted, -serialize_segment() { - local NAME="${1}" - local STATE="${2}" - local ALIGNMENT="${3}" - local INDEX="${4}" - local JOINED="${5}" - - local STATEFUL_NAME="${(U)NAME#prompt_}" - [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${(U)STATE}" - - # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" - local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" - [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" - - # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" - local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" - [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" - - # Overwrite given bold directive by user defined variable for this segment. - local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" - local BOLD="${(P)BOLD_USER_VARIABLE}" - [[ -z "${BOLD}" ]] && BOLD=false - - local CONTENT="${8}" - - local VISUAL_IDENTIFIER - if [[ -n "${9}" ]]; then - VISUAL_IDENTIFIER="$(print_icon ${9})" - if [[ -n "${VISUAL_IDENTIFIER}" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" - set_default "${visual_identifier_color_variable}" "${FOREGROUND}" - VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" - # Add an whitespace if we print more than just the visual identifier - if [[ -n "${CONTENT}" ]]; then - [[ "${ALIGNMENT}" == "left" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " - [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" - fi - fi +# load only the segments that are being used! +local segment_name +for segment in $p9k_directory/segments/**/*.p9k; do + segment_name=${${segment##*/}%.p9k} + if segment_in_use "$segment_name"; then + source "${segment}" fi - # Conditions have three layers: - # 1. All segments should not print - # a segment, if they provide no - # content (default condition). - # 2. All segments could define a - # default condition on their - # own, overriding the previous - # one. - # 3. Users could set a condition - # for each segment. This is - # the trump card, and has - # highest precedence. - local CONDITION - local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" - if defined "${SEGMENT_CONDITION}"; then - CONDITION="${(P)SEGMENT_CONDITION}" - elif [[ -n "${10}" ]]; then - CONDITION="${10}" - else - CONDITION='[[ -n "${8}" ]]' - fi - # Precompile condition. - eval "${CONDITION}" && CONDITION=true || CONDITION=false - -# if ! ${CONDITION}; then -# continue -# fi +done - "$3_prompt_segment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" "${CONDITION}" -} +# cleanup temporary variable +#unset p9k_directory ################################################################ -# Prompt Segment Definitions +# Choose the generator ################################################################ -# The `CURRENT_BG` variable is used to remember what the last BG color used was -# when building the left-hand prompt. Because the RPROMPT is created from -# right-left but reads the opposite, this isn't necessary for the other side. -CURRENT_BG='NONE' - -################################################################ -# The 'custom` prompt provides a way for users to invoke commands and display -# the output in a segment. -prompt_custom() { - local command=POWERLEVEL9K_CUSTOM_$3:u - local segment_content="$(eval ${(P)command})" - - if [[ -n $segment_content ]]; then - "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" - fi -} - -################################################################ -# Prompt processing and drawing -################################################################ -# Main prompt -build_left_prompt() { - local index=1 - local element - for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do - # Remove joined information in direct calls - element=${element%_joined} - - # Check if it is a custom command, otherwise interpet it as - # a prompt. - if [[ $element[0,7] =~ "custom_" ]]; then - "prompt_custom" "left" "$index" $element[8,-1] - else - "prompt_$element" "left" "$index" - fi - - index=$((index + 1)) - done - - left_prompt_end -} - -# Right prompt -build_right_prompt() { - local index=1 - for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do - # Remove joined information in direct calls - element=${element%_joined} - - # Check if it is a custom command, otherwise interpet it as - # a prompt. - if [[ $element[0,7] =~ "custom_" ]]; then - "prompt_custom" "right" "$index" $element[8,-1] - else - "prompt_$element" "right" "$index" - fi - - index=$((index + 1)) - done -} - -powerlevel9k_preexec() { - _P9K_TIMER_START=$EPOCHREALTIME -} - -set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false -powerlevel9k_prepare_prompts() { - RETVAL=$? - RETVALS=( "$pipestatus[@]" ) - - _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) - - # Reset start time - _P9K_TIMER_START=0x7FFFFFFF - - if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then - PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) -$(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' - if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then - # The right prompt should be on the same line as the first line of the left - # prompt. To do so, there is just a quite ugly workaround: Before zsh draws - # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we - # advise it to go one line down. See: - # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 - local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters - RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up - RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down - else - RPROMPT_PREFIX='' - RPROMPT_SUFFIX='' - fi - else - PROMPT='%f%b%k$(build_left_prompt)' - RPROMPT_PREFIX='' - RPROMPT_SUFFIX='' - fi - - if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then - RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' - fi - -NEWLINE=' -' - - if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then - NEWLINES="" - repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } - PROMPT="$NEWLINES$PROMPT" - fi - - # Allow iTerm integration to work - [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" -} - -set_default POWERLEVEL9K_IGNORE_TERM_COLORS false -set_default POWERLEVEL9K_IGNORE_TERM_LANG false - -prompt_powerlevel9k_setup() { - # The value below was set to better support 32-bit CPUs. - # It's the maximum _signed_ integer value on 32-bit CPUs. - # Please don't change it until 19 January of 2038. ;) - - # Disable false display of command execution time - _P9K_TIMER_START=0x7FFFFFFF - - # The prompt function will set these prompt_* options after the setup function - # returns. We need prompt_subst so we can safely run commands in the prompt - # without them being double expanded and we need prompt_percent to expand the - # common percent escape sequences. - prompt_opts=(cr percent sp subst) - - # Borrowed from promptinit, sets the prompt options in case the theme was - # not initialized via promptinit. - setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" - - # Display a warning if the terminal does not support 256 colors - termColors - - # If the terminal `LANG` is set to `C`, this theme will not work at all. - if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then - local term_lang - term_lang=$(echo $LANG) - if [[ $term_lang == 'C' ]]; then - print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" - print -P "\t%F{red}WARNING!%f Please set your 'LANG' to a UTF-8 language, like 'en_US.UTF-8'" - print -P "\t%F{red}WARNING!%f _before_ loading this theme in your \~\.zshrc. Putting" - print -P "\t%F{red}WARNING!%f %F{blue}export LANG=\"en_US.UTF-8\"%f at the top of your \~\/.zshrc is sufficient." - fi - fi - - defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) - defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) - - # Display a warning if deprecated segments are in use. - typeset -AH deprecated_segments - # old => new - deprecated_segments=( - 'longstatus' 'status' - ) - print_deprecation_warning deprecated_segments - - # initialize colors - autoload -U colors && colors - - # load only the segments that are being used! - local segment_name - for segment in $p9k_directory/segments/**/*.p9k; do - segment_name=${${segment##*/}%.p9k} - if segment_in_use "$segment_name"; then - source "${segment}" - fi - done - - # cleanup temporary variable - unset p9k_directory - - # initialize timing functions - zmodload zsh/datetime - - # Initialize math functions - zmodload zsh/mathfunc - - # initialize hooks - autoload -Uz add-zsh-hook - - # prepare prompts - add-zsh-hook precmd powerlevel9k_prepare_prompts - add-zsh-hook preexec powerlevel9k_preexec -} - -prompt_powerlevel9k_teardown() { - add-zsh-hook -D precmd powerlevel9k_\* - add-zsh-hook -D preexec powerlevel9k_\* - PROMPT='%m%# ' - RPROMPT= -} +case "${(L)POWERLEVEL9K_GENERATOR}" in + "zsh-async") + source "${p9k_directory}/generator/zsh-async.p9k" + ;; + *) + source "${p9k_directory}/generator/default.p9k" + ;; +esac +# Launch the generator prompt_powerlevel9k_setup "$@" diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index 8f3536a2d..2b8466da7 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -27,6 +27,6 @@ prompt_background_jobs() { if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then background_jobs_number_print="$background_jobs_number" fi - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' fi } diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index fbf174070..8ebb0fdc7 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -118,10 +118,10 @@ prompt_battery() { if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) local offset=$(( ($bat_percent / $segment) + 1 )) - "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi else # Draw the prompt_segment - "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi } diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index 8c74ccafb..c08c76a7a 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -42,6 +42,6 @@ prompt_command_execution_time() { fi if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - "$1_prompt_segment" "$0" "$2" "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + serialize_segment "$0" "" $1 "$2" $3 "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' fi } diff --git a/segments/core/context.p9k b/segments/core/context.p9k index 2ba53c762..47bcd3c2e 100644 --- a/segments/core/context.p9k +++ b/segments/core/context.p9k @@ -47,5 +47,5 @@ prompt_context() { current_state="SUDO" fi - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" + serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" } diff --git a/segments/core/date.p9k b/segments/core/date.p9k index a42d2da3b..e6e9db760 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -17,5 +17,5 @@ register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' prompt_date() { set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" } diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index 2560f5221..ba5e8e75d 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -277,5 +277,5 @@ prompt_dir() { current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} fi - "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" + serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" } diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index a50b120ff..b6014e901 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -16,6 +16,6 @@ register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AW # dir_writable: Display information about the user's permission to write in the current directory prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then - "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "yellow1" "" 'LOCK_ICON' + serialize_segment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' fi } diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index 956954929..2f3a3c1d8 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -52,6 +52,6 @@ prompt_disk_usage() { # Draw the prompt_segment if [[ -n $disk_usage ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' + serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' fi } diff --git a/segments/core/history.p9k b/segments/core/history.p9k index c4bd06b10..bc703b781 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -15,5 +15,5 @@ register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' ################################################################ # Command number (in local history) prompt_history() { - "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' + serialize_segment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' } diff --git a/segments/core/host.p9k b/segments/core/host.p9k index bc4e8dc6c..936ddc7e7 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -37,5 +37,5 @@ prompt_host() { "VISUAL_IDENTIFIER" "HOST_ICON" ) fi - "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" + serialize_segment "$0" "${(U)host_state[STATE]}" $1 "$2" $3 "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" } diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index 347a52ede..36059ce01 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -41,5 +41,5 @@ prompt_ip() { fi fi - "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' + serialize_segment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' } diff --git a/segments/core/load.p9k b/segments/core/load.p9k index 0cacc3c2d..2445797c1 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -66,5 +66,5 @@ prompt_load() { current_state="normal" fi - "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' + serialize_segment "$0" "${current_state}" $1 "$2" $3 "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' } diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index 90dbf7386..1d5c1774a 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -124,5 +124,5 @@ esac ################################################################ # Segment to print a little OS icon prompt_os_icon() { - "$1_prompt_segment" "$0" "$2" "black" "white" $(print_icon "$OS_ICON") + serialize_segment "$0" "" $1 "$2" $3 "black" "white" $(print_icon "$OS_ICON") } diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 810d0c31c..80d0af5ac 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -90,6 +90,6 @@ prompt_public_ip() { break done fi - $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" fi } diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index 28a9df3ba..0ed721874 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -33,5 +33,5 @@ prompt_ram() { fi fi - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' + serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index 5bbc3b21b..78938136d 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -16,6 +16,6 @@ register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OC # Segment to print an icon if user is root. prompt_root_indicator() { if [[ "$UID" -eq 0 ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' fi } diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index e52e826df..c8553fb48 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -16,6 +16,6 @@ register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' # Segment to display SSH icon when connected prompt_ssh() { if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' fi } diff --git a/segments/core/status.p9k b/segments/core/status.p9k index 1271de266..bf1634e4c 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -63,11 +63,11 @@ prompt_status() { if (( ec_sum > 0 )); then if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + serialize_segment "$0" "ERROR" $1 "$2" $3 "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' else - "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + serialize_segment "$0" "ERROR" $1 "$2" $3 "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' + serialize_segment "$0" "OK" $1 "$2" $3 "$DEFAULT_COLOR" "green" "" 'OK_ICON' fi } diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index 23ea9513b..adf6b01bf 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -35,5 +35,5 @@ prompt_swap() { base='K' fi - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' + serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' } diff --git a/segments/core/test_stats.p9k b/segments/core/test_stats.p9k deleted file mode 100644 index 3122a2b04..000000000 --- a/segments/core/test_stats.p9k +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env zsh -# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -################################################################ -# Show a ratio of tests vs code -build_test_stats() { - local code_amount="$4" - local tests_amount="$5"+0.00001 - local headline="$6" - - # Set float precision to 2 digits: - typeset -F 2 ratio - local ratio=$(( (tests_amount/code_amount) * 100 )) - - (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" -} diff --git a/segments/core/time.p9k b/segments/core/time.p9k index 5c382f1ef..7b1c02725 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -17,5 +17,5 @@ register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' prompt_time() { set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" } diff --git a/segments/core/user.p9k b/segments/core/user.p9k index 1308e2999..d35bd1c24 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -49,6 +49,6 @@ prompt_user() { "VISUAL_IDENTIFIER" "USER_ICON" ) fi - "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + serialize_segment "$0" ${(U)user_state[STATE]} $1 "$2" $3 "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" fi } diff --git a/segments/core/vi_mode.p9k b/segments/core/vi_mode.p9k index 5cd5403da..f918eb68a 100644 --- a/segments/core/vi_mode.p9k +++ b/segments/core/vi_mode.p9k @@ -15,11 +15,11 @@ set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" prompt_vi_mode() { case ${KEYMAP} in vicmd) - "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + serialize_segment "$0" "NORMAL" $1 "$2" $3 "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" ;; main|viins|*) if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi - "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" + serialize_segment "$0" "INSERT" $1 "$2" $3 "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" ;; esac } diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index 0d33bc5f9..99e684ff9 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -20,6 +20,6 @@ prompt_vpn_ip() { for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) do ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) - "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + serialize_segment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' done } diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index da895fc9e..c1bf08760 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -25,6 +25,6 @@ prompt_anaconda() { # variant works even if both are set. _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' + serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' fi } diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index 361565aee..d6bb3f562 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -18,6 +18,6 @@ prompt_aws() { local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" if [[ -n "$aws_profile" ]]; then - "$1_prompt_segment" "$0" "$2" red white "$aws_profile" 'AWS_ICON' + serialize_segment "$0" "" $1 "$2" $3 red white "$aws_profile" 'AWS_ICON' fi } diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index 8ac238d55..d6b90199f 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -18,6 +18,6 @@ prompt_aws_eb_env() { local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') if [[ -n "$eb_env" ]]; then - "$1_prompt_segment" "$0" "$2" black green "$eb_env" 'AWS_EB_ICON' + serialize_segment "$0" "" $1 "$2" $3 black green "$eb_env" 'AWS_EB_ICON' fi } diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index 3a68a1919..b66dbcf5a 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -20,6 +20,6 @@ prompt_chruby() { chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" # Don't show anything if the chruby did not change the default ruby if [[ "${chrb_env:-system}" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' + serialize_segment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' fi } diff --git a/segments/developer/detect_virt.p9k b/segments/developer/detect_virt.p9k index eff69b6a6..9340a8f7f 100644 --- a/segments/developer/detect_virt.p9k +++ b/segments/developer/detect_virt.p9k @@ -18,11 +18,11 @@ prompt_detect_virt() { if [[ "$virt" == "none" ]]; then if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then virt="chroot" - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" else ; fi else - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" fi } diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index 7095f25c1..004cb3a91 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -18,6 +18,6 @@ prompt_docker_machine() { local docker_machine="$DOCKER_MACHINE_NAME" if [[ -n "$docker_machine" ]]; then - "$1_prompt_segment" "$0" "$2" "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' + serialize_segment "$0" "" $1 "$2" $3 "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' fi } diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index 1f11e89cb..959c379d5 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -21,6 +21,6 @@ prompt_go_version() { go_path=$(go env GOPATH 2>/dev/null) if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - "$1_prompt_segment" "$0" "$2" "green" "grey93" "$go_version" "GO_ICON" + serialize_segment "$0" "" $1 "$2" $3 "green" "grey93" "$go_version" "GO_ICON" fi } diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index 7591ef33a..b8488adab 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -35,6 +35,6 @@ prompt_kubecontext() { k8s_final_text="$cur_ctx/$cur_namespace" fi - "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + serialize_segment "$0" "" $1 "$2" $3 "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" fi } diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index 8063b246c..0cc40ba93 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -18,6 +18,6 @@ prompt_node_env() { local node_env_path="$NODE_VIRTUAL_ENV" if [[ -n "$node_env_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then local info="$(node -v)[$(basename "$node_env_path")]" - "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' + serialize_segment "$0" "" $1 "$2" $3 "black" "green" "$info" 'NODE_ICON' fi } diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index 83398d86d..7ed98ae99 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -18,5 +18,5 @@ prompt_node_version() { local node_version=$(node -v 2>/dev/null) [[ -z "${node_version}" ]] && return - "$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON' + serialize_segment "$0" "" $1 "$2" $3 "green" "white" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index 2d320acbd..c5fb06b5e 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -25,5 +25,5 @@ prompt_nvm() { nvm_default=$(nvm_version default) [[ "$node_version" =~ "$nvm_default" ]] && return - $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' + serialize_segment "$0" "" $1 "$2" $3 "magenta" "black" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/developer/php_version.p9k b/segments/developer/php_version.p9k index c46a5959d..2a099932e 100644 --- a/segments/developer/php_version.p9k +++ b/segments/developer/php_version.p9k @@ -15,6 +15,6 @@ prompt_php_version() { php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") if [[ -n "$php_version" ]]; then - "$1_prompt_segment" "$0" "$2" "fuchsia" "grey93" "$php_version" + serialize_segment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "$php_version" fi } diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index 0b6a65530..5219e5f21 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -17,6 +17,6 @@ register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' # https://github.com/pyenv/pyenv#choosing-the-python-version prompt_pyenv() { if [[ -n "$PYENV_VERSION" ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' fi } diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index e80384a4b..25bdf4080 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -23,7 +23,7 @@ prompt_rbenv() { # Don't show anything if the current Ruby is the same as the global Ruby # unless `POWERLEVEL9K_RBENV_ALWAYS` is set. if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + serialize_segment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi fi } diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index dc64fa2aa..58231764c 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -12,6 +12,9 @@ #     register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +# Source test stats script +source $p9k_directory/segments/developer/test_stats.p9k + ################################################################ # Segment to display RSpec test ratio prompt_rspec_stats() { @@ -20,6 +23,6 @@ prompt_rspec_stats() { code_amount=$(ls -1 app/**/*.rb | wc -l) tests_amount=$(ls -1 spec/**/*.rb | wc -l) - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' + build_test_stats "$0" "$1" $2 $3 "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' fi } diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index 0bf911ddf..89b3e2f1f 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -19,6 +19,6 @@ prompt_rust_version() { rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + serialize_segment "$0" "" $1 "$2" $3 "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' fi } diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index 9d2401e17..cd29c1daf 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -18,6 +18,6 @@ prompt_rvm() { local version_and_gemset=${rvm_env_string/ruby-} if [[ -n "$version_and_gemset" ]]; then - "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + serialize_segment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' fi } diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index 76d8cc3d2..e23b2da77 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -19,7 +19,7 @@ prompt_swift_version() { local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) [[ -z "${swift_version}" ]] && return - "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' + serialize_segment "$0" "" $1 "$2" $3 "magenta" "white" "${swift_version}" 'SWIFT_ICON' } # diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index d30a23d74..f8750e23d 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -12,6 +12,9 @@ #     register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +# Source test stats script +source $p9k_directory/segments/developer/test_stats.p9k + ################################################################ # Symfony2-PHPUnit test ratio prompt_symfony2_tests() { @@ -20,6 +23,6 @@ prompt_symfony2_tests() { code_amount=$(ls -1 src/**/*.php | grep -vc Tests) tests_amount=$(ls -1 src/**/*.php | grep -c Tests) - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' + build_test_stats "$0" "$1" $2 $3 "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' fi } diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index 01b57179a..9b3391e0c 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -18,6 +18,6 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' + serialize_segment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } diff --git a/segments/developer/test_stats.p9k b/segments/developer/test_stats.p9k new file mode 100644 index 000000000..a6f3aa481 --- /dev/null +++ b/segments/developer/test_stats.p9k @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# This theme was inspired by agnoster's Theme: +# https://gist.github.com/3712874 +################################################################ + +################################################################ +# Show a ratio of tests vs code +# Parameters for build_test_stats +# * $1 Name: string - Name of the calling segment +# * $2 Align: string - left|right +# * $3 Index: integer +# * $4 Joined: bool +# * $5 Code Amount: string +# * $6 Tests Amount: string +# * $7 Headline: string +# * $8 Icon: string +build_test_stats() { + local code_amount="$5" + local tests_amount="$6"+0.00001 + local headline="$7" + + # Set float precision to 2 digits: + typeset -F 2 ratio + local ratio=$(( (tests_amount/code_amount) * 100 )) + + (( ratio >= 75 )) && serialize_segment "$1" "GOOD" "$2" $3 $4 "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && serialize_segment "$1" "AVG" "$2" $3 $4 "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && serialize_segment "$1" "BAD" "$2" $3 $4 "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" +} diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index c2046a9fb..99527242b 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -53,8 +53,11 @@ register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESO #  register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' -# unset prompt_icon +################################################################ +# Source VCS_INFO hooks / helper functions +################################################################ +source "${p9k_directory}/functions/vcs.zsh" ################################################################ # VCS segment: shows the state of your repository, if you are in a folder under @@ -145,7 +148,7 @@ prompt_vcs() { current_state='clean' fi fi - "$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" + serialize_segment $0 ${(U)current_state} $1 "$2" $3 "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi } diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index a2fe32674..8125f3df9 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -19,6 +19,6 @@ register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' + serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' fi } diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index 635244624..468ca99cf 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -25,7 +25,7 @@ prompt_dropbox() { dropbox_status="" fi - "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" + serialize_segment "$0" "" $1 "$2" $3 "white" "blue" "$dropbox_status" "DROPBOX_ICON" fi } diff --git a/segments/other/icons_test.p9k b/segments/other/icons_test.p9k index 6f04ad2ac..d0976ce96 100644 --- a/segments/other/icons_test.p9k +++ b/segments/other/icons_test.p9k @@ -16,6 +16,6 @@ prompt_icons_test() { # the next color has enough contrast to read. local random_color=$((RANDOM % 8)) local next_color=$((random_color+1)) - "$1_prompt_segment" "$0" "$2" "$random_color" "$next_color" "$key" "$key" + serialize_segment "$0" "" $1 "$2" $3 "$random_color" "$next_color" "$key" "$key" done } diff --git a/segments/other/openfoam.p9k b/segments/other/openfoam.p9k index deb8a68cc..a5187f39a 100644 --- a/segments/other/openfoam.p9k +++ b/segments/other/openfoam.p9k @@ -14,8 +14,8 @@ prompt_openfoam() { local wm_project_version="$WM_PROJECT_VERSION" local wm_fork="$WM_FORK" if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" fi } diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index b51f95104..e028f9d7f 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -18,7 +18,7 @@ prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') if [[ "$count" = <-> ]]; then - "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' + serialize_segment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' fi fi } From 28a8690434c8ffd0b2ac6ff88fe1273ed30b1acd Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 09:11:21 +0400 Subject: [PATCH 23/55] Fixed double visual identifier code error --- generator/default.p9k | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index ad6960bd9..452687d93 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -247,20 +247,7 @@ serialize_segment() { local CONTENT="${8}" local VISUAL_IDENTIFIER - if [[ -n "${9}" ]]; then - VISUAL_IDENTIFIER="$(print_icon ${9})" - if [[ -n "${VISUAL_IDENTIFIER}" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" - set_default "${visual_identifier_color_variable}" "${FOREGROUND}" - VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" - # Add an whitespace if we print more than just the visual identifier - if [[ -n "${CONTENT}" ]]; then - [[ "${ALIGNMENT}" == "left" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " - [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" - fi - fi - fi + [[ -n "${9}" ]] && VISUAL_IDENTIFIER="$(print_icon ${9})" # Conditions have three layers: # 1. All segments should not print # a segment, if they provide no From 30379d65ff69712b8abe7823be390c05ae25269f Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 09:23:58 +0400 Subject: [PATCH 24/55] Icon drawing correction --- generator/default.p9k | 47 +++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index 452687d93..a5f86b0a8 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -86,14 +86,14 @@ left_prompt_segment() { local visual_identifier if [[ -n $7 ]]; then visual_identifier="$7" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$6" ]] && visual_identifier="$visual_identifier " - fi + # if [[ -n "$visual_identifier" ]]; then + # # Allow users to overwrite the color for the visual identifier only. + # local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + # set_default $visual_identifier_color_variable $4 + # visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # # Add an whitespace if we print more than just the visual identifier + # [[ -n "$6" ]] && visual_identifier="$visual_identifier " + # fi fi # Print the visual identifier @@ -171,14 +171,14 @@ right_prompt_segment() { local visual_identifier if [[ -n "$7" ]]; then visual_identifier="$7" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$6" ]] && visual_identifier=" $visual_identifier" - fi + # if [[ -n "$visual_identifier" ]]; then + # # Allow users to overwrite the color for the visual identifier only. + # local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + # set_default $visual_identifier_color_variable $4 + # visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # # Add an whitespace if we print more than just the visual identifier + # [[ -n "$6" ]] && visual_identifier=" $visual_identifier" + # fi fi echo -n "${bg}${fg}" @@ -247,7 +247,20 @@ serialize_segment() { local CONTENT="${8}" local VISUAL_IDENTIFIER - [[ -n "${9}" ]] && VISUAL_IDENTIFIER="$(print_icon ${9})" + if [[ -n "${9}" ]]; then + VISUAL_IDENTIFIER="$(print_icon ${9})" + if [[ -n "${VISUAL_IDENTIFIER}" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + set_default "${visual_identifier_color_variable}" "${FOREGROUND}" + VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" + # Add an whitespace if we print more than just the visual identifier + if [[ -n "${CONTENT}" ]]; then + [[ "${ALIGNMENT}" == "left" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " + [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" + fi + fi + fi # Conditions have three layers: # 1. All segments should not print # a segment, if they provide no From 45ef06e92eaf1db22cfd00cece54feb5d25ccb5b Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 09:34:49 +0400 Subject: [PATCH 25/55] Reverted #776 Seems that removing the -P from the print command does make a difference. --- segments/core/dir.p9k | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index ba5e8e75d..ffe7ef902 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -42,11 +42,6 @@ prompt_dir() { local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) case "$POWERLEVEL9K_SHORTEN_STRATEGY" in - truncate_absolute_chars) - if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then - current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} - fi - ;; truncate_middle) # truncate characters from the middle of the path current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") @@ -55,7 +50,7 @@ prompt_dir() { # truncate characters from the right of the path current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) ;; - truncate_absolute) + truncate_absolute|truncate_absolute_chars) # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} @@ -183,7 +178,7 @@ prompt_dir() { fi ;; *) - current_path="$(print "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" ;; esac fi From 259db2dcb6e2638421d14c6b4d007f3f79c501d8 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 12:16:03 +0400 Subject: [PATCH 26/55] Code cleanup --- generator/default.p9k | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index a5f86b0a8..fbe61744c 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -84,17 +84,7 @@ left_prompt_segment() { fi local visual_identifier - if [[ -n $7 ]]; then - visual_identifier="$7" - # if [[ -n "$visual_identifier" ]]; then - # # Allow users to overwrite the color for the visual identifier only. - # local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - # set_default $visual_identifier_color_variable $4 - # visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # # Add an whitespace if we print more than just the visual identifier - # [[ -n "$6" ]] && visual_identifier="$visual_identifier " - # fi - fi + [[ -n $7 ]] && visual_identifier="$7" # Print the visual identifier echo -n "${visual_identifier}" @@ -169,17 +159,7 @@ right_prompt_segment() { fi local visual_identifier - if [[ -n "$7" ]]; then - visual_identifier="$7" - # if [[ -n "$visual_identifier" ]]; then - # # Allow users to overwrite the color for the visual identifier only. - # local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - # set_default $visual_identifier_color_variable $4 - # visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # # Add an whitespace if we print more than just the visual identifier - # [[ -n "$6" ]] && visual_identifier=" $visual_identifier" - # fi - fi + [[ -n "$7" ]] && visual_identifier="$7" echo -n "${bg}${fg}" From 8f6013048e50cae942d10ae7eacb5e8deb6fbca2 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 13:08:50 +0400 Subject: [PATCH 27/55] Rewrote vi_mode to support sync & async Combined synchronous and asynchronous code into a single prompt segment --- segments/core/vi_mode.p9k | 204 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 194 insertions(+), 10 deletions(-) diff --git a/segments/core/vi_mode.p9k b/segments/core/vi_mode.p9k index f918eb68a..3d3c86faa 100644 --- a/segments/core/vi_mode.p9k +++ b/segments/core/vi_mode.p9k @@ -8,25 +8,209 @@ # https://gist.github.com/3712874 ################################################################ -################################################################ +# Visual mode only works if the user has installed zsh-vimode-visual +# (Requires https://github.com/b4b4r07/zsh-vimode-visual) + +set_default "POWERLEVEL9K_VI_INSERT_MODE_STRING" "INSERT" +set_default "POWERLEVEL9K_VI_COMMAND_MODE_STRING" "NORMAL" +set_default "POWERLEVEL9K_VI_VISUAL_MODE_STRING" "VISUAL" +############################################################### # Vi Mode: show editing mode (NORMAL|INSERT) -set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" -set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +# * $3 Joined: bool - If the segment should be joined prompt_vi_mode() { - case ${KEYMAP} in + local vi_mode + local current_state + typeset -gAH vi_states + vi_states=( + 'NORMAL' "${DEFAULT_COLOR_INVERTED}" + 'INSERT' 'blue' + 'VISUAL' 'orange' + ) + case "${KEYMAP}" in vicmd) - serialize_segment "$0" "NORMAL" $1 "$2" $3 "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + current_state="NORMAL" + vi_mode="${POWERLEVEL9K_VI_COMMAND_MODE_STRING}" + ;; + vivis) + current_state="VISUAL" + vi_mode="${POWERLEVEL9K_VI_VISUAL_MODE_STRING}" ;; main|viins|*) if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi - serialize_segment "$0" "INSERT" $1 "$2" $3 "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" + current_state="INSERT" + vi_mode="${POWERLEVEL9K_VI_INSERT_MODE_STRING}" + ;; + esac + serialize_segment "$0" "${current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${vi_states[$current_state]}" "${vi_mode}" '' +} + +############################################################### +function rebuild_vi_mode { + case "${POWERLEVEL9K_GENERATOR}" in + async) + if (( ${+terminfo[smkx]} )); then + printf '%s' ${terminfo[smkx]} + fi + for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}"); do + prompt_vi_mode "left" "${index}" "${1}" &! + done + for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}"); do + prompt_vi_mode "right" "${index}" "${1}" &! + done + ;; + async-adv) + if (( ${+terminfo[smkx]} )); then + printf '%s' ${terminfo[smkx]} + fi + local element + for (( i = 1; i <= ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}; i++ )); do + element="${(L)POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[$i]}" + if [[ "${element}" =~ "vi_mode" ]]; then + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true + prompt_vi_mode "left" "${i}" "$joined" + break + fi + done + for (( i = 1; i <= ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}; i++ )); do + element="${(L)POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[$i]}" + if [[ "${element}" =~ "vi_mode" ]]; then + [[ "${element[-7,-1]}" == '_joined' ]] && joined=true + prompt_vi_mode "left" "${i}" "$joined" + break + fi + done + ;; + esac +} + +############################################################### +# This function returns the correct cursorline +# +# Parameters: +# * $1 Shape: string - box, hbar or vbar +cursorShape() { + typeset -gAH CS_konsole # iTerm and yakuake use the same definition + CS_konsole=( + "prefix" "\033]50;CursorShape=" + "box" "0" + "vbar" "1" + "hbar" "2" + "suffix" "\x7" + ) + typeset -gAH CS_xterm # tmux uses the same definition + CS_xterm=( + "prefix" "\033[" + "box" "1" + "vbar" "3" + "hbar" "5" + "suffix" " q" + ) + typeset -gAH CS_xterm_noblink + CS_xterm_noblink=( + "prefix" "\033[" + "box" "2" + "vbar" "4" + "hbar" "6" + "suffix" " q" + ) + typeset -gAH CS_rxvt # gnometerm uses the same definition + CS_rxvt=( + "prefix" "\033[" + "box" "1" + "vbar" "5" + "hbar" "3" + "suffix" " q" + ) + typeset -gAH CS_rxvt_noblink + CS_rxvt_noblink=( + "prefix" "\033[" + "box" "2" + "vbar" "6" + "hbar" "4" + "suffix" " q" + ) + local cursor_shape_line="" + + case $TERMINAL in + konsole | iterm | yakuake) + cursor_shape_line=$CS_konsole[prefix]$CS_konsole[$1]$CS_konsole[suffix] + ;; + gnometerm | rxvt | termite | tmux) + if [[ $POWERLEVEL9K_CURSOR_NOBLINK ]]; then + cursor_shape_line=$CS_rxvt_noblink[prefix]$CS_rxvt_noblink[$1]$CS_rxvt_noblink[suffix] + else + cursor_shape_line=$CS_rxvt[prefix]$CS_rxvt[$1]$CS_rxvt[suffix] + fi + ;; + xterm) + if [[ $POWERLEVEL9K_CURSOR_NOBLINK ]]; then + cursor_shape_line=$CS_xterm_noblink[prefix]$CS_xterm_noblink[$1]$CS_xterm_noblink[suffix] + else + cursor_shape_line=$CS_xterm[prefix]$CS_xterm[$1]$CS_xterm[suffix] + fi + ;; + esac + + [[ -n $cursor_shape_line ]] && echo -en "$cursor_shape_line" +} + +############################################################### +function zle-line-init { + case $POWERLEVEL9K_GENERATOR in + zsh-async) + rebuild_vi_mode "${KEYMAP}" + ;; + esac + # change cursor shape + if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then + case $KEYMAP in + vicmd) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_NORMAL};; + viins|main) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_INSERT};; + vivis) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_VISUAL};; + *) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT};; + esac + fi +} + +############################################################### +function zle-line-finish { + #rebuild_vi_mode "${KEYMAP}" + if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then + cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT} + fi +} + +############################################################### +function zle-keymap-select { + case $POWERLEVEL9K_GENERATOR in + zsh-async) + rebuild_vi_mode "${KEYMAP}" + break; + ;; + *) + zle reset-prompt + zle -R ;; esac + # change cursor shape + if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then + case $KEYMAP in + vicmd) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_NORMAL};; + viins|main) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_INSERT};; + vivis) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_VISUAL};; + *) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT};; + esac + fi } -zle-keymap-select () { - zle reset-prompt - zle -R +############################################################### +function register_zle { + zle -N zle-line-init + zle -N zle-line-finish + zle -N zle-keymap-select } -zle -N zle-keymap-select +register_zle From f43a9a7bb0956afca1f1e754bdaed5dbff57f13c Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 24 Mar 2018 13:18:09 +0400 Subject: [PATCH 28/55] vi_mode: Supports term ID and cursor shape change To enable cursor shape change, set: POWERLEVEL9K_CURSOR_SHAPE=true On supported terminals, cursor shape can be box [], hbar _ or vbar | Example: POWERLEVEL9K_CURSOR_SHAPE_NORMAL="box" POWERLEVEL9K_CURSOR_SHAPE_INSERT="vbar" POWERLEVEL9K_CURSOR_SHAPE_VISUAL="box" POWERLEVEL9K_CURSOR_SHAPE_DEFAULT="hbar" --- functions/utilities.zsh | 49 +++++++++++++++++++++++++++++++++++++++ segments/core/vi_mode.p9k | 24 +++++++++---------- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index deaf2a8ec..6cdd67bf8 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -30,6 +30,55 @@ case $(uname) in SunOS) OS='Solaris' ;; esac +################################################################ +# Identify Terminal Emulator +# Find out which emulator is being used for terminal specific options +# The testing order is important, since some override others +if [[ "$TMUX" =~ "tmux" ]]; then + readonly TERMINAL="tmux" +elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then + readonly TERMINAL="iterm" +elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + readonly TERMINAL="appleterm" +else + if [[ "$OS" == "OSX" ]]; then + local termtest=$(ps -o 'command=' -p $(ps -o 'ppid=' -p $$) | tail -1 | awk '{print $NF}') + # test if we are in a sudo su - + if [[ $termtest == "-" || $termtest == "root" ]]; then + termtest=($(ps -o 'command=' -p $(ps -o 'ppid=' -p $(ps -o 'ppid='$$)))) + termtest=$(basename $termtest[1]) + fi + else + local termtest=$(ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) | tail -1 | awk '{print $NF}') + # test if we are in a sudo su - + if [[ $termtest == "-" || $termtest == "root" ]]; then + termtest=($(ps -o 'cmd=' -p $(ps -o 'ppid=' $(ps -o 'ppid='$$)))) + if [[ $termtest[1] == "zsh" ]]; then # gnome terminal works differently than the rest... sigh + termtest=$termtest[-1] + elif [[ $termtest[1] =~ "python" ]]; then # as does guake + termtest=$termtest[3] + else + termtest=$termtest[1] + fi + fi + fi + case "${termtest##*/}" in + gnome-terminal-server) readonly TERMINAL="gnometerm";; + guake.main) readonly TERMINAL="guake";; + iTerm2) readonly TERMINAL="iterm";; + konsole) readonly TERMINAL="konsole";; + termite) readonly TERMINAL="termite";; + urxvt) readonly TERMINAL="rxvt";; + yakuake) readonly TERMINAL="yakuake";; + xterm | xterm-256color) readonly TERMINAL="xterm";; + *tty*) readonly TERMINAL="tty";; + *) readonly TERMINAL=${termtest##*/};; + esac + + unset termtest + unset uname +fi + # Exits with 0 if a variable has been previously defined (even if empty) # Takes the name of a variable that should be checked. function defined() { diff --git a/segments/core/vi_mode.p9k b/segments/core/vi_mode.p9k index 3d3c86faa..4885bbd09 100644 --- a/segments/core/vi_mode.p9k +++ b/segments/core/vi_mode.p9k @@ -50,18 +50,18 @@ prompt_vi_mode() { ############################################################### function rebuild_vi_mode { case "${POWERLEVEL9K_GENERATOR}" in - async) - if (( ${+terminfo[smkx]} )); then - printf '%s' ${terminfo[smkx]} - fi - for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}"); do - prompt_vi_mode "left" "${index}" "${1}" &! - done - for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}"); do - prompt_vi_mode "right" "${index}" "${1}" &! - done - ;; - async-adv) + # async) + # if (( ${+terminfo[smkx]} )); then + # printf '%s' ${terminfo[smkx]} + # fi + # for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}"); do + # prompt_vi_mode "left" "${index}" "${1}" &! + # done + # for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}"); do + # prompt_vi_mode "right" "${index}" "${1}" &! + # done + # ;; + zsh-async) if (( ${+terminfo[smkx]} )); then printf '%s' ${terminfo[smkx]} fi From 5843e804dd2c4f3f0bd6d6bb5a01891927d66b5a Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 27 Mar 2018 20:16:12 +0400 Subject: [PATCH 29/55] Added java_version, comments & API - Added prompt_java_version & updated README.md - Updated comments for ALL functions for use with sh2md. - Added API folder. This contains all the Markdown documentation for all of the *.p9k files. --- README.md | 2 + api/functions/colors.md | 98 +++++++++ api/functions/icons.md | 64 ++++++ api/functions/utilities.md | 175 ++++++++++++++++ api/generator/default.md | 153 ++++++++++++++ api/generator/zsh-async.md | 210 +++++++++++++++++++ api/segments/core/background_jobs.md | 28 +++ api/segments/core/battery.md | 28 +++ api/segments/core/command_execution_time.md | 28 +++ api/segments/core/context.md | 32 +++ api/segments/core/date.md | 28 +++ api/segments/core/dir.md | 28 +++ api/segments/core/dir_writable.md | 28 +++ api/segments/core/disk_usage.md | 28 +++ api/segments/core/history.md | 28 +++ api/segments/core/host.md | 28 +++ api/segments/core/ip.md | 28 +++ api/segments/core/load.md | 28 +++ api/segments/core/newline.md | 28 +++ api/segments/core/os_icon.md | 32 +++ api/segments/core/public_ip.md | 14 ++ api/segments/core/ram.md | 28 +++ api/segments/core/root_indicator.md | 28 +++ api/segments/core/ssh.md | 28 +++ api/segments/core/status.md | 28 +++ api/segments/core/swap.md | 28 +++ api/segments/core/time.md | 28 +++ api/segments/core/user.md | 32 +++ api/segments/core/vi_mode.md | 32 +++ api/segments/core/vpn_ip.md | 28 +++ api/segments/developer/anaconda.md | 28 +++ api/segments/developer/aws.md | 28 +++ api/segments/developer/aws_eb_env.md | 28 +++ api/segments/developer/chruby.md | 33 +++ api/segments/developer/detect_virt.md | 28 +++ api/segments/developer/docker_machine.md | 28 +++ api/segments/developer/go_version.md | 28 +++ api/segments/developer/java_version.md | 28 +++ api/segments/developer/kubecontext.md | 28 +++ api/segments/developer/node_env.md | 28 +++ api/segments/developer/node_version.md | 28 +++ api/segments/developer/nvm.md | 32 +++ api/segments/developer/php_version.md | 28 +++ api/segments/developer/pyenv.md | 33 +++ api/segments/developer/rbenv.md | 28 +++ api/segments/developer/rspec_stats.md | 28 +++ api/segments/developer/rust_version.md | 28 +++ api/segments/developer/rvm.md | 28 +++ api/segments/developer/swift_version.md | 28 +++ api/segments/developer/symfony2_tests.md | 28 +++ api/segments/developer/symfony2_version.md | 28 +++ api/segments/developer/test_stats.md | 37 ++++ api/segments/developer/vcs.md | 41 ++++ api/segments/developer/virtualenv.md | 34 ++++ api/segments/other/dropbox.md | 28 +++ api/segments/other/icons_test.md | 28 +++ api/segments/other/openfoam.md | 28 +++ api/segments/other/todo.md | 28 +++ functions/colors.zsh | 90 ++++++-- functions/icons.zsh | 83 ++++---- functions/utilities.zsh | 214 ++++++++++++++------ generator/default.p9k | 184 ++++++++++++----- generator/zsh-async.p9k | 78 +++++-- powerlevel9k.zsh-theme | 27 +-- segments/core/background_jobs.p9k | 24 ++- segments/core/battery.p9k | 27 ++- segments/core/command_execution_time.p9k | 27 ++- segments/core/context.p9k | 28 ++- segments/core/date.p9k | 27 ++- segments/core/dir.p9k | 32 +-- segments/core/dir_writable.p9k | 29 ++- segments/core/disk_usage.p9k | 29 ++- segments/core/history.p9k | 27 ++- segments/core/host.p9k | 29 ++- segments/core/ip.p9k | 27 ++- segments/core/load.p9k | 29 ++- segments/core/newline.p9k | 22 +- segments/core/os_icon.p9k | 31 ++- segments/core/public_ip.p9k | 18 +- segments/core/ram.p9k | 27 ++- segments/core/root_indicator.p9k | 27 ++- segments/core/ssh.p9k | 27 ++- segments/core/status.p9k | 32 ++- segments/core/swap.p9k | 27 ++- segments/core/time.p9k | 27 ++- segments/core/user.p9k | 32 ++- segments/core/vi_mode.p9k | 36 +++- segments/core/vpn_ip.p9k | 30 ++- segments/developer/anaconda.p9k | 24 ++- segments/developer/aws.p9k | 27 ++- segments/developer/aws_eb_env.p9k | 27 ++- segments/developer/chruby.p9k | 32 ++- segments/developer/detect_virt.p9k | 22 +- segments/developer/docker_machine.p9k | 27 ++- segments/developer/go_version.p9k | 27 ++- segments/developer/java_version.p9k | 34 ++++ segments/developer/kubecontext.p9k | 27 ++- segments/developer/node_env.p9k | 27 ++- segments/developer/node_version.p9k | 27 ++- segments/developer/nvm.p9k | 31 ++- segments/developer/php_version.p9k | 29 ++- segments/developer/pyenv.p9k | 31 ++- segments/developer/rbenv.p9k | 29 ++- segments/developer/rspec_stats.p9k | 30 +-- segments/developer/rust_version.p9k | 27 ++- segments/developer/rvm.p9k | 27 ++- segments/developer/swift_version.p9k | 27 ++- segments/developer/symfony2_tests.p9k | 28 +-- segments/developer/symfony2_version.p9k | 26 ++- segments/developer/test_stats.p9k | 43 ++-- segments/developer/vcs.p9k | 36 +++- segments/developer/virtualenv.p9k | 32 ++- segments/other/dropbox.p9k | 27 ++- segments/other/icons_test.p9k | 22 +- segments/other/openfoam.p9k | 22 +- segments/other/todo.p9k | 27 ++- 116 files changed, 3692 insertions(+), 652 deletions(-) create mode 100644 api/functions/colors.md create mode 100644 api/functions/icons.md create mode 100644 api/functions/utilities.md create mode 100644 api/generator/default.md create mode 100644 api/generator/zsh-async.md create mode 100644 api/segments/core/background_jobs.md create mode 100644 api/segments/core/battery.md create mode 100644 api/segments/core/command_execution_time.md create mode 100644 api/segments/core/context.md create mode 100644 api/segments/core/date.md create mode 100644 api/segments/core/dir.md create mode 100644 api/segments/core/dir_writable.md create mode 100644 api/segments/core/disk_usage.md create mode 100644 api/segments/core/history.md create mode 100644 api/segments/core/host.md create mode 100644 api/segments/core/ip.md create mode 100644 api/segments/core/load.md create mode 100644 api/segments/core/newline.md create mode 100644 api/segments/core/os_icon.md create mode 100644 api/segments/core/public_ip.md create mode 100644 api/segments/core/ram.md create mode 100644 api/segments/core/root_indicator.md create mode 100644 api/segments/core/ssh.md create mode 100644 api/segments/core/status.md create mode 100644 api/segments/core/swap.md create mode 100644 api/segments/core/time.md create mode 100644 api/segments/core/user.md create mode 100644 api/segments/core/vi_mode.md create mode 100644 api/segments/core/vpn_ip.md create mode 100644 api/segments/developer/anaconda.md create mode 100644 api/segments/developer/aws.md create mode 100644 api/segments/developer/aws_eb_env.md create mode 100644 api/segments/developer/chruby.md create mode 100644 api/segments/developer/detect_virt.md create mode 100644 api/segments/developer/docker_machine.md create mode 100644 api/segments/developer/go_version.md create mode 100644 api/segments/developer/java_version.md create mode 100644 api/segments/developer/kubecontext.md create mode 100644 api/segments/developer/node_env.md create mode 100644 api/segments/developer/node_version.md create mode 100644 api/segments/developer/nvm.md create mode 100644 api/segments/developer/php_version.md create mode 100644 api/segments/developer/pyenv.md create mode 100644 api/segments/developer/rbenv.md create mode 100644 api/segments/developer/rspec_stats.md create mode 100644 api/segments/developer/rust_version.md create mode 100644 api/segments/developer/rvm.md create mode 100644 api/segments/developer/swift_version.md create mode 100644 api/segments/developer/symfony2_tests.md create mode 100644 api/segments/developer/symfony2_version.md create mode 100644 api/segments/developer/test_stats.md create mode 100644 api/segments/developer/vcs.md create mode 100644 api/segments/developer/virtualenv.md create mode 100644 api/segments/other/dropbox.md create mode 100644 api/segments/other/icons_test.md create mode 100644 api/segments/other/openfoam.md create mode 100644 api/segments/other/todo.md create mode 100644 segments/developer/java_version.p9k diff --git a/README.md b/README.md index 8b0fc03c9..38e34a593 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,8 @@ The segments that are currently available are: * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** * `swift_version` - Show the version number of the installed Swift. +* **Java Segments:** + * `java_version` - Show the current Java version. **Cloud Segments:** * **AWS Segments:** diff --git a/api/functions/colors.md b/api/functions/colors.md new file mode 100644 index 000000000..78fd20cc9 --- /dev/null +++ b/api/functions/colors.md @@ -0,0 +1,98 @@ +# powerlevel9k Color Functions + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +### File Description + +*This file contains some color-functions for powerlevel9k. * + +## Table of Contents + +- [termColors](#termColors) +- [getColor](#getColor) +- [backgroundColor](#backgroundColor) +- [foregroundColor](#foregroundColor) +- [getColorCode](#getColorCode) +- [isSameColor](#isSameColor) + +## termColors +*This function checks if the terminal supports 256 colors. If it doesn't, an error message is displayed. * + +#### Arguments + +- *Function has no arguments.* + + +#### Notes + +*You can bypass this check by setting `POWERLEVEL9K_IGNORE_TERM_COLORS=true`. * + +## getColor +*This function gets the proper color code if it does not exist as a name. * + +#### Arguments + +- **$1** (misc) Color to check (as a number or string) + + +## backgroundColor +*Function to set the background color. * + +#### Arguments + +- **$1** (misc) The background color. + + +#### Returns + +- An escape code string for (re)setting the background color. + + +#### Notes + +*An empty paramenter resets (stops) background color. * + +## foregroundColor +*Function to set the foreground color. * + +#### Arguments + +- **$1** (misc) The foreground color. + + +#### Returns + +- An escape code string for (re)setting the foreground color. + + +#### Notes + +*An empty paramenter resets (stops) foreground color. * + +## getColorCode +*Function to get numerical color codes. That way we translate ANSI codes into ZSH-Style color codes. * + +#### Arguments + +- **$1** (misc) Number or string of color. + + +## isSameColor +*Check if two colors are equal, even if one is specified as ANSI code. * + +#### Arguments + +- **$1** (misc) First color (number or string) +- **$2** (misc) Second color (number or string) + + diff --git a/api/functions/icons.md b/api/functions/icons.md new file mode 100644 index 000000000..d6532bdc0 --- /dev/null +++ b/api/functions/icons.md @@ -0,0 +1,64 @@ +# powerlevel9k Icon Functions + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +### File Description + +*This file contains some the core icon definitions and icon-functions. * + +*These characters require the Powerline fonts to work properly. If you see boxes or bizarre characters below, your fonts are not correctly installed. If you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to `compatible`. This shows all icons in regular symbols. * + +## Table of Contents + +- [register_icon](#register_icon) +- [print_icon](#print_icon) + +## register_icon +*This function allows a segment to register the icons that it requires. These icons may be overriden by the user later. Arguments may be a direct call or an array. * + +#### Arguments + +- **$1** (string) Name of icon +- **$2** (string) Generic icon +- **$3** (string) Flat / Awesome Patched icon +- **$4** (string) Awesome FontConfig icon +- **$5** (string) Awesome Mapped FontConfig icon +- **$6** (string) NerdFont Complete / FontConfig icon + + +#### Notes + +*You can specify a string, unicode string or codepoint string (for Mapped fonts only). * + +#### Usage + +```sh +register_icon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' + +``` + +#### Example + +```sh +register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' + +``` + +## print_icon +*Safety function for printing icons. Prints the named icon, or if that icon is undefined, the string name. * + +#### Arguments + +- **$1** (string) Name of icon + + diff --git a/api/functions/utilities.md b/api/functions/utilities.md new file mode 100644 index 000000000..65dd14ea8 --- /dev/null +++ b/api/functions/utilities.md @@ -0,0 +1,175 @@ +# powerlevel9k Utility Functions + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +### File Description + +*This file contains some utility-functions for the powerlevel9k ZSH theme. * + +## Table of Contents + +- [defined](#defined) +- [set_default](#set_default) +- [printSizeHumanReadable](#printSizeHumanReadable) +- [getRelevantItem](#getRelevantItem) +- [segment_in_use](#segment_in_use) +- [print_deprecation_warning](#print_deprecation_warning) +- [segmentShouldBeJoined](#segmentShouldBeJoined) +- [truncatePath](#truncatePath) +- [truncatePathFromRight](#truncatePathFromRight) +- [upsearch](#upsearch) +- [union](#union) + +## defined +*This function determine if a variable has been previously defined, even if empty. * + +#### Arguments + +- **$1** (string) The name of the variable that should be checked. + + +#### Returns + +- 0 if the variable has been defined. + + +## set_default +*This function determine if a variable has been previously defined, and only sets the value to the specified default if it hasn't. * + +#### Arguments + +- **$1** (string) The name of the variable that should be checked. +- **$2** (string) The default value + + +#### Returns + +- Nothing. + + +#### Notes + +*Typeset cannot set the value for an array, so this will only work for scalar values. * + +## printSizeHumanReadable +*Converts large memory values into a human-readable unit (e.g., bytes --> GB) * + +#### Arguments + +- **$1** (integer) Size - The number which should be prettified. +- **$2** (string) Base - The base of the number (default Bytes). + + +#### Notes + +*The base can be any of the following: B, K, M, G, T, P, E, Z, Y. * + +## getRelevantItem +*Gets the first value out of a list of items that is not empty. The items are examined by a callback-function. * + +#### Arguments + +- **$1** (array) A list of items. +- **$2** (string) A callback function to examine if the item is worthy. + + +#### Notes + +*The callback function has access to the inner variable $item. * + +## segment_in_use +*Determine if the passed segment is used in either the LEFT or RIGHT prompt arrays. * + +#### Arguments + +- **$1** (string) The segment to be tested. + + +## print_deprecation_warning +*Print a deprecation warning if an old segment is in use. * + +#### Arguments + +- **$1** (associative-array) An associative array that contains the +- deprecated segments as keys, and the new segment names as values. + + +## segmentShouldBeJoined +*A helper function to determine if a segment should be joined or promoted to a full one. * + +## truncatePath +*Given a directory path, truncate it according to the settings. * + +#### Arguments + +- **$1** (string) The directory path to be truncated. +- **$2** (integer) Length to truncate to. +- **$3** (string) Delimiter to use. +- **$4** (string) Where to truncate from - "right" | "middle". If omited, assumes right. + + +## truncatePathFromRight +*Given a directory path, truncate it according to the settings for `truncate_from_right`. * + +#### Arguments + +- **$1** (string) Directory path. + + +#### Notes + +*Deprecated. Use `truncatePath` instead. * + +## upsearch +*Search recursively in parent folders for given file. * + +#### Arguments + +- **$1** (string) Filename to search for. + + +## union +*Union of two or more arrays. * + +#### Arguments + +- **...** (arrays) The arrays to combine. + + +#### Returns + +- array of unique items. + + +#### Notes + +*This does not work with indexed arrays. * + +#### Usage + +```sh +union [arr1[ arr2[ ...]]] + +``` + +#### Example + +```sh +$ arr1=('a' 'b' 'c') +$ arr2=('b' 'c' 'd') +$ arr2=('c' 'd' 'e') +$ union $arr1 $arr2 $arr3 +> a b c d e + +``` + diff --git a/api/generator/default.md b/api/generator/default.md new file mode 100644 index 000000000..56c6ec8ef --- /dev/null +++ b/api/generator/default.md @@ -0,0 +1,153 @@ +# powerlevel9k Default Engine + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +### File Description + +*This file contains an default generator for the powerlevel9k project. * + +## Table of Contents + +- [left_prompt_segment()](#left_prompt_segment) +- [left_prompt_end()](#left_prompt_end) +- [right_prompt_segment()](#right_prompt_segment) +- [serialize_segment()](#serialize_segment) +- [prompt_custom()](#prompt_custom) +- [build_left_prompt()](#build_left_prompt) +- [build_right_prompt()](#build_right_prompt) +- [powerlevel9k_preexec()](#powerlevel9k_preexec) +- [powerlevel9k_prepare_prompts()](#powerlevel9k_prepare_prompts) +- [p9k_chpwd()](#p9k_chpwd) +- [prompt_powerlevel9k_setup()](#prompt_powerlevel9k_setup) +- [prompt_powerlevel9k_teardown()](#prompt_powerlevel9k_teardown) + +## left_prompt_segment() +*Construct a left prompt segment * + +#### Arguments + +- **$1** (string) Name of the function that was originally invoked (mandatory). +- **$2** (integer) Index of the segment +- **$3** (string) Background color +- **$4** (string) Foreground color +- **$5** (bool) Whether the segment should be bold +- **$6** (string) Content of the segment +- **$7** (string) Visual identifier (must be a key of the icons array) + + +## left_prompt_end() +*End the left prompt, closes the final segment * + +#### Arguments + +- *Function has no arguments.* + + +## right_prompt_segment() +*Construct a right prompt segment * + +#### Arguments + +- **$1** (string) Name of the function that was originally invoked (mandatory). +- **$2** (integer) Index of the segment +- **$3** (string) Background color +- **$4** (string) Foreground color +- **$5** (bool) Whether the segment should be bold +- **$6** (string) Content of the segment +- **$7** (string) Visual identifier (must be a key of the icons array) + + +## serialize_segment() +*This function wraps `left_prompt_segment` and `right_prompt_segment` (for compatibility with the async generator). * + +#### Arguments + +- **$1** (string) Name of the function that was originally invoked (mandatory). +- **$2** (string) State of the segment. +- **$3** (string) Alignment (left|right). +- **$4** (integer) Index of the segment. +- **$5** (bool) Whether the segment should be joined. +- **$6** (string) Background color. +- **$7** (string) Foreground color. +- **$8** (string) Content of the segment. +- **$9** (string) Visual identifier (must be a key of the icons array). +- **$10** (string) The condition - if the segment should be shown (gets evaluated). + + +## prompt_custom() +*The `custom` prompt provides a way for users to invoke commands and display the output in a segment. * + +#### Arguments + +- **$1** (string) Left|Right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined +- **$4** (string) Custom segment name + + +## build_left_prompt() +*This function loops through the left prompt elements and calls the related segment functions. * + +#### Arguments + +- *Function has no arguments.* + + +## build_right_prompt() +*This function loops through the right prompt elements and calls the related segment functions. * + +#### Arguments + +- *Function has no arguments.* + + +## powerlevel9k_preexec() +*This function is a hook that runs before the command runs. It sets the start timer. * + +#### Arguments + +- *Function has no arguments.* + + +## powerlevel9k_prepare_prompts() +*This function is a hook that is run before the prompts are created. If sets all the required variables for the prompts and then calls the prompt segment building functions. * + +#### Arguments + +- *Function has no arguments.* + + +## p9k_chpwd() +*This function is a hook into chpwd to add bindkey support. * + +#### Arguments + +- *Function has no arguments.* + + +## prompt_powerlevel9k_setup() +*This is the main function. It does the necessary checks, loads the required resources and sets the required hooks. * + +#### Arguments + +- *Function has no arguments.* + + +## prompt_powerlevel9k_teardown() +*This function removed PowerLevel9k hooks and resets the prompts. * + +#### Arguments + +- *Function has no arguments.* + + diff --git a/api/generator/zsh-async.md b/api/generator/zsh-async.md new file mode 100644 index 000000000..e216410cf --- /dev/null +++ b/api/generator/zsh-async.md @@ -0,0 +1,210 @@ +# powerlevel9k ZSH-Async Engine + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) +- Christo Kotze (onaforeignshore) + + +### Dependencies + +- [zsh-async](https://github.com/mafredri/zsh-async) + + +### File Description + +*This file contains an async generator for the powerlevel9k project. It makes use of zsh-async in order to build the prompts asynchronously. * + +*Please note that this is A WORK IN PROGRESS, so use at your own risk! * + +## Table of Contents + +- [left_prompt_segment()](#left_prompt_segment) +- [right_prompt_segment()](#right_prompt_segment) +- [last_left_bg()](#last_left_bg) +- [last_right_bg()](#last_right_bg) +- [update_left_prompt()](#update_left_prompt) +- [update_right_prompt()](#update_right_prompt) +- [p9k_async_callback()](#p9k_async_callback) +- [p9k_serialize_segment()](#p9k_serialize_segment) +- [serialize_segment()](#serialize_segment) +- [prompt_custom()](#prompt_custom) +- [build_left_prompt()](#build_left_prompt) +- [build_right_prompt()](#build_right_prompt) +- [powerlevel9k_preexec()](#powerlevel9k_preexec) +- [powerlevel9k_prepare_prompts()](#powerlevel9k_prepare_prompts) +- [p9k_chpwd()](#p9k_chpwd) +- [prompt_powerlevel9k_setup()](#prompt_powerlevel9k_setup) +- [prompt_powerlevel9k_teardown()](#prompt_powerlevel9k_teardown) + +## left_prompt_segment() +*Spawn a subshell to convert the data into a left prompt segment * + +#### Arguments + +- **$1** (string) Name - The stateful name of the function that was originally invoked (mandatory). +- **$2** (integer) Index - Segment array index +- **$3** (string) Background - Segment background color +- **$4** (string) Foreground - Segment foreground color +- **$5** (boolean) Bold - Whether the segment should be bold +- **$6** (string) Content - Segment content +- **$7** (string) Visual Identifier - Segment icon + + +## right_prompt_segment() +*Spawn a subshell to convert the data into a right prompt segment * + +#### Arguments + +- **$1** (string) Name - The stateful name of the function that was originally invoked (mandatory). +- **$2** (integer) Index - Segment array index +- **$3** (string) Background - Segment background color +- **$4** (string) Foreground - Segment foreground color +- **$5** (boolean) Bold - Whether the segment should be bold +- **$6** (string) Content - Segment content +- **$7** (string) Visual Identifier - Segment icon + + +## last_left_bg() +*This function determines the background of the previous VISIBLE segment in the left prompt. * + +#### Arguments + +- **$1** (integer) Index - Left prompt source segment index + + +## last_right_bg() +*This function determines the background of the previous VISIBLE segment in the right prompt. * + +#### Arguments + +- **$1** (integer) Index - Right prompt source segment index + + +## update_left_prompt() +*This function walks through the Left Prompt segment array and rebuilds the left prompt every time a subshell returns. * + +#### Arguments + +- *Function has no arguments.* + + +## update_right_prompt() +*This function walks through the Right Prompt segment array and rebuilds the right prompt every time a subshell returns. * + +#### Arguments + +- *Function has no arguments.* + + +## p9k_async_callback() +*This function is the heart of the async engine. Whenever a subshell is completed, this function is called to deal with the generated output. * + +#### Arguments + +- **$1** (string) Job - The name of the calling function or job +- **$2** (number) Code - Return code (If the value is -1, then it is likely that there is a bug) +- **$3** (string) Output - Resulting (stdout) output from the job +- **$4** (number) Exec_Time - Execution time, floating point (in seconds) +- **$5** (string) Err - Resulting (stderr) output from the job + + +## p9k_serialize_segment() +*This function processes the segment code in a subshell. When done, the resulting data is sent to `p9k_async_callback`. * + +#### Arguments + +- **$1** (string) Name - Segment name +- **$2** (string) State - Segment state +- **$3** (string) Alignment - left|right +- **$4** (integer) Index - Segment array index +- **$5** (boolean) Joined - If the segment should be joined +- **$6** (string) Background - Segment background color +- **$7** (string) Foreground - Segment foreground color +- **$8** (string) Content - Segment content +- **$9** (string) Visual identifier - Segment icon +- **$10** (string) Condition - The condition, if the segment should be printed (gets evaluated) + + +## serialize_segment() +*This function is a wrapper function that starts off the async process and passes the parameters from the segment code to the subshells. * + +#### Arguments + +- **...** (misc) The parameters passed from the segment code + + +## prompt_custom() +*The `custom` prompt provides a way for users to invoke commands and display the output in a segment. * + +#### Arguments + +- **$1** (string) Left|Right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined +- **$4** (string) Custom segment name + + +## build_left_prompt() +*This function loops through the left prompt elements and calls the related segment functions. * + +#### Arguments + +- *Function has no arguments.* + + +## build_right_prompt() +*This function loops through the right prompt elements and calls the related segment functions. * + +#### Arguments + +- *Function has no arguments.* + + +## powerlevel9k_preexec() +*This function is a hook that runs before the command runs. It sets the start timer. * + +#### Arguments + +- *Function has no arguments.* + + +## powerlevel9k_prepare_prompts() +*This function is a hook that is run before the prompts are created. If sets all the required variables for the prompts and then calls the prompt segment building functions. * + +#### Arguments + +- *Function has no arguments.* + + +## p9k_chpwd() +*This function is a hook into chpwd to add bindkey support. * + +#### Arguments + +- *Function has no arguments.* + + +## prompt_powerlevel9k_setup() +*This is the main function. It does the necessary checks, loads the required resources and sets the required hooks. * + +#### Arguments + +- *Function has no arguments.* + + +## prompt_powerlevel9k_teardown() +*This function removed PowerLevel9k hooks and resets the prompts. * + +#### Arguments + +- *Function has no arguments.* + + diff --git a/api/segments/core/background_jobs.md b/api/segments/core/background_jobs.md new file mode 100644 index 000000000..d41db7482 --- /dev/null +++ b/api/segments/core/background_jobs.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Background Jobs + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_background_jobs](#prompt_background_jobs) + +## prompt_background_jobs +*Displays the number of background jobs with an icon. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/battery.md b/api/segments/core/battery.md new file mode 100644 index 000000000..5f0e3185e --- /dev/null +++ b/api/segments/core/battery.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Battery + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_battery](#prompt_battery) + +## prompt_battery +*Displays the battery statys in levels and colors. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/command_execution_time.md b/api/segments/core/command_execution_time.md new file mode 100644 index 000000000..d86600a39 --- /dev/null +++ b/api/segments/core/command_execution_time.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Command Execution Time + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_command_execution_time](#prompt_command_execution_time) + +## prompt_command_execution_time +*Displays the duration the command needed to run. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/context.md b/api/segments/core/context.md new file mode 100644 index 000000000..c57d718d4 --- /dev/null +++ b/api/segments/core/context.md @@ -0,0 +1,32 @@ +# powerlevel9k Segment - Context + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_context](#prompt_context) + +## prompt_context +*Displays the context - user@hostname (who am I and where am I). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### Notes + +*If $DEFAULT_USER is not set, this prompt segment will always print. * + diff --git a/api/segments/core/date.md b/api/segments/core/date.md new file mode 100644 index 000000000..c98d3fefe --- /dev/null +++ b/api/segments/core/date.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Date + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_date](#prompt_date) + +## prompt_date +*Displays the system date. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/dir.md b/api/segments/core/dir.md new file mode 100644 index 000000000..f8047eaa0 --- /dev/null +++ b/api/segments/core/dir.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Dir Writable + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_dir](#prompt_dir) + +## prompt_dir +*Display information about the current working directory. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/dir_writable.md b/api/segments/core/dir_writable.md new file mode 100644 index 000000000..85228104a --- /dev/null +++ b/api/segments/core/dir_writable.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Dir Writable + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_dir_writable](#prompt_dir_writable) + +## prompt_dir_writable +*Display information about the user's permission to write in the current directory. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/disk_usage.md b/api/segments/core/disk_usage.md new file mode 100644 index 000000000..2953c29a9 --- /dev/null +++ b/api/segments/core/disk_usage.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Disk Usage + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_disk_usage](#prompt_disk_usage) + +## prompt_disk_usage +*Display information about the usage level of current partition. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/history.md b/api/segments/core/history.md new file mode 100644 index 000000000..5ed997fcd --- /dev/null +++ b/api/segments/core/history.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - History + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_history](#prompt_history) + +## prompt_history +*Display the command number (in local history). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/host.md b/api/segments/core/host.md new file mode 100644 index 000000000..6eb362207 --- /dev/null +++ b/api/segments/core/host.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Host + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_host](#prompt_host) + +## prompt_host +*Display information about the Host - machine (where am I). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/ip.md b/api/segments/core/ip.md new file mode 100644 index 000000000..bb85a7985 --- /dev/null +++ b/api/segments/core/ip.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - IP + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_ip](#prompt_ip) + +## prompt_ip +*Display the current IP address. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/load.md b/api/segments/core/load.md new file mode 100644 index 000000000..de20cf1da --- /dev/null +++ b/api/segments/core/load.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Load + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_load](#prompt_load) + +## prompt_load +*Display the current load. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/newline.md b/api/segments/core/newline.md new file mode 100644 index 000000000..24e911214 --- /dev/null +++ b/api/segments/core/newline.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Newline + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_newline](#prompt_newline) + +## prompt_newline +*Display a newline in your prompt, so you can do segments on multiple lines. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/os_icon.md b/api/segments/core/os_icon.md new file mode 100644 index 000000000..834d600ac --- /dev/null +++ b/api/segments/core/os_icon.md @@ -0,0 +1,32 @@ +# powerlevel9k Segment - OS Icon + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_os_icon](#prompt_os_icon) + +## prompt_os_icon +*Displays the OS icon only. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### Notes + +*Only displays the specific Linux distro icon if available, otherwise just uses the Tux icon. * + diff --git a/api/segments/core/public_ip.md b/api/segments/core/public_ip.md new file mode 100644 index 000000000..db9ea3f67 --- /dev/null +++ b/api/segments/core/public_ip.md @@ -0,0 +1,14 @@ +# powerlevel9k Segment - Public IP + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + diff --git a/api/segments/core/ram.md b/api/segments/core/ram.md new file mode 100644 index 000000000..ad6d71227 --- /dev/null +++ b/api/segments/core/ram.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Ram + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_ram](#prompt_ram) + +## prompt_ram +*Display information about the free RAM and used Swap. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/root_indicator.md b/api/segments/core/root_indicator.md new file mode 100644 index 000000000..9d1c1abca --- /dev/null +++ b/api/segments/core/root_indicator.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Root Indicator + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_root_indicator](#prompt_root_indicator) + +## prompt_root_indicator +*Displays an icon if user is root. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/ssh.md b/api/segments/core/ssh.md new file mode 100644 index 000000000..18805f332 --- /dev/null +++ b/api/segments/core/ssh.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - SSH + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_ssh](#prompt_ssh) + +## prompt_ssh +*Displays an SSH icon when connected. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/status.md b/api/segments/core/status.md new file mode 100644 index 000000000..d88642d70 --- /dev/null +++ b/api/segments/core/status.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Status + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_status](#prompt_status) + +## prompt_status +*Display an ok icon when no error occur, or hide the segment if option is set to false. When an error occurs, return the error code, or a cross icon if option is set. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/swap.md b/api/segments/core/swap.md new file mode 100644 index 000000000..7b1deee94 --- /dev/null +++ b/api/segments/core/swap.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Swap + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_swap](#prompt_swap) + +## prompt_swap +*Display information the swap file. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/time.md b/api/segments/core/time.md new file mode 100644 index 000000000..e40c900d9 --- /dev/null +++ b/api/segments/core/time.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Time + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_time](#prompt_time) + +## prompt_time +*Display the system time. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/core/user.md b/api/segments/core/user.md new file mode 100644 index 000000000..34ed01d9f --- /dev/null +++ b/api/segments/core/user.md @@ -0,0 +1,32 @@ +# powerlevel9k Segment - User + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_user](#prompt_user) + +## prompt_user +*Display information about the user (Who am I). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### Notes + +*If $DEFAULT_USER is not set, this prompt segment will always print. * + diff --git a/api/segments/core/vi_mode.md b/api/segments/core/vi_mode.md new file mode 100644 index 000000000..944b5726c --- /dev/null +++ b/api/segments/core/vi_mode.md @@ -0,0 +1,32 @@ +# powerlevel9k Segment - VI Mode + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_vi_mode](#prompt_vi_mode) + +## prompt_vi_mode +*Display information about the editing mode - Normal | Insert | Visual. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### Notes + +*Visual mode only works if the user has installed zsh-vimode-visual. * + diff --git a/api/segments/core/vpn_ip.md b/api/segments/core/vpn_ip.md new file mode 100644 index 000000000..b8caea10e --- /dev/null +++ b/api/segments/core/vpn_ip.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - VPN IP + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_vpn_ip](#prompt_vpn_ip) + +## prompt_vpn_ip +*Segment to display if the VPN is active. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/anaconda.md b/api/segments/developer/anaconda.md new file mode 100644 index 000000000..48f03fa6e --- /dev/null +++ b/api/segments/developer/anaconda.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Anaconda + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_anaconda](#prompt_anaconda) + +## prompt_anaconda +*Display the Anaconda Environment. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/aws.md b/api/segments/developer/aws.md new file mode 100644 index 000000000..001ef97e9 --- /dev/null +++ b/api/segments/developer/aws.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - AWS + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_aws](#prompt_aws) + +## prompt_aws +*Display the current AWS Profile. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/aws_eb_env.md b/api/segments/developer/aws_eb_env.md new file mode 100644 index 000000000..843f0ba95 --- /dev/null +++ b/api/segments/developer/aws_eb_env.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - AWS EB Environment + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_aws_eb_env](#prompt_aws_eb_env) + +## prompt_aws_eb_env +*Display the current Elastic Beanstalk environment. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/chruby.md b/api/segments/developer/chruby.md new file mode 100644 index 000000000..3abe33a58 --- /dev/null +++ b/api/segments/developer/chruby.md @@ -0,0 +1,33 @@ +# powerlevel9k Segment - chruby + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_chruby](#prompt_chruby) + +## prompt_chruby +*Display chruby information. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### See also + +- [[chruby_auto issue with ZSH](https://github.com/postmodern/chruby/issues/245).](#[chruby_auto issue with ZSH](https://github.com/postmodern/chruby/issues/245).) + + diff --git a/api/segments/developer/detect_virt.md b/api/segments/developer/detect_virt.md new file mode 100644 index 000000000..b5d9420a3 --- /dev/null +++ b/api/segments/developer/detect_virt.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Detect Virtualization + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_detect_virt](#prompt_detect_virt) + +## prompt_detect_virt +*Detection for virtualization (systemd based systems only). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/docker_machine.md b/api/segments/developer/docker_machine.md new file mode 100644 index 000000000..d784f5698 --- /dev/null +++ b/api/segments/developer/docker_machine.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Docker Machine + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_docker_machine](#prompt_docker_machine) + +## prompt_docker_machine +*Display the current Docker machine name. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/go_version.md b/api/segments/developer/go_version.md new file mode 100644 index 000000000..6f2a7b543 --- /dev/null +++ b/api/segments/developer/go_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Go Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_go_version](#prompt_go_version) + +## prompt_go_version +*Display the current Go version. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/java_version.md b/api/segments/developer/java_version.md new file mode 100644 index 000000000..e30c81eed --- /dev/null +++ b/api/segments/developer/java_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Java Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_java_version](#prompt_java_version) + +## prompt_java_version +*Display the current Java version. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/kubecontext.md b/api/segments/developer/kubecontext.md new file mode 100644 index 000000000..243cc4b50 --- /dev/null +++ b/api/segments/developer/kubecontext.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Kube Context + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_kubecontext](#prompt_kubecontext) + +## prompt_kubecontext +*Display the Kubernetes Current Context/Namespace. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/node_env.md b/api/segments/developer/node_env.md new file mode 100644 index 000000000..9521775f8 --- /dev/null +++ b/api/segments/developer/node_env.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Node Environment + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_node_env](#prompt_node_env) + +## prompt_node_env +*Display the current NodeEnv. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/node_version.md b/api/segments/developer/node_version.md new file mode 100644 index 000000000..fdcbc70cb --- /dev/null +++ b/api/segments/developer/node_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Node Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_node_version](#prompt_node_version) + +## prompt_node_version +*Display the current Node version. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/nvm.md b/api/segments/developer/nvm.md new file mode 100644 index 000000000..ec3b98341 --- /dev/null +++ b/api/segments/developer/nvm.md @@ -0,0 +1,32 @@ +# powerlevel9k Segment - NVM + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_nvm](#prompt_nvm) + +## prompt_nvm +*Display the current Node version from NVM. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### Notes + +*Only prints the segment if different than the default value. * + diff --git a/api/segments/developer/php_version.md b/api/segments/developer/php_version.md new file mode 100644 index 000000000..a1821d3f9 --- /dev/null +++ b/api/segments/developer/php_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - PHP Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_php_version](#prompt_php_version) + +## prompt_php_version +*Display the current PHP version number. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/pyenv.md b/api/segments/developer/pyenv.md new file mode 100644 index 000000000..6859fe382 --- /dev/null +++ b/api/segments/developer/pyenv.md @@ -0,0 +1,33 @@ +# powerlevel9k Segment - Python Environment + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_pyenv](#prompt_pyenv) + +## prompt_pyenv +*Display the current active python version (with restrictions). * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### See also + +- [[Choosing the Python Version](https://github.com/pyenv/pyenv#choosing-the-python-version)](#[Choosing the Python Version](https://github.com/pyenv/pyenv#choosing-the-python-version)) + + diff --git a/api/segments/developer/rbenv.md b/api/segments/developer/rbenv.md new file mode 100644 index 000000000..8c28be529 --- /dev/null +++ b/api/segments/developer/rbenv.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Ruby Environment + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_rbenv](#prompt_rbenv) + +## prompt_rbenv +*Display the current rbenv information. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/rspec_stats.md b/api/segments/developer/rspec_stats.md new file mode 100644 index 000000000..1e272ba54 --- /dev/null +++ b/api/segments/developer/rspec_stats.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - RSpec Statistics + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_rspec_stats](#prompt_rspec_stats) + +## prompt_rspec_stats +*Display the current RSpec test ratio. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/rust_version.md b/api/segments/developer/rust_version.md new file mode 100644 index 000000000..21344a8af --- /dev/null +++ b/api/segments/developer/rust_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Rust Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_rust_version](#prompt_rust_version) + +## prompt_rust_version +*Display the current Rust version number. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/rvm.md b/api/segments/developer/rvm.md new file mode 100644 index 000000000..fd2f6647f --- /dev/null +++ b/api/segments/developer/rvm.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - RVM + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_rvm](#prompt_rvm) + +## prompt_rvm +*Display Ruby Version Manager information. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/swift_version.md b/api/segments/developer/swift_version.md new file mode 100644 index 000000000..2670caaa7 --- /dev/null +++ b/api/segments/developer/swift_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Swift Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_swift_version](#prompt_swift_version) + +## prompt_swift_version +*Display the current Swift version. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/symfony2_tests.md b/api/segments/developer/symfony2_tests.md new file mode 100644 index 000000000..ad580f736 --- /dev/null +++ b/api/segments/developer/symfony2_tests.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Symfony2 Tests + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_symfony2_tests](#prompt_symfony2_tests) + +## prompt_symfony2_tests +*Display the current Symfony2-PHPUnit test ratio. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/symfony2_version.md b/api/segments/developer/symfony2_version.md new file mode 100644 index 000000000..9d1258d65 --- /dev/null +++ b/api/segments/developer/symfony2_version.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Symfony2 Version + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_symfony2_version](#prompt_symfony2_version) + +## prompt_symfony2_version +*Display the current Symfony2-Version. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/test_stats.md b/api/segments/developer/test_stats.md new file mode 100644 index 000000000..ed05532e6 --- /dev/null +++ b/api/segments/developer/test_stats.md @@ -0,0 +1,37 @@ +# powerlevel9k Support File - Test Statistics + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [build_test_stats](#build_test_stats) + +## build_test_stats +*Show a ratio of tests vs code. * + +#### Arguments + +- **$1** (string) of the calling segment +- **$2** (string) Alignment - left | right +- **$3** (integer) Index +- **$4** (bool) Whether the segment should be joined +- **$5** (string) Code Amount +- **$6** (string) Tests Amount +- **$7** (string) Headline +- **$8** (string) Icon + + +#### Notes + +*This function is called by prompt segments to display the information required. * + diff --git a/api/segments/developer/vcs.md b/api/segments/developer/vcs.md new file mode 100644 index 000000000..98fd81408 --- /dev/null +++ b/api/segments/developer/vcs.md @@ -0,0 +1,41 @@ +# powerlevel9k Segment - VCS + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [powerlevel9k_vcs_init](#powerlevel9k_vcs_init) +- [prompt_vcs](#prompt_vcs) + +## powerlevel9k_vcs_init +*Initializes the VCS segment by setting the required ZSH options. * + +#### Arguments + +- *Function has no arguments.* + + +#### Notes + +*This function is only called once. * + +## prompt_vcs +*Display the current VCS information. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/developer/virtualenv.md b/api/segments/developer/virtualenv.md new file mode 100644 index 000000000..5f8f77cba --- /dev/null +++ b/api/segments/developer/virtualenv.md @@ -0,0 +1,34 @@ +# powerlevel9k Segment - Virtual Environment + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_virtualenv](#prompt_virtualenv) + +## prompt_virtualenv +*Display the current working virtualenv. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + +#### See also + +- [[virtualenv (Python)](https://virtualenv.pypa.io/en/latest/)](#[virtualenv (Python)](https://virtualenv.pypa.io/en/latest/)) +- [for more information.](#for more information.) + + diff --git a/api/segments/other/dropbox.md b/api/segments/other/dropbox.md new file mode 100644 index 000000000..d2edb5b0f --- /dev/null +++ b/api/segments/other/dropbox.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Dropbox + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_dropbox](#prompt_dropbox) + +## prompt_dropbox +*Display information about the current Dropbox status. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/other/icons_test.md b/api/segments/other/icons_test.md new file mode 100644 index 000000000..d74994a45 --- /dev/null +++ b/api/segments/other/icons_test.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Test Icons + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_icons_test](#prompt_icons_test) + +## prompt_icons_test +*Print some test icons in a segment. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/other/openfoam.md b/api/segments/other/openfoam.md new file mode 100644 index 000000000..bd550bc63 --- /dev/null +++ b/api/segments/other/openfoam.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - Openfoam + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_openfoam](#prompt_openfoam) + +## prompt_openfoam +*Display information about Openfoam. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/api/segments/other/todo.md b/api/segments/other/todo.md new file mode 100644 index 000000000..2bed80543 --- /dev/null +++ b/api/segments/other/todo.md @@ -0,0 +1,28 @@ +# powerlevel9k Segment - ToDo + + +### Source(s) + +[https://github.com/bhilburn/powerlevel9k](#https://github.com/bhilburn/powerlevel9k) + + +### Author(s) + +- Ben Hilburn (bhilburn) +- Dominic Ritter (dritter) + + +## Table of Contents + +- [prompt_todo](#prompt_todo) + +## prompt_todo +*Display the number of tasks in your todo.sh file. * + +#### Arguments + +- **$1** (string) Alignment - left | right +- **$2** (integer) Segment index +- **$3** (boolean) Whether the segment should be joined + + diff --git a/functions/colors.zsh b/functions/colors.zsh index f38feb1fc..b6c482f19 100755 --- a/functions/colors.zsh +++ b/functions/colors.zsh @@ -1,24 +1,29 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Color Functions +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## +# @info +# This file contains some color-functions for powerlevel9k. +## ################################################################ -# Color functions -# This file holds some color-functions for -# the powerlevel9k-ZSH-theme -# https://github.com/bhilburn/powerlevel9k -################################################################ - +# @description +# This function checks if the terminal supports 256 colors. +# If it doesn't, an error message is displayed. +## +# @noargs +## +# @note +# You can bypass this check by setting `POWERLEVEL9K_IGNORE_TERM_COLORS=true`. +## function termColors() { - if [[ $POWERLEVEL9K_IGNORE_TERM_COLORS == true ]]; then - return - fi + [[ $POWERLEVEL9K_IGNORE_TERM_COLORS == true ]] && return local term_colors @@ -35,7 +40,13 @@ function termColors() { fi } -# get the proper color code if it does not exist as a name. +################################################################ +# @description +# This function gets the proper color code if it does not exist as a name. +## +# @args +# $1 misc Color to check (as a number or string) +## function getColor() { # no need to check numerical values if [[ "$1" = <-> ]]; then @@ -57,7 +68,19 @@ function getColor() { echo -n "$1" } -# empty paramenter resets (stops) background color +################################################################ +# @description +# Function to set the background color. +## +# @args +# $1 misc The background color. +## +# @returns +# An escape code string for (re)setting the background color. +## +# @note +# An empty paramenter resets (stops) background color. +## function backgroundColor() { if [[ -z $1 ]]; then echo -n "%k" @@ -66,7 +89,19 @@ function backgroundColor() { fi } -# empty paramenter resets (stops) foreground color +################################################################ +# @description +# Function to set the foreground color. +## +# @args +# $1 misc The foreground color. +## +# @returns +# An escape code string for (re)setting the foreground color. +## +# @note +# An empty paramenter resets (stops) foreground color. +## function foregroundColor() { if [[ -z $1 ]]; then echo -n "%f" @@ -75,8 +110,14 @@ function foregroundColor() { fi } -# Get numerical color codes. That way we translate ANSI codes -# into ZSH-Style color codes. +################################################################ +# @description +# Function to get numerical color codes. That way we translate +# ANSI codes into ZSH-Style color codes. +## +# @args +# $1 misc Number or string of color. +## function getColorCode() { # Check if given value is already numerical if [[ "$1" = <-> ]]; then @@ -373,7 +414,14 @@ function getColorCode() { fi } -# Check if two colors are equal, even if one is specified as ANSI code. +################################################################ +# @description +# Check if two colors are equal, even if one is specified as ANSI code. +## +# @args +# $1 misc First color (number or string) +# $2 misc Second color (number or string) +## function isSameColor() { if [[ "$1" == "NONE" || "$2" == "NONE" ]]; then return 1 diff --git a/functions/icons.zsh b/functions/icons.zsh index 84ba0f51f..4cd51ad21 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -1,48 +1,48 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k +# @title powerlevel9k Icon Functions +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## +# @info +# This file contains some the core icon definitions and +# icon-functions. # -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -################################################################ -# icons -# This file holds the icon definitions and -# icon-functions for the powerlevel9k-ZSH-theme -# https://github.com/bhilburn/powerlevel9k -################################################################ - -################################################################ -# These characters require the Powerline fonts to work properly. If you see -# boxes or bizarre characters below, your fonts are not correctly installed. If -# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to -# `compatible`. This shows all icons in regular symbols. -################################################################ +# These characters require the Powerline fonts to work properly. If you see +# boxes or bizarre characters below, your fonts are not correctly installed. If +# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to +# `compatible`. This shows all icons in regular symbols. +## typeset -gAH icons ################################################################ -# This function allows a segment to register the icons that it requires. -# These icons may be overriden by the user later. -# Arguments may be a direct call or an array. -# -# Direct call: +# @description +# This function allows a segment to register the icons that it requires. +# These icons may be overriden by the user later. +# Arguments may be a direct call or an array. +## +# @args +# $1 string Name of icon +# $2 string Generic icon +# $3 string Flat / Awesome Patched icon +# $4 string Awesome FontConfig icon +# $5 string Awesome Mapped FontConfig icon +# $6 string NerdFont Complete / FontConfig icon +## +# @note +# You can specify a string, unicode string or codepoint string (for Mapped fonts only). +## +# @usage # register_icon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' -# -# Calling with an array: -# prompt_icon=( -# 'Gen' # codepoint/text for generic icons/fonts -# "name_of_icon" # name under which icon will be registered -# $'\uXXX' # codepoint for flat / awesome-patched -# $'\uXXX' # codepoint for awesome-fontconfig -# '\u'$CODEPOINT_OF_AWESOME_xxx # codepoint for awesome-mapped-fontconfig -# $'\uXXX' # codepoint for nerdfont (complete / fontconfig) -# ) -# register_icon "$prompt_icon[@]" -# unset prompt_icon +## +# @example +# register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +## register_icon() { local map case $POWERLEVEL9K_MODE in @@ -52,7 +52,6 @@ register_icon() { 'nerdfont-complete'|'nerdfont-fontconfig') map=$6 ;; *) map=$2 ;; esac - # local arr=("$@") icons[$1]=${map} } @@ -169,8 +168,14 @@ case $POWERLEVEL9K_MODE in ;; esac -# Safety function for printing icons -# Prints the named icon, or if that icon is undefined, the string name. +################################################################ +# @description +# Safety function for printing icons. Prints the named icon, +# or if that icon is undefined, the string name. +## +# @args +# $1 string Name of icon +## function print_icon() { local icon_name=$1 local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 6cdd67bf8..351b4d5af 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -1,21 +1,21 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -################################################################ -# Utility functions -# This file holds some utility-functions for -# the powerlevel9k-ZSH-theme -# https://github.com/bhilburn/powerlevel9k -################################################################ +# @title powerlevel9k Utility Functions +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## +# @info +# This file contains some utility-functions for +# the powerlevel9k ZSH theme. +## -# Determine OS and version (if applicable) +############################################################### +# description +# Determine the OS and version (if applicable). case $(uname) in Darwin) OS='macOS' ;; CYGWIN_NT-*) OS='Windows' ;; @@ -31,9 +31,11 @@ case $(uname) in esac ################################################################ -# Identify Terminal Emulator -# Find out which emulator is being used for terminal specific options -# The testing order is important, since some override others +# description +# Identify Terminal Emulator. +## +# Find out which emulator is being used for terminal specific options +# The testing order is important, since some override others. if [[ "$TMUX" =~ "tmux" ]]; then readonly TERMINAL="tmux" elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then @@ -41,7 +43,7 @@ elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then readonly TERMINAL="appleterm" else - if [[ "$OS" == "OSX" ]]; then + if [[ "$OS" == "macOS" ]]; then local termtest=$(ps -o 'command=' -p $(ps -o 'ppid=' -p $$) | tail -1 | awk '{print $NF}') # test if we are in a sudo su - if [[ $termtest == "-" || $termtest == "root" ]]; then @@ -79,19 +81,39 @@ else unset uname fi -# Exits with 0 if a variable has been previously defined (even if empty) -# Takes the name of a variable that should be checked. +############################################################### +# @description +# This function determines if a variable has been previously +# defined, even if empty. +## +# @args +# $1 string The name of the variable that should be checked. +## +# @returns +# 0 if the variable has been defined. +## function defined() { local varname="$1" typeset -p "$varname" > /dev/null 2>&1 } -# Given the name of a variable and a default value, sets the variable -# value to the default only if it has not been defined. -# -# Typeset cannot set the value for an array, so this will only work -# for scalar values. +############################################################### +# @description +# This function determine if a variable has been previously defined, +# and only sets the value to the specified default if it hasn't. +## +# @args +# $1 string The name of the variable that should be checked. +# $2 string The default value +## +# @returns +# Nothing. +## +# @note +# Typeset cannot set the value for an array, so this will only work +# for scalar values. +## function set_default() { local varname="$1" local default_value="$2" @@ -99,10 +121,17 @@ function set_default() { defined "$varname" || typeset -g "$varname"="$default_value" } -# Converts large memory values into a human-readable unit (e.g., bytes --> GB) -# Takes two arguments: -# * $size - The number which should be prettified -# * $base - The base of the number (default Bytes) +############################################################### +# @description +# Converts large memory values into a human-readable unit (e.g., bytes --> GB) +## +# @args +# $1 integer Size - The number which should be prettified. +# $2 string Base - The base of the number (default Bytes). +## +# @note +# The base can be any of the following: B, K, M, G, T, P, E, Z, Y. +## printSizeHumanReadable() { typeset -F 2 size size="$1"+0.00001 @@ -128,13 +157,18 @@ printSizeHumanReadable() { echo "$size${extension[$index]}" } -# Gets the first value out of a list of items that is not empty. -# The items are examined by a callback-function. -# Takes two arguments: -# * $list - A list of items -# * $callback - A callback function to examine if the item is -# worthy. The callback function has access to -# the inner variable $item. +############################################################### +# @description +# Gets the first value out of a list of items that is not empty. +# The items are examined by a callback-function. +## +# @args +# $1 array A list of items. +# $2 string A callback function to examine if the item is worthy. +## +# @notes +# The callback function has access to the inner variable $item. +## function getRelevantItem() { local -a list local callback @@ -152,9 +186,15 @@ function getRelevantItem() { done } -# Determine the correct sed parameter. -# -# `sed` is unfortunately not consistent across OSes when it comes to flags. +############################################################### +# description +# Determines the correct sed parameter. +## +# noargs +## +# note +# `sed` is unfortunately not consistent across OSes when it comes to flags. +## SED_EXTENDED_REGEX_PARAMETER="-r" if [[ "$OS" == 'macOS' ]]; then local IS_BSD_SED="$(sed --version &>> /dev/null || echo "BSD sed")" @@ -173,11 +213,14 @@ for (( i=0; i <= ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}; i++ )) do POWERLEVEL9K_PROMPT_ELEMENTS+=${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[$i]%_joined} done -# Determine if the passed segment is used in the prompt -# -# Pass the name of the segment to this function to test for its presence in -# either the LEFT or RIGHT prompt arrays. -# * $1: The segment to be tested. +############################################################### +# @description +# Determine if the passed segment is used in either the LEFT or +# RIGHT prompt arrays. +## +# @args +# $1 string The segment to be tested. +## segment_in_use() { local key=$1 if [[ -n "${POWERLEVEL9K_PROMPT_ELEMENTS[(r)$key]}" ]]; then @@ -187,10 +230,13 @@ segment_in_use() { fi } -# Print a deprecation warning if an old segment is in use. -# Takes the name of an associative array that contains the -# deprecated segments as keys, the values contain the new -# segment names. +############################################################### +# @description +# Print a deprecation warning if an old segment is in use. +# @args +# $1 associative-array An associative array that contains the +# deprecated segments as keys, and the new segment names as values. +## print_deprecation_warning() { typeset -AH raw_deprecated_segments raw_deprecated_segments=(${(kvP@)1}) @@ -203,12 +249,16 @@ print_deprecation_warning() { done } -# A helper function to determine if a segment should be -# joined or promoted to a full one. -# Takes three arguments: -# * $1: The array index of the current segment -# * $2: The array index of the last printed segment -# * $3: The array of segments of the left or right prompt +############################################################### +# @description +# A helper function to determine if a segment should be +# joined or promoted to a full one. +## +# args +# $1 integer The array index of the current segment. +# $2 integer The array index of the last printed segment. +# $3 array The array of segments of the left or right prompt. +## function segmentShouldBeJoined() { local current_index=$1 local last_segment_index=$2 @@ -253,12 +303,15 @@ function segmentShouldBeJoined() { } ################################################################ -# Given a directory path, truncate it according to the settings. -# Parameters: -# * $1 Path: string - the directory path to be truncated -# * $2 Length: integer - length to truncate to -# * $3 Delimiter: string - the delimiter to use -# * $4 From: string - "right" | "middle". If omited, assumes right. +# @description +# Given a directory path, truncate it according to the settings. +## +# @args +# $1 string The directory path to be truncated. +# $2 integer Length to truncate to. +# $3 string Delimiter to use. +# $4 string Where to truncate from - "right" | "middle". If omited, assumes right. +## function truncatePath() { # if the current path is not 1 character long (e.g. "/" or "~") if (( ${#1} > 1 )); then @@ -328,15 +381,30 @@ function truncatePath() { fi } -# Given a directory path, truncate it according to the settings for -# `truncate_from_right` +############################################################### +# @description +# Given a directory path, truncate it according to the settings for +# `truncate_from_right`. +## +# @args +# $1 string Directory path. +## +# @note +# Deprecated. Use `truncatePath` instead. +## function truncatePathFromRight() { local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER:-1} echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \ "s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g" } -# Search recursively in parent folders for given file. +############################################################### +# @description +# Search recursively in parent folders for given file. +## +# @args +# $1 string Filename to search for. +## function upsearch () { if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then echo "$PWD" @@ -352,15 +420,29 @@ function upsearch () { fi } -# Union of two or more arrays -# USAGE: +############################################################### +# @description +# Union of two or more arrays. +## +# @args +# $@ arrays The arrays to combine. +## +# @returns +# array of unique items. +## +# @note +# This does not work with indexed arrays. +## +# @usage # union [arr1[ arr2[ ...]]] -# EXAMPLE: +## +# @example # $ arr1=('a' 'b' 'c') # $ arr2=('b' 'c' 'd') # $ arr2=('c' 'd' 'e') # $ union $arr1 $arr2 $arr3 # > a b c d e +## union() { typeset -U sections=("$@") echo $sections diff --git a/generator/default.p9k b/generator/default.p9k index fbe61744c..0123fab9c 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -1,12 +1,16 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Default Engine +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## +# @info +# This file contains the default generator for the powerlevel9k project. +## ################################################################ # DEFAULT ENGINE - Synchronous @@ -29,18 +33,21 @@ # right-left but reads the opposite, this isn't necessary for the other side. CURRENT_BG='NONE' -# Begin a left prompt segment -# Takes seven arguments: -# * $1 Name: string - Name of the function that was originally invoked (mandatory). -# * $2 Index: integer -# * $3 Background: string -# * $4 Foreground: string -# * $5 Bold: bool -# * $6 Content: string -# * $7 Visual identifier: string - Icon (must be a key of the icons array) -# The latter three can be omitted, set_default last_left_element_index 1 set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " +################################################################ +# @description +# Construct a left prompt segment +## +# @args +# $1 string Name of the function that was originally invoked (mandatory). +# $2 integer Index of the segment +# $3 string Background color +# $4 string Foreground color +# $5 bool Whether the segment should be bold +# $6 string Content of the segment +# $7 string Visual identifier (must be a key of the icons array) +## left_prompt_segment() { local current_index=$2 # Check if the segment should be joined with the previous one @@ -96,7 +103,12 @@ left_prompt_segment() { last_left_element_index=$current_index } -# End the left prompt, closes the final segment. +################################################################ +# @description +# End the left prompt, closes the final segment +## +# @noargs +## left_prompt_end() { if [[ -n $CURRENT_BG ]]; then echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" @@ -109,18 +121,24 @@ left_prompt_end() { CURRENT_RIGHT_BG='NONE' -# Begin a right prompt segment -# Takes seven arguments: -# * $1 Name: string - Name of the function that was originally invoked (mandatory). -# * $2 Index: integer -# * $3 Background: string -# * $4 Foreground: string -# * $5 Bold: bool -# * $6 Content: string -# * $7 Visual identifier: string - Icon (must be a key of the icons array) -# No ending for the right prompt segment is needed (unlike the left prompt, above). set_default last_right_element_index 1 set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " +################################################################ +# @description +# Construct a right prompt segment +## +# @args +# $1 string Name of the function that was originally invoked (mandatory). +# $2 integer Index of the segment +# $3 string Background color +# $4 string Foreground color +# $5 bool Whether the segment should be bold +# $6 string Content of the segment +# $7 string Visual identifier (must be a key of the icons array) +## +# @notes +# No ending for the right prompt segment is needed (unlike the left prompt, above). +## right_prompt_segment() { local current_index=$2 @@ -175,30 +193,23 @@ right_prompt_segment() { last_right_element_index=$current_index } -############################################################### -# This function wraps left_prompt_segment and right_prompt_segment to serializes a segment (for compatibility with the async branch) -# -# Parameters for serialize_segment: -# * $1 Name: string - Name of the segment -# * $2 State: string - The state the segment is in -# * $3 Alignment: string - left|right -# * $4 Index: integer -# * $5 Joined: bool - If the segment should be joined -# * $6 Background: string - The default background color of the segment -# * $7 Foreground: string - The default foreground color of the segment -# * $8 Content: string - Content of the segment -# * $9 Visual identifier: string - Icon of the segment -# * $10 Condition: string - The condition, if the segment should be printed (gets evaluated) -# -# Parameters for [left|right]_prompt_segment: -# * $1 Name: string - Name of the function that was originally invoked (mandatory). -# * $2 Index: integer -# * $3 Background: string -# * $4 Foreground: string -# * $5 Bold: bool -# * $6 Content: string -# * $7 Visual identifier: string - Icon (must be a key of the icons array) -# The latter three can be omitted, +################################################################ +# @description +# This function wraps `left_prompt_segment` and `right_prompt_segment` +# (for compatibility with the async generator). +## +# @args +# $1 string Name of the function that was originally invoked (mandatory). +# $2 string State of the segment. +# $3 string Alignment (left|right). +# $4 integer Index of the segment. +# $5 bool Whether the segment should be joined. +# $6 string Background color. +# $7 string Foreground color. +# $8 string Content of the segment. +# $9 string Visual identifier (must be a key of the icons array). +# $10 string The condition - if the segment should be shown (gets evaluated). +## serialize_segment() { local NAME="${1}" local STATE="${2}" @@ -281,8 +292,16 @@ serialize_segment() { CURRENT_BG='NONE' ################################################################ -# The 'custom` prompt provides a way for users to invoke commands and display -# the output in a segment. +# @description +# The `custom` prompt provides a way for users to invoke commands and display +# the output in a segment. +## +# @args +# $1 string Left|Right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +# $4 string Custom segment name +## prompt_custom() { local command=POWERLEVEL9K_CUSTOM_$4:u local segment_content="$(eval ${(P)command})" @@ -295,7 +314,14 @@ prompt_custom() { ################################################################ # Prompt processing and drawing ################################################################ -# Main prompt + +############################################################### +# @description +# This function loops through the left prompt elements and calls +# the related segment functions. +## +# @noargs +## build_left_prompt() { local index=1 local element joined @@ -320,7 +346,13 @@ build_left_prompt() { left_prompt_end } -# Right prompt +############################################################### +# @description +# This function loops through the right prompt elements and calls +# the related segment functions. +## +# @noargs +## build_right_prompt() { local index=1 local joined @@ -343,11 +375,26 @@ build_right_prompt() { done } +############################################################### +# @description +# This function is a hook that runs before the command runs. +# It sets the start timer. +## +# @noargs +## powerlevel9k_preexec() { _P9K_TIMER_START=$EPOCHREALTIME } set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +############################################################### +# @description +# This function is a hook that is run before the prompts are created. +# If sets all the required variables for the prompts and then +# calls the prompt segment building functions. +## +# @noargs +## powerlevel9k_prepare_prompts() { RETVAL=$? RETVALS=( "$pipestatus[@]" ) @@ -399,6 +446,24 @@ NEWLINE=' set_default POWERLEVEL9K_IGNORE_TERM_COLORS false set_default POWERLEVEL9K_IGNORE_TERM_LANG false +############################################################### +# @description +# This function is a hook into chpwd to add bindkey support. +## +# @noargs +## +p9k_chpwd() { + powerlevel9k_prepare_prompts + powerlevel9k_preexec +} + +############################################################### +# @description +# This is the main function. It does the necessary checks, +# loads the required resources and sets the required hooks. +## +# @noargs +## prompt_powerlevel9k_setup() { # The value below was set to better support 32-bit CPUs. # It's the maximum _signed_ integer value on 32-bit CPUs. @@ -458,8 +523,17 @@ prompt_powerlevel9k_setup() { # prepare prompts add-zsh-hook precmd powerlevel9k_prepare_prompts add-zsh-hook preexec powerlevel9k_preexec + + # hook into chpwd for bindkey support + chpwd_functions=(${chpwd_functions[@]} "p9k_chpwd") } +############################################################### +# @description +# This function removed PowerLevel9k hooks and resets the prompts. +## +# @noargs +## prompt_powerlevel9k_teardown() { add-zsh-hook -D precmd powerlevel9k_\* add-zsh-hook -D preexec powerlevel9k_\* diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index 3c8fd03cc..ddc8aa391 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -16,10 +16,10 @@ # This file contains an async generator for the powerlevel9k # project. It makes use of zsh-async in order to build the # prompts asynchronously. +# +# Please note that this is A WORK IN PROGRESS, so use at your own risk! ## -# Please note that this is A WORK IN PROGRESS, so use at your own risk! - # Debugging #ASYNC_DEBUG=1 @@ -27,11 +27,12 @@ # Prompt Segment Constructors ################################################################ +POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " ############################################################### # @description # Spawn a subshell to convert the data into a left prompt segment ## -# @arg +# @args # $1 string Name - The stateful name of the function that was originally invoked (mandatory). # $2 integer Index - Segment array index # $3 string Background - Segment background color @@ -40,7 +41,6 @@ # $6 string Content - Segment content # $7 string Visual Identifier - Segment icon ## -POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " left_prompt_segment() { # Name the parameters and add %K and %F to color variables local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" BOLD="${5}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" @@ -59,11 +59,12 @@ left_prompt_segment() { [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" } +POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " ############################################################### # @description # Spawn a subshell to convert the data into a right prompt segment ## -# @arg +# @args # $1 string Name - The stateful name of the function that was originally invoked (mandatory). # $2 integer Index - Segment array index # $3 string Background - Segment background color @@ -72,7 +73,6 @@ left_prompt_segment() { # $6 string Content - Segment content # $7 string Visual Identifier - Segment icon ## -POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " right_prompt_segment() { # Name the parameters and add %K and %F to color variables local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" @@ -100,7 +100,7 @@ right_prompt_segment() { # @description # This function determines the background of the previous VISIBLE segment in the left prompt. ## -# @arg +# @args # $1 integer Index - Left prompt source segment index ## last_left_bg() { @@ -121,7 +121,7 @@ last_left_bg() { # @description # This function determines the background of the previous VISIBLE segment in the right prompt. ## -# @arg +# @args # $1 integer Index - Right prompt source segment index ## last_right_bg() { @@ -138,6 +138,13 @@ last_right_bg() { echo "$LAST_BG" } +############################################################### +# @description +# This function walks through the Left Prompt segment array and rebuilds +# the left prompt every time a subshell returns. +## +# @noargs +## update_left_prompt() { local LBG LAST_LBG LSEGMENTS # Determine how many segments are visible in the left prompt @@ -182,6 +189,13 @@ update_left_prompt() { zle .reset-prompt } +############################################################### +# @description +# This function walks through the Right Prompt segment array and rebuilds +# the right prompt every time a subshell returns. +## +# @noargs +## update_right_prompt() { local RBG LAST_RBG RSEGMENTS # Determine how many segments are visible in the left prompt @@ -229,7 +243,7 @@ update_right_prompt() { # subshell is completed, this function is called to deal with # the generated output. ## -# @arg +# @args # $1 string Job - The name of the calling function or job # $2 number Code - Return code (If the value is -1, then it is likely that there is a bug) # $3 string Output - Resulting (stdout) output from the job @@ -330,7 +344,7 @@ p9k_async_callback() { # This function processes the segment code in a subshell. # When done, the resulting data is sent to `p9k_async_callback`. ## -# @arg +# @args # $1 string Name - Segment name # $2 string State - Segment state # $3 string Alignment - left|right @@ -404,7 +418,7 @@ p9k_serialize_segment() { # process and passes the parameters from the segment code to the # subshells. ## -# @arg +# @args # $@ misc The parameters passed from the segment code ## serialize_segment() { @@ -416,8 +430,15 @@ serialize_segment() { ################################################################ ################################################################ -# The 'custom` prompt provides a way for users to invoke commands and display -# the output in a segment. +# @description +# The `custom` prompt provides a way for users to invoke commands and display +# the output in a segment. +## +# @args +# $1 string Left|Right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +# $4 string Custom segment name prompt_custom() { local command=POWERLEVEL9K_CUSTOM_$4:u local segment_content="$(eval ${(P)command})" @@ -432,7 +453,7 @@ prompt_custom() { # This function loops through the left prompt elements and calls # the related segment functions. ## -# @noarg +# @noargs ## build_left_prompt() { local index=1 @@ -447,7 +468,7 @@ build_left_prompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then - "prompt_custom" "left" "${index}" "${element[8,-1]}" "${joined}" &! + "prompt_custom" "left" "${index}" "${joined}" "${element[8,-1]}" &! else # Could we display placeholders? # -> At most it could be static ones, but @@ -463,7 +484,7 @@ build_left_prompt() { # This function loops through the right prompt elements and calls # the related segment functions. ## -# @noarg +# @noargs ## build_right_prompt() { local index=1 @@ -491,7 +512,7 @@ build_right_prompt() { # This function is a hook that runs before the command runs. # It sets the start timer. ## -# @noarg +# @noargs ## powerlevel9k_preexec() { # The Timer is started here, but the end @@ -508,7 +529,7 @@ powerlevel9k_preexec() { # If sets all the required variables for the prompts and then # calls the prompt segment building functions. ## -# @noarg +# @noargs ## powerlevel9k_prepare_prompts() { setopt localoptions noshwordsplit @@ -588,6 +609,12 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" fi } +############################################################### +# @description +# This function is a hook into chpwd to add bindkey support. +## +# @noargs +## p9k_chpwd() { powerlevel9k_prepare_prompts powerlevel9k_preexec @@ -598,7 +625,7 @@ p9k_chpwd() { # This is the main function. It does the necessary checks, # loads the required resources and sets the required hooks. ## -# @noarg +# @noargs ## prompt_powerlevel9k_setup() { # The value below was set to better support 32-bit CPUs. @@ -681,3 +708,16 @@ prompt_powerlevel9k_setup() { # hook into chpwd for bindkey support chpwd_functions=(${chpwd_functions[@]} "p9k_chpwd") } + +############################################################### +# @description +# This function removed PowerLevel9k hooks and resets the prompts. +## +# @noargs +## +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROMPT= +} diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 79124bc50..002538caa 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1,20 +1,23 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k +# @title powerlevel9k Theme +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn +# Dominic Ritter +## +# @info +# This theme was inspired by [agnoster's Theme](https://gist.github.com/3712874) # -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -################################################################ -# For basic documentation, please refer to the README.md in the top-level -# directory. For more detailed documentation, refer to the project wiki, hosted -# on Github: https://github.com/bhilburn/powerlevel9k/wiki +# For basic documentation, please refer to the README.md in the top-level +# directory. For more detailed documentation, refer to the +# [project wiki](https://github.com/bhilburn/powerlevel9k/wiki). # -# There are a lot of easy ways you can customize your prompt segments and -# theming with simple variables defined in your `~/.zshrc`. +# There are a lot of easy ways you can customize your prompt segments and +# theming with simple variables defined in your `~/.zshrc`. Please refer to +# the `sample-zshrc` file for more details. ################################################################ ## Turn on for Debugging diff --git a/segments/core/background_jobs.p9k b/segments/core/background_jobs.p9k index 2b8466da7..146c84fcf 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/core/background_jobs.p9k @@ -1,21 +1,29 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Background Jobs +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## # Register icons # ⚙     register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' -################################################################ -# Segment to indicate background jobs with an icon. set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +################################################################ +# @description +# Displays the number of background jobs with an icon. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_background_jobs() { local background_jobs_number=${$(jobs -l | wc -l)// /} local wrong_lines=`jobs -l | awk '/pwd now/{ count++ } END {print count}'` diff --git a/segments/core/battery.p9k b/segments/core/battery.p9k index 8ebb0fdc7..264a78ae5 100644 --- a/segments/core/battery.p9k +++ b/segments/core/battery.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Battery +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # 🔋  🔋   register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' ################################################################ -# Segment that displays the battery status in levels and colors +# @description +# Displays the battery statys in levels and colors. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_battery() { # The battery can have four different states - default to 'unknown'. local current_state='unknown' diff --git a/segments/core/command_execution_time.p9k b/segments/core/command_execution_time.p9k index c08c76a7a..596b5466f 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/core/command_execution_time.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Command Execution Time +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' ################################################################ -# Display the duration the command needed to run. +# @description +# Displays the duration the command needed to run. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_command_execution_time() { set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 diff --git a/segments/core/context.p9k b/segments/core/context.p9k index 47bcd3c2e..bc5154942 100644 --- a/segments/core/context.p9k +++ b/segments/core/context.p9k @@ -1,19 +1,29 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Context +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -################################################################ -# Context: user@hostname (who am I and where am I) -# Note that if $DEFAULT_USER is not set, this prompt segment will always print set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false set_default POWERLEVEL9K_ALWAYS_SHOW_USER false set_default POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" +################################################################ +# @description +# Displays the context - user@hostname (who am I and where am I). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @note +# If $DEFAULT_USER is not set, this prompt segment will always print. +## prompt_context() { local current_state="DEFAULT" typeset -AH context_states diff --git a/segments/core/date.p9k b/segments/core/date.p9k index e6e9db760..0bd6911fd 100644 --- a/segments/core/date.p9k +++ b/segments/core/date.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Date +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' ################################################################ -# System date +# @description +# Displays the system date. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_date() { set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" diff --git a/segments/core/dir.p9k b/segments/core/dir.p9k index ffe7ef902..ba9c7240a 100644 --- a/segments/core/dir.p9k +++ b/segments/core/dir.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Dir Writable +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' #     @@ -18,14 +22,18 @@ register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME #     register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' -################################################################ -# Dir: current working directory -# Parameters: -# * $1 Alignment: string - left|right -# * $2 Index: integer set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +################################################################ +# @description +# Display information about the current working directory. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_dir() { # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE local current_path=$PWD # WAS: local current_path="$(print -P '%~')" diff --git a/segments/core/dir_writable.p9k b/segments/core/dir_writable.p9k index b6014e901..bb16a19fd 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/core/dir_writable.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Dir Writable +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' -############################################################### -# dir_writable: Display information about the user's permission to write in the current directory +################################################################ +# @description +# Display information about the user's permission to write in the current directory. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then serialize_segment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' diff --git a/segments/core/disk_usage.p9k b/segments/core/disk_usage.p9k index 2f3a3c1d8..ccc0694bb 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/core/disk_usage.p9k @@ -1,23 +1,34 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Disk Usage +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' -################################################################ -# Segment that indicates usage level of current partition. set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 +################################################################ +# @description +# Display information about the usage level of current partition. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_disk_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors diff --git a/segments/core/history.p9k b/segments/core/history.p9k index bc703b781..7a2839e7a 100644 --- a/segments/core/history.p9k +++ b/segments/core/history.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - History +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' ################################################################ -# Command number (in local history) +# @description +# Display the command number (in local history). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_history() { serialize_segment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' } diff --git a/segments/core/host.p9k b/segments/core/host.p9k index 936ddc7e7..e5c4eb370 100644 --- a/segments/core/host.p9k +++ b/segments/core/host.p9k @@ -1,22 +1,33 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Host +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' #    register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' -################################################################ -# Host: machine (where am I) set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +################################################################ +# @description +# Display information about the Host - machine (where am I). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_host() { local current_state="LOCAL" typeset -AH host_state diff --git a/segments/core/ip.p9k b/segments/core/ip.p9k index 36059ce01..4f4099729 100644 --- a/segments/core/ip.p9k +++ b/segments/core/ip.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - IP +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' ################################################################ -# Segment to display the current IP address +# @description +# Display the current IP address. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_ip() { if [[ "$OS" == "OSX" ]]; then if defined POWERLEVEL9K_IP_INTERFACE; then diff --git a/segments/core/load.p9k b/segments/core/load.p9k index 2445797c1..7ba055330 100644 --- a/segments/core/load.p9k +++ b/segments/core/load.p9k @@ -1,20 +1,31 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Load +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' -################################################################ -# Segment to display load set_default POWERLEVEL9K_LOAD_WHICH 5 +################################################################ +# @description +# Display the current load. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_load() { # The load segment can have three different states local current_state="unknown" diff --git a/segments/core/newline.p9k b/segments/core/newline.p9k index 2f9a3b9a6..8570314da 100644 --- a/segments/core/newline.p9k +++ b/segments/core/newline.p9k @@ -1,15 +1,23 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Newline +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## ################################################################ -# A newline in your prompt, so you can do segments on multiple lines. +# @description +# Display a newline in your prompt, so you can do segments on multiple lines. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_newline() { local lws newline [[ "$1" == "right" ]] && return diff --git a/segments/core/os_icon.p9k b/segments/core/os_icon.p9k index 1d5c1774a..607e0b996 100644 --- a/segments/core/os_icon.p9k +++ b/segments/core/os_icon.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - OS Icon +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# OS detection +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont case "$OS" in "macOS") #     @@ -122,7 +126,18 @@ case "$OS" in esac ################################################################ -# Segment to print a little OS icon +# @description +# Displays the OS icon only. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @note +# Only displays the specific Linux distro icon if available, +# otherwise just uses the Tux icon. +## prompt_os_icon() { serialize_segment "$0" "" $1 "$2" $3 "black" "white" $(print_icon "$OS_ICON") } diff --git a/segments/core/public_ip.p9k b/segments/core/public_ip.p9k index 80d0af5ac..38386454f 100644 --- a/segments/core/public_ip.p9k +++ b/segments/core/public_ip.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Public IP +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' #    diff --git a/segments/core/ram.p9k b/segments/core/ram.p9k index 0ed721874..0ac460510 100644 --- a/segments/core/ram.p9k +++ b/segments/core/ram.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Ram +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' ################################################################ -# Segment to display free RAM and used Swap +# @description +# Display information about the free RAM and used Swap. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_ram() { local base='' local ramfree=0 diff --git a/segments/core/root_indicator.p9k b/segments/core/root_indicator.p9k index 78938136d..cfe6df030 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/core/root_indicator.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Root Indicator +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⚡     register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' ################################################################ -# Segment to print an icon if user is root. +# @description +# Displays an icon if user is root. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_root_indicator() { if [[ "$UID" -eq 0 ]]; then serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' diff --git a/segments/core/ssh.p9k b/segments/core/ssh.p9k index c8553fb48..3c3773494 100644 --- a/segments/core/ssh.p9k +++ b/segments/core/ssh.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - SSH +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' ################################################################ -# Segment to display SSH icon when connected +# @description +# Displays an SSH icon when connected. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_ssh() { if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' diff --git a/segments/core/status.p9k b/segments/core/status.p9k index bf1634e4c..c342a7b18 100644 --- a/segments/core/status.p9k +++ b/segments/core/status.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Status +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ↵ ↵ ↵ ↵ ↵ register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' # ✔ ✔ ✔   @@ -16,10 +20,6 @@ register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWES # ✘ ✘ ✘   register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' -################################################################ -# Status: When an error occur, return the error code, or a cross icon if option is set -# Display an ok icon when no error occur, or hide the segment if option is set to false -# set_default POWERLEVEL9K_STATUS_CROSS false set_default POWERLEVEL9K_STATUS_OK true set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true @@ -41,6 +41,16 @@ exit_code_or_status() { fi } +################################################################ +# @description +# Display an ok icon when no error occur, or hide the segment if option is set to false. +# When an error occurs, return the error code, or a cross icon if option is set. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_status() { local ec_text local ec_sum diff --git a/segments/core/swap.p9k b/segments/core/swap.p9k index adf6b01bf..b73fbfb30 100644 --- a/segments/core/swap.p9k +++ b/segments/core/swap.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Swap +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' ################################################################ -# Segment to display Swap information +# @description +# Display information the swap file. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_swap() { local swap_used=0 local base='' diff --git a/segments/core/time.p9k b/segments/core/time.p9k index 7b1c02725..59595a11b 100644 --- a/segments/core/time.p9k +++ b/segments/core/time.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Time +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' ################################################################ -# System time +# @description +# Display the system time. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_time() { set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" diff --git a/segments/core/user.p9k b/segments/core/user.p9k index d35bd1c24..2de855a94 100644 --- a/segments/core/user.p9k +++ b/segments/core/user.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - User +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⚡     register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' #      @@ -16,10 +20,18 @@ register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AW #    register_icon "USER_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' -################################################################ -# User: user (who am I) -# Note that if $DEFAULT_USER is not set, this prompt segment will always print set_default POWERLEVEL9K_USER_TEMPLATE "%n" +################################################################ +# @description +# Display information about the user (Who am I). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +# @note +# If $DEFAULT_USER is not set, this prompt segment will always print. +## prompt_user() { local current_state="DEFAULT" typeset -AH user_state diff --git a/segments/core/vi_mode.p9k b/segments/core/vi_mode.p9k index 4885bbd09..a1775bea6 100644 --- a/segments/core/vi_mode.p9k +++ b/segments/core/vi_mode.p9k @@ -1,15 +1,13 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -# Visual mode only works if the user has installed zsh-vimode-visual -# (Requires https://github.com/b4b4r07/zsh-vimode-visual) +# @title powerlevel9k Segment - VI Mode +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## set_default "POWERLEVEL9K_VI_INSERT_MODE_STRING" "INSERT" set_default "POWERLEVEL9K_VI_COMMAND_MODE_STRING" "NORMAL" @@ -20,6 +18,21 @@ set_default "POWERLEVEL9K_VI_VISUAL_MODE_STRING" "VISUAL" # * $1 Alignment: string - left|right # * $2 Index: integer # * $3 Joined: bool - If the segment should be joined +################################################################ +# @description +# Display information about the editing mode - Normal | Insert | Visual. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @note +# Visual mode only works if the user has installed zsh-vimode-visual. +## +# @requires +# [zsh-vimode-visual](https://github.com/b4b4r07/zsh-vimode-visual) +## prompt_vi_mode() { local vi_mode local current_state @@ -191,7 +204,10 @@ function zle-keymap-select { break; ;; *) - zle reset-prompt + # About .reset-prompt see: + # https://github.com/sorin-ionescu/prezto/issues/1026 + # https://github.com/zsh-users/zsh-autosuggestions/issues/107#issuecomment-183824034 + zle .reset-prompt zle -R ;; esac diff --git a/segments/core/vpn_ip.p9k b/segments/core/vpn_ip.p9k index 99e684ff9..9cc0e61bd 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/core/vpn_ip.p9k @@ -1,21 +1,31 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - VPN IP +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' -################################################################ -# Segment to display if VPN is active set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" -# prompt if vpn active +################################################################ +# @description +# Segment to display if the VPN is active. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_vpn_ip() { for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) do diff --git a/segments/developer/anaconda.p9k b/segments/developer/anaconda.p9k index c1bf08760..6ccdfa3ce 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/developer/anaconda.p9k @@ -1,15 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Anaconda +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## ################################################################ # Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' @@ -19,7 +22,14 @@ set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" ################################################################ -# Anaconda Environment +# @description +# Display the Anaconda Environment. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_anaconda() { # Depending on the conda version, either might be set. This # variant works even if both are set. diff --git a/segments/developer/aws.p9k b/segments/developer/aws.p9k index d6bb3f562..43d78b170 100644 --- a/segments/developer/aws.p9k +++ b/segments/developer/aws.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - AWS +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' ################################################################ -# AWS Profile +# @description +# Display the current AWS Profile. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_aws() { local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" diff --git a/segments/developer/aws_eb_env.p9k b/segments/developer/aws_eb_env.p9k index d6b90199f..45204049a 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/developer/aws_eb_env.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - AWS EB Environment +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # 🌱 🌱 🌱 🌱  register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' ################################################################ -# Current Elastic Beanstalk environment +# @description +# Display the current Elastic Beanstalk environment. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_aws_eb_env() { local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') diff --git a/segments/developer/chruby.p9k b/segments/developer/chruby.p9k index b66dbcf5a..c51c610c4 100644 --- a/segments/developer/chruby.p9k +++ b/segments/developer/chruby.p9k @@ -1,20 +1,34 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - chruby +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ -# Segment to display chruby information -# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH +# Segment to display +################################################################ +# @description +# Display chruby information. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +# @see +# [chruby_auto issue with ZSH](https://github.com/postmodern/chruby/issues/245). +## prompt_chruby() { local chruby_env chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" diff --git a/segments/developer/detect_virt.p9k b/segments/developer/detect_virt.p9k index 9340a8f7f..a341df297 100644 --- a/segments/developer/detect_virt.p9k +++ b/segments/developer/detect_virt.p9k @@ -1,15 +1,23 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Detect Virtualization +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## ################################################################ -# Detection for virtualization (systemd based systems only) +# @description +# Detection for virtualization (systemd based systems only). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_detect_virt() { if ! command -v systemd-detect-virt > /dev/null; then return diff --git a/segments/developer/docker_machine.p9k b/segments/developer/docker_machine.p9k index 004cb3a91..16fb74973 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/developer/docker_machine.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Docker Machine +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' ################################################################ -# Docker machine +# @description +# Display the current Docker machine name. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_docker_machine() { local docker_machine="$DOCKER_MACHINE_NAME" diff --git a/segments/developer/go_version.p9k b/segments/developer/go_version.p9k index 959c379d5..aeffb2cf6 100644 --- a/segments/developer/go_version.p9k +++ b/segments/developer/go_version.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Go Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' ################################################################ -# GO prompt +# @description +# Display the current Go version. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_go_version() { local go_version local go_path diff --git a/segments/developer/java_version.p9k b/segments/developer/java_version.p9k new file mode 100644 index 000000000..6212a5b52 --- /dev/null +++ b/segments/developer/java_version.p9k @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# @title powerlevel9k Segment - Java Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## + +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont +# ☕ ☕  +register_icon "JAVA_ICON" 'Java' '' $'\u2615' $'\u2615' $'\uE256' + +################################################################ +# @description +# Display the current Java version. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +prompt_java_version() { + local java_version + java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) + if [[ -n "$java_version" ]]; then + serialize_segment "$0" "" $1 "$2" $3 "red" "white" "${java_version}" 'JAVA_ICON' + fi +} diff --git a/segments/developer/kubecontext.p9k b/segments/developer/kubecontext.p9k index b8488adab..df8ab73a2 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/developer/kubecontext.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Kube Context +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⎈ ⎈ ⎈ ⎈ ⎈ register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' ################################################################ -# Kubernetes Current Context/Namespace +# @description +# Display the Kubernetes Current Context/Namespace. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_kubecontext() { local kubectl_version="$(kubectl version --client 2>/dev/null)" diff --git a/segments/developer/node_env.p9k b/segments/developer/node_env.p9k index 0cc40ba93..0e74d4eed 100644 --- a/segments/developer/node_env.p9k +++ b/segments/developer/node_env.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Node Environment +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ -# Segment to display NodeEnv +# @description +# Display the current NodeEnv. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_node_env() { local node_env_path="$NODE_VIRTUAL_ENV" if [[ -n "$node_env_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then diff --git a/segments/developer/node_version.p9k b/segments/developer/node_version.p9k index 7ed98ae99..703a01226 100644 --- a/segments/developer/node_version.p9k +++ b/segments/developer/node_version.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Node Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ -# Segment to diplay Node version +# @description +# Display the current Node version. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_node_version() { local node_version=$(node -v 2>/dev/null) [[ -z "${node_version}" ]] && return diff --git a/segments/developer/nvm.p9k b/segments/developer/nvm.p9k index c5fb06b5e..2c2422d16 100644 --- a/segments/developer/nvm.p9k +++ b/segments/developer/nvm.p9k @@ -1,20 +1,33 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - NVM +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ -# Segment to display Node version from NVM -# Only prints the segment if different than the default value +# @description +# Display the current Node version from NVM. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @note +# Only prints the segment if different than the default value. +## prompt_nvm() { local node_version nvm_default (( $+functions[nvm_version] )) || return diff --git a/segments/developer/php_version.p9k b/segments/developer/php_version.p9k index 2a099932e..01b37a7de 100644 --- a/segments/developer/php_version.p9k +++ b/segments/developer/php_version.p9k @@ -1,20 +1,35 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 +# @title powerlevel9k Segment - PHP Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## + ################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont +#     +register_icon "PHP_ICON" 'PHP' $'\uF457' $'\uF457' $'\uF457' $'\uE73D' ################################################################ -# Segment to display PHP version number +# @description +# Display the current PHP version number. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_php_version() { local php_version php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") if [[ -n "$php_version" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "$php_version" + serialize_segment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "${php_version}" 'PHP_ICON' fi } diff --git a/segments/developer/pyenv.p9k b/segments/developer/pyenv.p9k index 5219e5f21..00dc38024 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/developer/pyenv.p9k @@ -1,20 +1,33 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Python Environment +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ -# pyenv: current active python version (with restrictions) -# https://github.com/pyenv/pyenv#choosing-the-python-version +# @description +# Display the current active python version (with restrictions). +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @see +# [Choosing the Python Version](https://github.com/pyenv/pyenv#choosing-the-python-version) +## prompt_pyenv() { if [[ -n "$PYENV_VERSION" ]]; then serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' diff --git a/segments/developer/rbenv.p9k b/segments/developer/rbenv.p9k index 25bdf4080..ea1953cfa 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/developer/rbenv.p9k @@ -1,20 +1,31 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Ruby Environment +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' -################################################################ -# Segment to display rbenv information set_default POWERLEVEL9K_RBENV_ALWAYS false +################################################################ +# @description +# Display the current rbenv information. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_rbenv() { if which rbenv 2>/dev/null >&2; then local rbenv_version_name="$(rbenv version-name)" diff --git a/segments/developer/rspec_stats.p9k b/segments/developer/rspec_stats.p9k index 58231764c..b78cdd7c8 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/developer/rspec_stats.p9k @@ -1,22 +1,26 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -# Register icons -#     -register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +# @title powerlevel9k Segment - RSpec Statistics +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Source test stats script +# Source test stats script & icons source $p9k_directory/segments/developer/test_stats.p9k -################################################################ -# Segment to display RSpec test ratio +############################################################### +# @description +# Display the current RSpec test ratio. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_rspec_stats() { if [[ (-d app && -d spec) ]]; then local code_amount tests_amount diff --git a/segments/developer/rust_version.p9k b/segments/developer/rust_version.p9k index 89b3e2f1f..cb7b6f639 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/developer/rust_version.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Rust Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' ################################################################ -# Segment to display Rust version number +# @description +# Display the current Rust version number. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_rust_version() { local rust_version rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') diff --git a/segments/developer/rvm.p9k b/segments/developer/rvm.p9k index cd29c1daf..a807f3c39 100644 --- a/segments/developer/rvm.p9k +++ b/segments/developer/rvm.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - RVM +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ -# Segment to display Ruby Version Manager information +# @description +# Display Ruby Version Manager information. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_rvm() { local version_and_gemset=${rvm_env_string/ruby-} diff --git a/segments/developer/swift_version.p9k b/segments/developer/swift_version.p9k index e23b2da77..eb68c3080 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/developer/swift_version.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Swift Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' ################################################################ -# Segment to display Swift version +# @description +# Display the current Swift version. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_swift_version() { # Get the first number as this is probably the "main" version number.. local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) diff --git a/segments/developer/symfony2_tests.p9k b/segments/developer/symfony2_tests.p9k index f8750e23d..b5af15be8 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/developer/symfony2_tests.p9k @@ -1,22 +1,26 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -# Register icons -#     -register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +# @title powerlevel9k Segment - Symfony2 Tests +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Source test stats script +# Source test stats script & icons source $p9k_directory/segments/developer/test_stats.p9k ################################################################ -# Symfony2-PHPUnit test ratio +# @description +# Display the current Symfony2-PHPUnit test ratio. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_symfony2_tests() { if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then local code_amount tests_amount diff --git a/segments/developer/symfony2_version.p9k b/segments/developer/symfony2_version.p9k index 9b3391e0c..5ff58c900 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/developer/symfony2_version.p9k @@ -1,19 +1,31 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Symfony2 Version +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # Register icons #  register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' ################################################################ -# Segment to display Symfony2-Version +# @description +# Display the current Symfony2-Version. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version diff --git a/segments/developer/test_stats.p9k b/segments/developer/test_stats.p9k index a6f3aa481..4072b8551 100644 --- a/segments/developer/test_stats.p9k +++ b/segments/developer/test_stats.p9k @@ -1,24 +1,37 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 +# @title powerlevel9k Support File - Test Statistics +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## + ################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont +#     +register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' ################################################################ -# Show a ratio of tests vs code -# Parameters for build_test_stats -# * $1 Name: string - Name of the calling segment -# * $2 Align: string - left|right -# * $3 Index: integer -# * $4 Joined: bool -# * $5 Code Amount: string -# * $6 Tests Amount: string -# * $7 Headline: string -# * $8 Icon: string +# @description +# Show a ratio of tests vs code. +## +# @args +# $1 string of the calling segment +# $2 string Alignment - left | right +# $3 integer Index +# $4 bool Whether the segment should be joined +# $5 string Code Amount +# $6 string Tests Amount +# $7 string Headline +# $8 string Icon +## +# @note +# This function is called by prompt segments to display the information required. build_test_stats() { local code_amount="$5" local tests_amount="$6"+0.00001 diff --git a/segments/developer/vcs.p9k b/segments/developer/vcs.p9k index 99527242b..b0604e6ca 100644 --- a/segments/developer/vcs.p9k +++ b/segments/developer/vcs.p9k @@ -1,14 +1,18 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - VCS +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' # ●     @@ -65,6 +69,15 @@ source "${p9k_directory}/functions/vcs.zsh" set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" # Default: Just display the first 8 characters of our changeset-ID. set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" +################################################################ +# @description +# Initializes the VCS segment by setting the required ZSH options. +## +# @noargs +## +# @note +# This function is only called once. +## powerlevel9k_vcs_init() { if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" @@ -126,7 +139,14 @@ powerlevel9k_vcs_init() { } ################################################################ -# Segment to show VCS information +# @description +# Display the current VCS information. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_vcs() { VCS_WORKDIR_DIRTY=false VCS_WORKDIR_HALF_DIRTY=false diff --git a/segments/developer/virtualenv.p9k b/segments/developer/virtualenv.p9k index 8125f3df9..d4c7d02fc 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/developer/virtualenv.p9k @@ -1,21 +1,33 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Virtual Environment +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ -# Virtualenv: current working virtualenv -# More information on virtualenv (Python): -# https://virtualenv.pypa.io/en/latest/ +# @description +# Display the current working virtualenv. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +# @see +# [virtualenv (Python)](https://virtualenv.pypa.io/en/latest/) +# for more information. prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then diff --git a/segments/other/dropbox.p9k b/segments/other/dropbox.p9k index 468ca99cf..e37d58508 100644 --- a/segments/other/dropbox.p9k +++ b/segments/other/dropbox.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Dropbox +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' ################################################################ -# Dropbox status +# @description +# Display information about the current Dropbox status. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_dropbox() { # The first column is just the directory, so cut it local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" diff --git a/segments/other/icons_test.p9k b/segments/other/icons_test.p9k index d0976ce96..61bdeffc6 100644 --- a/segments/other/icons_test.p9k +++ b/segments/other/icons_test.p9k @@ -1,15 +1,23 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Test Icons +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## ################################################################ -# Test icons +# @description +# Print some test icons in a segment. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_icons_test() { for key in ${(@k)icons}; do # The lower color spectrum in ZSH makes big steps. Choosing diff --git a/segments/other/openfoam.p9k b/segments/other/openfoam.p9k index a5187f39a..c79079c78 100644 --- a/segments/other/openfoam.p9k +++ b/segments/other/openfoam.p9k @@ -1,15 +1,23 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - Openfoam +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## ################################################################ -# Display openfoam information +# @description +# Display information about Openfoam. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_openfoam() { local wm_project_version="$WM_PROJECT_VERSION" local wm_fork="$WM_FORK" diff --git a/segments/other/todo.p9k b/segments/other/todo.p9k index e028f9d7f..a0f8bc70b 100644 --- a/segments/other/todo.p9k +++ b/segments/other/todo.p9k @@ -1,19 +1,30 @@ #!/usr/bin/env zsh # vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 ################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ +# @title powerlevel9k Segment - ToDo +# @source https://github.com/bhilburn/powerlevel9k +## +# @authors +# Ben Hilburn (bhilburn) +# Dominic Ritter (dritter) +## -# Register icons +################################################################ +# Register segment icon +# Parameters: +# name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ☑ ☑ ☑   register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' ################################################################ -# todo.sh: shows the number of tasks in your todo.sh file +# @description +# Display the number of tasks in your todo.sh file. +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') From 78ed8349375433c4633512762a105fa4ba30f70e Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 11:34:04 +0400 Subject: [PATCH 30/55] MAJOR UPDATE CHANGES: - flattened `segments` folder, but kept `segments\custom`. - added function `updateEnvironmentVars` to automatically change user variables. NOTE: There may be minor issues with arrays, so this still needs review. - added local keyword to variables where appropriate. - streamlined P9K_PROMPT_ELEMENT generation. - added ability to autoload segments to `build_x_prompt` when user changed `P9K_x_PROMPT_ELEMENT` arrays. - added tracking of loaded segments using `loadedSegments`. - fixed coding error in `prompt_status`. - change all internal functions to use camelCase. Exceptions are listed below: - prompt functions still use `prompt_x` so that we can differentiate between internal (core) functionality and segments. - `prompt_powerlevel9k_setup`, `prompt_powerlevel9k_teardown`, and `p9k_preexec`. - replaced variables `POWERLEVEL9K_` -> `P9K_` and `powerlevel9k_` -> `p9k_`. TODO: - Decide on a default variable naming scheme. - Update code & comments in `segments/vcs.p9k` and `functions/vcs.zsh`. --- README.md | 222 +++++------ api/functions/colors.md | 2 +- api/functions/icons.md | 14 +- api/functions/utilities.md | 49 +-- api/generator/default.md | 42 +- api/generator/zsh-async.md | 40 +- api/segments/{developer => }/anaconda.md | 0 api/segments/{developer => }/aws.md | 0 api/segments/{developer => }/aws_eb_env.md | 0 api/segments/{core => }/background_jobs.md | 0 api/segments/{core => }/battery.md | 0 api/segments/{developer => }/chruby.md | 0 .../{core => }/command_execution_time.md | 0 api/segments/{core => }/context.md | 0 api/segments/{core => }/date.md | 0 api/segments/{developer => }/detect_virt.md | 0 api/segments/{core => }/dir.md | 0 api/segments/{core => }/dir_writable.md | 0 api/segments/{core => }/disk_usage.md | 0 .../{developer => }/docker_machine.md | 0 api/segments/{other => }/dropbox.md | 0 api/segments/{developer => }/go_version.md | 0 api/segments/{core => }/history.md | 0 api/segments/{core => }/host.md | 0 api/segments/{other => }/icons_test.md | 0 api/segments/{core => }/ip.md | 0 api/segments/{developer => }/java_version.md | 0 api/segments/{developer => }/kubecontext.md | 0 api/segments/{core => }/load.md | 0 api/segments/{core => }/newline.md | 0 api/segments/{developer => }/node_env.md | 0 api/segments/{developer => }/node_version.md | 0 api/segments/{developer => }/nvm.md | 0 api/segments/{other => }/openfoam.md | 0 api/segments/{core => }/os_icon.md | 0 api/segments/{developer => }/php_version.md | 0 api/segments/{core => }/public_ip.md | 0 api/segments/{developer => }/pyenv.md | 0 api/segments/{core => }/ram.md | 0 api/segments/{developer => }/rbenv.md | 0 api/segments/{core => }/root_indicator.md | 0 api/segments/{developer => }/rspec_stats.md | 0 api/segments/{developer => }/rust_version.md | 0 api/segments/{developer => }/rvm.md | 0 api/segments/{core => }/ssh.md | 0 api/segments/{core => }/status.md | 0 api/segments/{core => }/swap.md | 0 api/segments/{developer => }/swift_version.md | 0 .../{developer => }/symfony2_tests.md | 0 .../{developer => }/symfony2_version.md | 0 api/segments/{developer => }/test_stats.md | 0 api/segments/{core => }/time.md | 0 api/segments/{other => }/todo.md | 0 api/segments/{core => }/user.md | 0 api/segments/{developer => }/vcs.md | 4 +- api/segments/{core => }/vi_mode.md | 0 api/segments/{developer => }/virtualenv.md | 0 api/segments/{core => }/vpn_ip.md | 0 docker/base-4.3.11/Dockerfile | 2 +- docker/base-5.0.3/Dockerfile | 2 +- docker/base-5.1.1/Dockerfile | 2 +- docker/base-5.2/Dockerfile | 2 +- functions/colors.zsh | 10 +- functions/icons.zsh | 29 +- functions/utilities.zsh | 101 ++--- functions/vcs.zsh | 34 +- generator/default.p9k | 161 ++++---- generator/zsh-async.p9k | 128 +++---- powerlevel9k.zsh-theme | 58 +-- segments/{developer => }/anaconda.p9k | 8 +- segments/{developer => }/aws.p9k | 4 +- segments/{developer => }/aws_eb_env.p9k | 4 +- segments/{core => }/background_jobs.p9k | 10 +- segments/{core => }/battery.p9k | 28 +- segments/{developer => }/chruby.p9k | 4 +- .../{core => }/command_execution_time.p9k | 14 +- segments/{core => }/context.p9k | 14 +- segments/{core => }/date.p9k | 6 +- segments/{developer => }/detect_virt.p9k | 4 +- segments/{core => }/dir.p9k | 92 ++--- segments/{core => }/dir_writable.p9k | 4 +- segments/{core => }/disk_usage.p9k | 16 +- segments/{developer => }/docker_machine.p9k | 4 +- segments/{other => }/dropbox.p9k | 4 +- segments/{developer => }/go_version.p9k | 4 +- segments/{core => }/history.p9k | 4 +- segments/{core => }/host.p9k | 12 +- segments/{other => }/icons_test.p9k | 2 +- segments/{core => }/ip.p9k | 12 +- segments/{developer => }/java_version.p9k | 4 +- segments/{developer => }/kubecontext.p9k | 4 +- segments/{core => }/load.p9k | 8 +- segments/{core => }/newline.p9k | 12 +- segments/{developer => }/node_env.p9k | 4 +- segments/{developer => }/node_version.p9k | 4 +- segments/{developer => }/nvm.p9k | 4 +- segments/{other => }/openfoam.p9k | 4 +- segments/{core => }/os_icon.p9k | 40 +- segments/{developer => }/php_version.p9k | 4 +- segments/{core => }/public_ip.p9k | 46 +-- segments/{developer => }/pyenv.p9k | 4 +- segments/{core => }/ram.p9k | 4 +- segments/{developer => }/rbenv.p9k | 10 +- segments/{core => }/root_indicator.p9k | 4 +- segments/{developer => }/rspec_stats.p9k | 2 +- segments/{developer => }/rust_version.p9k | 4 +- segments/{developer => }/rvm.p9k | 4 +- segments/{core => }/ssh.p9k | 4 +- segments/{core => }/status.p9k | 60 +-- segments/{core => }/swap.p9k | 4 +- segments/{developer => }/swift_version.p9k | 4 +- segments/{developer => }/symfony2_tests.p9k | 2 +- segments/{developer => }/symfony2_version.p9k | 4 +- segments/{developer => }/test_stats.p9k | 8 +- segments/{core => }/time.p9k | 6 +- segments/{other => }/todo.p9k | 4 +- segments/{core => }/user.p9k | 16 +- segments/{developer => }/vcs.p9k | 84 ++-- segments/{core => }/vi_mode.p9k | 62 +-- segments/{developer => }/virtualenv.p9k | 4 +- segments/{core => }/vpn_ip.p9k | 8 +- test/functions/icons.spec | 114 +++--- test/functions/utilities.spec | 2 +- test/powerlevel9k.spec | 80 ++-- test/segments/command_execution_time.spec | 66 ++-- test/segments/dir.spec | 362 +++++++++--------- test/segments/go_version.spec | 40 +- test/segments/kubecontext.spec | 22 +- test/segments/rust_version.spec | 16 +- test/segments/vcs.spec | 42 +- 130 files changed, 1169 insertions(+), 1163 deletions(-) rename api/segments/{developer => }/anaconda.md (100%) rename api/segments/{developer => }/aws.md (100%) rename api/segments/{developer => }/aws_eb_env.md (100%) rename api/segments/{core => }/background_jobs.md (100%) rename api/segments/{core => }/battery.md (100%) rename api/segments/{developer => }/chruby.md (100%) rename api/segments/{core => }/command_execution_time.md (100%) rename api/segments/{core => }/context.md (100%) rename api/segments/{core => }/date.md (100%) rename api/segments/{developer => }/detect_virt.md (100%) rename api/segments/{core => }/dir.md (100%) rename api/segments/{core => }/dir_writable.md (100%) rename api/segments/{core => }/disk_usage.md (100%) rename api/segments/{developer => }/docker_machine.md (100%) rename api/segments/{other => }/dropbox.md (100%) rename api/segments/{developer => }/go_version.md (100%) rename api/segments/{core => }/history.md (100%) rename api/segments/{core => }/host.md (100%) rename api/segments/{other => }/icons_test.md (100%) rename api/segments/{core => }/ip.md (100%) rename api/segments/{developer => }/java_version.md (100%) rename api/segments/{developer => }/kubecontext.md (100%) rename api/segments/{core => }/load.md (100%) rename api/segments/{core => }/newline.md (100%) rename api/segments/{developer => }/node_env.md (100%) rename api/segments/{developer => }/node_version.md (100%) rename api/segments/{developer => }/nvm.md (100%) rename api/segments/{other => }/openfoam.md (100%) rename api/segments/{core => }/os_icon.md (100%) rename api/segments/{developer => }/php_version.md (100%) rename api/segments/{core => }/public_ip.md (100%) rename api/segments/{developer => }/pyenv.md (100%) rename api/segments/{core => }/ram.md (100%) rename api/segments/{developer => }/rbenv.md (100%) rename api/segments/{core => }/root_indicator.md (100%) rename api/segments/{developer => }/rspec_stats.md (100%) rename api/segments/{developer => }/rust_version.md (100%) rename api/segments/{developer => }/rvm.md (100%) rename api/segments/{core => }/ssh.md (100%) rename api/segments/{core => }/status.md (100%) rename api/segments/{core => }/swap.md (100%) rename api/segments/{developer => }/swift_version.md (100%) rename api/segments/{developer => }/symfony2_tests.md (100%) rename api/segments/{developer => }/symfony2_version.md (100%) rename api/segments/{developer => }/test_stats.md (100%) rename api/segments/{core => }/time.md (100%) rename api/segments/{other => }/todo.md (100%) rename api/segments/{core => }/user.md (100%) rename api/segments/{developer => }/vcs.md (89%) rename api/segments/{core => }/vi_mode.md (100%) rename api/segments/{developer => }/virtualenv.md (100%) rename api/segments/{core => }/vpn_ip.md (100%) rename segments/{developer => }/anaconda.p9k (75%) rename segments/{developer => }/aws.p9k (84%) rename segments/{developer => }/aws_eb_env.p9k (85%) rename segments/{core => }/background_jobs.p9k (68%) rename segments/{core => }/battery.p9k (73%) rename segments/{developer => }/chruby.p9k (86%) rename segments/{core => }/command_execution_time.p9k (74%) rename segments/{core => }/context.p9k (70%) rename segments/{core => }/date.p9k (76%) rename segments/{developer => }/detect_virt.p9k (84%) rename segments/{core => }/dir.p9k (69%) rename segments/{core => }/dir_writable.p9k (84%) rename segments/{core => }/disk_usage.p9k (70%) rename segments/{developer => }/docker_machine.p9k (83%) rename segments/{other => }/dropbox.p9k (86%) rename segments/{developer => }/go_version.p9k (88%) rename segments/{core => }/history.p9k (84%) rename segments/{core => }/host.p9k (74%) rename segments/{other => }/icons_test.p9k (90%) rename segments/{core => }/ip.p9k (79%) rename segments/{developer => }/java_version.p9k (86%) rename segments/{developer => }/kubecontext.p9k (89%) rename segments/{core => }/load.p9k (85%) rename segments/{core => }/newline.p9k (70%) rename segments/{developer => }/node_env.p9k (86%) rename segments/{developer => }/node_version.p9k (84%) rename segments/{developer => }/nvm.p9k (87%) rename segments/{other => }/openfoam.p9k (78%) rename segments/{core => }/os_icon.p9k (68%) rename segments/{developer => }/php_version.p9k (85%) rename segments/{core => }/public_ip.p9k (54%) rename segments/{developer => }/pyenv.p9k (85%) rename segments/{core => }/ram.p9k (86%) rename segments/{developer => }/rbenv.p9k (74%) rename segments/{core => }/root_indicator.p9k (83%) rename segments/{developer => }/rspec_stats.p9k (93%) rename segments/{developer => }/rust_version.p9k (85%) rename segments/{developer => }/rvm.p9k (82%) rename segments/{core => }/ssh.p9k (85%) rename segments/{core => }/status.p9k (50%) rename segments/{core => }/swap.p9k (86%) rename segments/{developer => }/swift_version.p9k (87%) rename segments/{developer => }/symfony2_tests.p9k (94%) rename segments/{developer => }/symfony2_version.p9k (86%) rename segments/{developer => }/test_stats.p9k (74%) rename segments/{core => }/time.p9k (76%) rename segments/{other => }/todo.p9k (84%) rename segments/{core => }/user.p9k (72%) rename segments/{developer => }/vcs.p9k (57%) rename segments/{core => }/vi_mode.p9k (72%) rename segments/{developer => }/virtualenv.p9k (85%) rename segments/{core => }/vpn_ip.p9k (72%) diff --git a/README.md b/README.md index 38e34a593..5c5fd2355 100644 --- a/README.md +++ b/README.md @@ -70,16 +70,16 @@ variables to your `~/.zshrc`. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt| -|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt| +|`P9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt| +|`P9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt| The table above shows the default values, so if you wanted to set these variables manually, you would put the following in your `~/.zshrc`: ```zsh -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) +P9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) +P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) ``` #### Available Prompt Segments The segments that are currently available are: @@ -168,12 +168,12 @@ Special configuration variables: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| -|`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| +|`P9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| +|`P9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| Additionally the following segment specific parameters can be used to customize -it: `POWERLEVEL9K_PYTHON_ICON`, `POWERLEVEL9K_ANACONDA_BACKGROUND`, and -`POWERLEVEL9K_ANACONDA_FOREGROUND`. +it: `P9K_PYTHON_ICON`, `P9K_ANACONDA_BACKGROUND`, and +`P9K_ANACONDA_FOREGROUND`. ##### aws @@ -190,8 +190,8 @@ your `~/.zshrc`: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE`|`true`|If there is more than one background job, this segment will show the number of jobs. Set this to `false` to turn this feature off.| -`POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS`|`false`|Always show the jobs count (even if it's zero).| +|`P9K_BACKGROUND_JOBS_VERBOSE`|`true`|If there is more than one background job, this segment will show the number of jobs. Set this to `false` to turn this feature off.| +`P9K_BACKGROUND_JOBS_VERBOSE_ALWAYS`|`false`|Always show the jobs count (even if it's zero).| ##### battery @@ -200,12 +200,12 @@ systems without a battery). It is supported on both OSX and Linux (note that it | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_BATTERY_CHARGING`|`"yellow"`|Color to indicate a charging battery.| -|`POWERLEVEL9K_BATTERY_CHARGED`|`"green"`|Color to indicate a charged battery.| -|`POWERLEVEL9K_BATTERY_DISCONNECTED`|`$DEFAULT_COLOR`|Color to indicate absence of battery.| -|`POWERLEVEL9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.| -|`POWERLEVEL9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.| -|`POWERLEVEL9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.| +|`P9K_BATTERY_CHARGING`|`"yellow"`|Color to indicate a charging battery.| +|`P9K_BATTERY_CHARGED`|`"green"`|Color to indicate a charged battery.| +|`P9K_BATTERY_DISCONNECTED`|`$DEFAULT_COLOR`|Color to indicate absence of battery.| +|`P9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.| +|`P9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.| +|`P9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.| Note that you can [modify the `_FOREGROUND` color](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization) @@ -216,26 +216,26 @@ level. This will override the default battery icon. In order to do this, you need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. | Variable | Default Value | Description | -| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| +| `P9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| Powerlevel9k will use each index of the string or array as a stage to indicate battery charge level, progressing from left to right. You can provide any number of stages. The setting below, for example, provides 8 stages for Powerlevel9k to use. ```zsh -POWERLEVEL9K_BATTERY_STAGES="▁▂▃▄▅▆▇█" +P9K_BATTERY_STAGES="▁▂▃▄▅▆▇█" ``` If you require extra spacing after the icon, you will have to set it as an array, since spaces in the string will be used as one of the stages and you will get a missing icon. To do this, declare the variable as follows: ```zsh -POWERLEVEL9K_BATTERY_STAGES=($'\u2581 ' $'\u2582 ' $'\u2583 ' $'\u2584 ' $'\u2585 ' $'\u2586 ' $'\u2587 ' $'\u2588 ') +P9K_BATTERY_STAGES=($'\u2581 ' $'\u2582 ' $'\u2583 ' $'\u2584 ' $'\u2585 ' $'\u2586 ' $'\u2587 ' $'\u2588 ') ``` Using the array syntax, you can create stages comprised of multiple characters. The below setting provides 40 battery stages. ```zsh -POWERLEVEL9K_BATTERY_STAGES=( +P9K_BATTERY_STAGES=( $'▏ ▏' $'▎ ▏' $'▍ ▏' $'▌ ▏' $'▋ ▏' $'▊ ▏' $'▉ ▏' $'█ ▏' $'█▏ ▏' $'█▎ ▏' $'█▍ ▏' $'█▌ ▏' $'█▋ ▏' $'█▊ ▏' $'█▉ ▏' $'██ ▏' $'██ ▏' $'██▎ ▏' $'██▍ ▏' $'██▌ ▏' $'██▋ ▏' $'██▊ ▏' $'██▉ ▏' $'███ ▏' @@ -245,11 +245,11 @@ POWERLEVEL9K_BATTERY_STAGES=( You can also change the background of the segment automatically depending on the battery level. This will override the following variables: -`POWERLEVEL9K_BATTERY_CHARGING`, `POWERLEVEL9K_BATTERY_CHARGED`, -`POWERLEVEL9K_BATTERY_DISCONNECTED`, and `POWERLEVEL9K_BATTERY_LOW_COLOR`. In +`P9K_BATTERY_CHARGING`, `P9K_BATTERY_CHARGED`, +`P9K_BATTERY_DISCONNECTED`, and `P9K_BATTERY_LOW_COLOR`. In order to do this, define a color array, from low to high, as shown below: ```zsh -POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND=(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1) +P9K_BATTERY_LEVEL_BACKGROUND=(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1) ``` As with the battery stages, you can use any number of colors and Powerlevel9k @@ -264,15 +264,15 @@ Some example settings: ##### command_execution_time Display the time the previous command took to execute if the time is above -`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be +`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be "human readable", and so scales the units based on the length of execution time. If you want more precision, just set the -`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION` field. +`P9K_COMMAND_EXECUTION_TIME_PRECISION` field. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.| -|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.| +|`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.| +|`P9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.| ##### custom_command @@ -281,10 +281,10 @@ a prompt segment. As an example, if you wanted to create a custom segment to display your WiFi signal strength, you might define a custom segment called `custom_wifi_signal` like this: ```zsh -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" +P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) +P9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" +P9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" +P9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" ``` If you prefer, you can also define the function in your `.zshrc` rather than putting it in-line with the variable export, as shown above. Just don't forget @@ -299,8 +299,8 @@ zsh_wifi_signal(){ echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is  } -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal" -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) +P9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal" +P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) ``` The command, above, gives you the wireless signal segment shown below: @@ -323,10 +323,10 @@ You can customize the `context` segment. For example, you can make it to print t full hostname by setting ``` -POWERLEVEL9K_CONTEXT_TEMPLATE="%n@`hostname -f`" +P9K_CONTEXT_TEMPLATE="%n@`hostname -f`" ``` -You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the +You can set the `P9K_CONTEXT_HOST_DEPTH` variable to change how the hostname is displayed. See [ZSH Manual](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information) for details. The default is set to %m which will show the hostname up to the first ‘.’ You can set it to %{N}m where N is an integer to show that many segments of system @@ -336,9 +336,9 @@ end of the hostname. | Variable | Default Value | Description | |----------|---------------|-------------| |`DEFAULT_USER`|None|Username to consider a "default context" (you can also set `$USER`).| -|`POWERLEVEL9K_ALWAYS_SHOW_CONTEXT`|false|Always show this segment, including $USER and hostname.| -|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.| -|`POWERLEVEL9K_CONTEXT_TEMPLATE`|%n@%m|Default context prompt (username@machine). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions, including deeper host depths.| +|`P9K_ALWAYS_SHOW_CONTEXT`|false|Always show this segment, including $USER and hostname.| +|`P9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.| +|`P9K_CONTEXT_TEMPLATE`|%n@%m|Default context prompt (username@machine). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions, including deeper host depths.| ##### date @@ -346,7 +346,7 @@ The `date` segment shows the current system date. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release Prompt-Expansion.html) to use in this segment.| +|`P9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release Prompt-Expansion.html) to use in this segment.| ##### dir @@ -361,42 +361,42 @@ Powerline" fonts, there are additional glyphs, as well: To turn off these icons you could set these variables to an empty string. ```zsh -POWERLEVEL9K_HOME_ICON='' -POWERLEVEL9K_HOME_SUB_ICON='' -POWERLEVEL9K_FOLDER_ICON='' +P9K_HOME_ICON='' +P9K_HOME_SUB_ICON='' +P9K_FOLDER_ICON='' ``` You can limit the output to a certain length by truncating long paths. Customizations available are: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_DIR_PATH_ABSOLUTE`|None|If set to `true`, will use absolute paths instead of home folder abbreviation `~`| -|`POWERLEVEL9K_SHORTEN_DIR_LENGTH`|`2`|If your shorten strategy, below, is entire directories, this field determines how many directories to leave at the end. If your shorten strategy is by character count, this field determines how many characters to allow per directory string.| -|`POWERLEVEL9K_SHORTEN_STRATEGY`|None|How the directory strings should be truncated. See the table below for more informations.| -|`POWERLEVEL9K_SHORTEN_DELIMITER`|`..`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.| +|`P9K_DIR_PATH_ABSOLUTE`|None|If set to `true`, will use absolute paths instead of home folder abbreviation `~`| +|`P9K_SHORTEN_DIR_LENGTH`|`2`|If your shorten strategy, below, is entire directories, this field determines how many directories to leave at the end. If your shorten strategy is by character count, this field determines how many characters to allow per directory string.| +|`P9K_SHORTEN_STRATEGY`|None|How the directory strings should be truncated. See the table below for more informations.| +|`P9K_SHORTEN_DELIMITER`|`..`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.| | Strategy Name | Description | |---------------|-------------| -|Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`| -|`truncate_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (with or without `POWERLEVEL9K_SHORTEN_DELIMITER`) is no more than `POWERLEVEL9K_SHORTEN_DIR_LENGTH` + the length of `POWERLEVEL9K_SHORTEN_DELIMITER` | -|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named `~/MySuperProjects/AwesomeFiles/BoringOffice`, then it will truncated to `~/MyS..cts/Awe..les/BoringOffice`, if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| -|`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| -|`truncate_absolute`|Truncates everything exept the last few characters in the path. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3`, you will get "..l9k".| +|Default|Truncate whole directories from left. How many is defined by `P9K_SHORTEN_DIR_LENGTH`| +|`truncate_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (with or without `P9K_SHORTEN_DELIMITER`) is no more than `P9K_SHORTEN_DIR_LENGTH` + the length of `P9K_SHORTEN_DELIMITER` | +|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named `~/MySuperProjects/AwesomeFiles/BoringOffice`, then it will truncated to `~/MyS..cts/Awe..les/BoringOffice`, if `P9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| +|`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `P9K_SHORTEN_DIR_LENGTH`.| +|`truncate_absolute`|Truncates everything exept the last few characters in the path. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `P9K_SHORTEN_DIR_LENGTH=3`, you will get "..l9k".| |`truncate_to_last`|Truncates everything before the last folder in the path.| -|`truncate_to_first_and_last|Truncate middle directories from the path. How many directories will be untouched is controlled by POWERLEVEL9K_SHORTER_DIR_LENGTH. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=1`, you will get "~/../powerlevel9k".|| +|`truncate_to_first_and_last|Truncate middle directories from the path. How many directories will be untouched is controlled by P9K_SHORTER_DIR_LENGTH. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `P9K_SHORTEN_DIR_LENGTH=1`, you will get "~/../powerlevel9k".|| |`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy & paste the result to a shell, after hitting `TAB` it should expand to the original path unambiguously.| -|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| -|`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| +|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `P9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| +|`truncate_with_folder_marker`|Search for a file that is specified by `P9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| For example, if you wanted the truncation behavior of the `fish` shell, which truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: ```zsh -POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 -POWERLEVEL9K_SHORTEN_DELIMITER="" -POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" +P9K_SHORTEN_DIR_LENGTH=1 +P9K_SHORTEN_DELIMITER="" +P9K_SHORTEN_STRATEGY="truncate_from_right" ``` In each case you have to specify the length you want to shorten the directory -to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in +to. So in some cases `P9K_SHORTEN_DIR_LENGTH` means characters, in others whole directories. The `truncate_with_package_name` strategy gives your directory path relative to the root of your project. For example, if you have a project inside `$HOME/projects/my-project` with a `package.json` that looks like: @@ -412,25 +412,25 @@ The path shown would be `my-cool-project`. If you navigate to `$HOME/projects/m If you want to customize the directory separator, you could set: ```zsh # Double quotes are important here! -POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{red} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}" +P9K_DIR_PATH_SEPARATOR="%F{red} $(printIcon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}" ``` -To omit the first character (usually a slash that gets replaced if you set `POWERLEVEL9K_DIR_PATH_SEPARATOR`), -you could set `POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true`. +To omit the first character (usually a slash that gets replaced if you set `P9K_DIR_PATH_SEPARATOR`), +you could set `P9K_DIR_OMIT_FIRST_CHARACTER=true`. You can also customize the leading tilde character when you are in `$HOME` using: ```zsh # Double quotes are important here! -POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}" +P9K_HOME_FOLDER_ABBREVIATION="%F{red} $(printIcon 'HOME_ICON') %F{black}" ``` You can also configure the `dir` segment to show when you are in a directory without write permissions, using the variable below. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)). Note that this functionality is also available in a separate segment, `dir_writable`.| +|`P9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)). Note that this functionality is also available in a separate segment, `dir_writable`.| -If you want to customize the last directory of the path, you can now set `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND` to a custom color and/or `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true` to display that part in bold. +If you want to customize the last directory of the path, you can now set `P9K_DIR_PATH_HIGHLIGHT_FOREGROUND` to a custom color and/or `P9K_DIR_PATH_HIGHLIGHT_BOLD=true` to display that part in bold. -You can also color the separator separately by setting the color using `POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND`. +You can also color the separator separately by setting the color using `P9K_DIR_PATH_SEPARATOR_FOREGROUND`. ##### disk_usage @@ -438,15 +438,15 @@ The `disk_usage` segment will show the usage level of the partition that your cu | Variable | Default Value | Description | |----------|---------------|-------------| -|POWERLEVEL9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| -|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| -|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| +|P9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| +|P9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| +|P9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| ##### host The `host` segment will print the hostname. -You can set the `POWERLEVEL9K_HOST_TEMPLATE` variable to change how the hostname +You can set the `P9K_HOST_TEMPLATE` variable to change how the hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] for details. The default is set to `%m` which will show the hostname up to the first `.`. You can set it to `%{N}m` where N is an integer to show that many @@ -454,13 +454,13 @@ segments of system hostname. Setting `N` to a negative integer will show that ma segments from the end of the hostname. ``` -POWERLEVEL9K_HOST_TEMPLATE="%2m" +P9K_HOST_TEMPLATE="%2m" ``` By default, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting ``` -POWERLEVEL9K_HOST_ICON="\uF109 " -POWERLEVEL9K_SSH_ICON="\uF489 " +P9K_HOST_ICON="\uF109 " +P9K_SSH_ICON="\uF489 " ``` @@ -472,7 +472,7 @@ specify the correct network interface by setting: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| +|`P9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| ##### vpn_ip @@ -480,7 +480,7 @@ This segment tries to extract the VPN related IP addresses from nmcli, based on | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| +|`P9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| ##### public_ip @@ -495,17 +495,17 @@ If you activate a VPN, the icon for this segment will change to the defined VPN The public_ip segment will attempt to update your public IP address every 5 minutes by default(also configurable by the user). If you lose connection your cached IP address will be displayed until your timeout expires at which point every time your prompt is generated a new attempt will be made. -Until an IP is successfully pulled the value of $POWERLEVEL9K_PUBLIC_IP_NONE will be displayed for -this segment. If this value is empty(the default)and $POWERLEVEL9K_PUBLIC_IP_FILE is empty the +Until an IP is successfully pulled the value of $P9K_PUBLIC_IP_NONE will be displayed for +this segment. If this value is empty(the default)and $P9K_PUBLIC_IP_FILE is empty the segment will not be displayed. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| -|`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| -|`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| -|`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| -|`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| +|`P9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| +|`P9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| +|`P9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| +|`P9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| +|`P9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| ##### load @@ -516,13 +516,13 @@ Displays one of your load averages with appropriate state coloring. The threshol | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_LOAD_WHICH`|5|Which average to show. Possible values: 1, 5 or 15| +|`P9K_LOAD_WHICH`|5|Which average to show. Possible values: 1, 5 or 15| ##### newline Puts a newline in your prompt so you can continue using segments on the next line. This allows you to use segments on both lines, unlike -`POWERLEVEL9K_PROMPT_ON_NEWLINE`, which simply separates segments from the +`P9K_PROMPT_ON_NEWLINE`, which simply separates segments from the prompt itself. This only works on the left side. On the right side it does nothing. @@ -538,7 +538,7 @@ It figures out the version being used by taking the output of the `rbenv version Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| +|`P9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| ##### rspec_stats @@ -550,16 +550,16 @@ This segment shows the return code of the last command. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK` to false.| -|`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| -|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| -|`POWERLEVEL9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to false, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| +|`P9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `P9K_STATUS_OK` to false.| +|`P9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| +|`P9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| +|`P9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to false, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| ##### ram | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.| +|`P9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.| ##### symfony2_tests @@ -569,18 +569,18 @@ See [Unit Test Ratios](#unit-test-ratios), below. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.| +|`P9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.| As an example, if you wanted a reversed time format, you would use this: ```zsh # Reversed time format -POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}' +P9K_TIME_FORMAT='%D{%S:%M:%H}' ``` If you are using an "Awesome Powerline Font", you can add a time symbol to this segment, as well: ```zsh # Output time, date, and a symbol from the "Awesome Powerline Font" set -POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}" +P9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}" ``` ##### user @@ -589,16 +589,16 @@ The `user` segment will print the username. You can also override the icons by setting: ``` -POWERLEVEL9K_USER_ICON="\uF415" #  -POWERLEVEL9K_ROOT_ICON="#" -POWERLEVEL9K_SUDO_ICON=$'\uF09C' #  +P9K_USER_ICON="\uF415" #  +P9K_ROOT_ICON="#" +P9K_SUDO_ICON=$'\uF09C' #  ``` | Variable | Default Value | Description | |----------|---------------|-------------| |`DEFAULT_USER`|None|Username to consider a "default context".| -|`POWERLEVEL9K_ALWAYS_SHOW_USER`|`false`|Always print this segment.| -|`POWERLEVEL9K_USER_TEMPLATE`|`%n`|Default username prompt. Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| +|`P9K_ALWAYS_SHOW_USER`|`false`|Always print this segment.| +|`P9K_USER_TEMPLATE`|`%n`|Default username prompt. Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| ##### vcs @@ -607,21 +607,21 @@ customization is provided via: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_HIDE_BRANCH_ICON`|`false`|Set to `true` to hide the branch icon from the segment.| -|`POWERLEVEL9K_SHOW_CHANGESET`|`false`|Set to `true` to display the hash / changeset in the segment.| -|`POWERLEVEL9K_CHANGESET_HASH_LENGTH`|`12`|How many characters of the hash / changeset to display in the segment.| -|`POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY`|`true`|Set to `false` to not reflect submodule status in the top-level repository prompt.| -|`POWERLEVEL9K_VCS_HIDE_TAGS`|`false`|Set to `true` to stop tags being displayed in the segment.| -|`POWERLEVEL9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| -|`POWERLEVEL9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| -|`POWERLEVEL9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| -|`POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| +|`P9K_HIDE_BRANCH_ICON`|`false`|Set to `true` to hide the branch icon from the segment.| +|`P9K_SHOW_CHANGESET`|`false`|Set to `true` to display the hash / changeset in the segment.| +|`P9K_CHANGESET_HASH_LENGTH`|`12`|How many characters of the hash / changeset to display in the segment.| +|`P9K_VCS_SHOW_SUBMODULE_DIRTY`|`true`|Set to `false` to not reflect submodule status in the top-level repository prompt.| +|`P9K_VCS_HIDE_TAGS`|`false`|Set to `true` to stop tags being displayed in the segment.| +|`P9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| +|`P9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| +|`P9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| +|`P9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| ##### vcs symbols The `vcs` segment uses various symbols to tell you the state of your repository. -These symbols depend on your installed font and selected `POWERLEVEL9K_MODE` +These symbols depend on your installed font and selected `P9K_MODE` from the [Installation](#Installation) section above. | `Compatible` | `Powerline` | `Awesome Powerline` | Explanation @@ -648,10 +648,10 @@ you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-L | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.| -|`POWERLEVEL9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.| +|`P9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.| +|`P9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.| -To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''` +To hide the segment entirely when in `INSERT` mode, set `P9K_VI_INSERT_MODE_STRING=''` #### Unit Test Ratios @@ -668,7 +668,7 @@ You can disable P9k and return to a very basic prompt at any time simply by calling: ```zsh -$ prompt_powerlevel9k_teardown +$ prompt_p9k_teardown ``` You can then re-enable it by calling: diff --git a/api/functions/colors.md b/api/functions/colors.md index 78fd20cc9..8dbe2aeb0 100644 --- a/api/functions/colors.md +++ b/api/functions/colors.md @@ -35,7 +35,7 @@ #### Notes -*You can bypass this check by setting `POWERLEVEL9K_IGNORE_TERM_COLORS=true`. * +*You can bypass this check by setting `P9K_IGNORE_TERM_COLORS=true`. * ## getColor *This function gets the proper color code if it does not exist as a name. * diff --git a/api/functions/icons.md b/api/functions/icons.md index d6532bdc0..f83ab927c 100644 --- a/api/functions/icons.md +++ b/api/functions/icons.md @@ -16,14 +16,14 @@ *This file contains some the core icon definitions and icon-functions. * -*These characters require the Powerline fonts to work properly. If you see boxes or bizarre characters below, your fonts are not correctly installed. If you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to `compatible`. This shows all icons in regular symbols. * +*These characters require the Powerline fonts to work properly. If you see boxes or bizarre characters below, your fonts are not correctly installed. If you do not want to install a special font, you can set `P9K_MODE` to `compatible`. This shows all icons in regular symbols. * ## Table of Contents -- [register_icon](#register_icon) -- [print_icon](#print_icon) +- [registerIcon](#registerIcon) +- [printIcon](#printIcon) -## register_icon +## registerIcon *This function allows a segment to register the icons that it requires. These icons may be overriden by the user later. Arguments may be a direct call or an array. * #### Arguments @@ -43,18 +43,18 @@ #### Usage ```sh -register_icon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' +registerIcon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' ``` #### Example ```sh -register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ``` -## print_icon +## printIcon *Safety function for printing icons. Prints the named icon, or if that icon is undefined, the string name. * #### Arguments diff --git a/api/functions/utilities.md b/api/functions/utilities.md index 65dd14ea8..07b5a8550 100644 --- a/api/functions/utilities.md +++ b/api/functions/utilities.md @@ -19,16 +19,15 @@ ## Table of Contents - [defined](#defined) -- [set_default](#set_default) +- [setDefault](#setDefault) - [printSizeHumanReadable](#printSizeHumanReadable) - [getRelevantItem](#getRelevantItem) -- [segment_in_use](#segment_in_use) -- [print_deprecation_warning](#print_deprecation_warning) +- [segmentInUse](#segmentInUse) +- [printDeprecationWarning](#printDeprecationWarning) - [segmentShouldBeJoined](#segmentShouldBeJoined) - [truncatePath](#truncatePath) - [truncatePathFromRight](#truncatePathFromRight) - [upsearch](#upsearch) -- [union](#union) ## defined *This function determine if a variable has been previously defined, even if empty. * @@ -43,7 +42,7 @@ - 0 if the variable has been defined. -## set_default +## setDefault *This function determine if a variable has been previously defined, and only sets the value to the specified default if it hasn't. * #### Arguments @@ -87,7 +86,7 @@ *The callback function has access to the inner variable $item. * -## segment_in_use +## segmentInUse *Determine if the passed segment is used in either the LEFT or RIGHT prompt arrays. * #### Arguments @@ -95,7 +94,7 @@ - **$1** (string) The segment to be tested. -## print_deprecation_warning +## printDeprecationWarning *Print a deprecation warning if an old segment is in use. * #### Arguments @@ -137,39 +136,3 @@ - **$1** (string) Filename to search for. - -## union -*Union of two or more arrays. * - -#### Arguments - -- **...** (arrays) The arrays to combine. - - -#### Returns - -- array of unique items. - - -#### Notes - -*This does not work with indexed arrays. * - -#### Usage - -```sh -union [arr1[ arr2[ ...]]] - -``` - -#### Example - -```sh -$ arr1=('a' 'b' 'c') -$ arr2=('b' 'c' 'd') -$ arr2=('c' 'd' 'e') -$ union $arr1 $arr2 $arr3 -> a b c d e - -``` - diff --git a/api/generator/default.md b/api/generator/default.md index 56c6ec8ef..c06f93e90 100644 --- a/api/generator/default.md +++ b/api/generator/default.md @@ -18,20 +18,20 @@ ## Table of Contents -- [left_prompt_segment()](#left_prompt_segment) -- [left_prompt_end()](#left_prompt_end) -- [right_prompt_segment()](#right_prompt_segment) -- [serialize_segment()](#serialize_segment) +- [leftPromptSegment()](#leftPromptSegment) +- [leftPromptEnd()](#leftPromptEnd) +- [rightPromptSegment()](#rightPromptSegment) +- [serializeSegment()](#serializeSegment) - [prompt_custom()](#prompt_custom) -- [build_left_prompt()](#build_left_prompt) -- [build_right_prompt()](#build_right_prompt) -- [powerlevel9k_preexec()](#powerlevel9k_preexec) -- [powerlevel9k_prepare_prompts()](#powerlevel9k_prepare_prompts) -- [p9k_chpwd()](#p9k_chpwd) +- [buildLeftPrompt()](#buildLeftPrompt) +- [buildRightPrompt()](#buildRightPrompt) +- [p9k_preexec()](#p9k_preexec) +- [p9kPreparePrompts()](#p9kPreparePrompts) +- [p9kChPwd()](#p9kChPwd) - [prompt_powerlevel9k_setup()](#prompt_powerlevel9k_setup) -- [prompt_powerlevel9k_teardown()](#prompt_powerlevel9k_teardown) +- [prompt_p9k_teardown()](#prompt_p9k_teardown) -## left_prompt_segment() +## leftPromptSegment() *Construct a left prompt segment * #### Arguments @@ -45,7 +45,7 @@ - **$7** (string) Visual identifier (must be a key of the icons array) -## left_prompt_end() +## leftPromptEnd() *End the left prompt, closes the final segment * #### Arguments @@ -53,7 +53,7 @@ - *Function has no arguments.* -## right_prompt_segment() +## rightPromptSegment() *Construct a right prompt segment * #### Arguments @@ -67,8 +67,8 @@ - **$7** (string) Visual identifier (must be a key of the icons array) -## serialize_segment() -*This function wraps `left_prompt_segment` and `right_prompt_segment` (for compatibility with the async generator). * +## serializeSegment() +*This function wraps `leftPromptSegment` and `rightPromptSegment` (for compatibility with the async generator). * #### Arguments @@ -95,7 +95,7 @@ - **$4** (string) Custom segment name -## build_left_prompt() +## buildLeftPrompt() *This function loops through the left prompt elements and calls the related segment functions. * #### Arguments @@ -103,7 +103,7 @@ - *Function has no arguments.* -## build_right_prompt() +## buildRightPrompt() *This function loops through the right prompt elements and calls the related segment functions. * #### Arguments @@ -111,7 +111,7 @@ - *Function has no arguments.* -## powerlevel9k_preexec() +## p9k_preexec() *This function is a hook that runs before the command runs. It sets the start timer. * #### Arguments @@ -119,7 +119,7 @@ - *Function has no arguments.* -## powerlevel9k_prepare_prompts() +## p9kPreparePrompts() *This function is a hook that is run before the prompts are created. If sets all the required variables for the prompts and then calls the prompt segment building functions. * #### Arguments @@ -127,7 +127,7 @@ - *Function has no arguments.* -## p9k_chpwd() +## p9kChPwd() *This function is a hook into chpwd to add bindkey support. * #### Arguments @@ -143,7 +143,7 @@ - *Function has no arguments.* -## prompt_powerlevel9k_teardown() +## prompt_p9k_teardown() *This function removed PowerLevel9k hooks and resets the prompts. * #### Arguments diff --git a/api/generator/zsh-async.md b/api/generator/zsh-async.md index e216410cf..61589eb5c 100644 --- a/api/generator/zsh-async.md +++ b/api/generator/zsh-async.md @@ -26,25 +26,25 @@ ## Table of Contents -- [left_prompt_segment()](#left_prompt_segment) -- [right_prompt_segment()](#right_prompt_segment) +- [leftPromptSegment()](#leftPromptSegment) +- [rightPromptSegment()](#rightPromptSegment) - [last_left_bg()](#last_left_bg) - [last_right_bg()](#last_right_bg) - [update_left_prompt()](#update_left_prompt) - [update_right_prompt()](#update_right_prompt) - [p9k_async_callback()](#p9k_async_callback) -- [p9k_serialize_segment()](#p9k_serialize_segment) -- [serialize_segment()](#serialize_segment) +- [p9k_serializeSegment()](#p9k_serializeSegment) +- [serializeSegment()](#serializeSegment) - [prompt_custom()](#prompt_custom) -- [build_left_prompt()](#build_left_prompt) -- [build_right_prompt()](#build_right_prompt) -- [powerlevel9k_preexec()](#powerlevel9k_preexec) -- [powerlevel9k_prepare_prompts()](#powerlevel9k_prepare_prompts) -- [p9k_chpwd()](#p9k_chpwd) +- [buildLeftPrompt()](#buildLeftPrompt) +- [buildRightPrompt()](#buildRightPrompt) +- [p9k_preexec()](#p9k_preexec) +- [p9kPreparePrompts()](#p9kPreparePrompts) +- [p9kChPwd()](#p9kChPwd) - [prompt_powerlevel9k_setup()](#prompt_powerlevel9k_setup) -- [prompt_powerlevel9k_teardown()](#prompt_powerlevel9k_teardown) +- [prompt_p9k_teardown()](#prompt_p9k_teardown) -## left_prompt_segment() +## leftPromptSegment() *Spawn a subshell to convert the data into a left prompt segment * #### Arguments @@ -58,7 +58,7 @@ - **$7** (string) Visual Identifier - Segment icon -## right_prompt_segment() +## rightPromptSegment() *Spawn a subshell to convert the data into a right prompt segment * #### Arguments @@ -116,7 +116,7 @@ - **$5** (string) Err - Resulting (stderr) output from the job -## p9k_serialize_segment() +## p9k_serializeSegment() *This function processes the segment code in a subshell. When done, the resulting data is sent to `p9k_async_callback`. * #### Arguments @@ -133,7 +133,7 @@ - **$10** (string) Condition - The condition, if the segment should be printed (gets evaluated) -## serialize_segment() +## serializeSegment() *This function is a wrapper function that starts off the async process and passes the parameters from the segment code to the subshells. * #### Arguments @@ -152,7 +152,7 @@ - **$4** (string) Custom segment name -## build_left_prompt() +## buildLeftPrompt() *This function loops through the left prompt elements and calls the related segment functions. * #### Arguments @@ -160,7 +160,7 @@ - *Function has no arguments.* -## build_right_prompt() +## buildRightPrompt() *This function loops through the right prompt elements and calls the related segment functions. * #### Arguments @@ -168,7 +168,7 @@ - *Function has no arguments.* -## powerlevel9k_preexec() +## p9k_preexec() *This function is a hook that runs before the command runs. It sets the start timer. * #### Arguments @@ -176,7 +176,7 @@ - *Function has no arguments.* -## powerlevel9k_prepare_prompts() +## p9kPreparePrompts() *This function is a hook that is run before the prompts are created. If sets all the required variables for the prompts and then calls the prompt segment building functions. * #### Arguments @@ -184,7 +184,7 @@ - *Function has no arguments.* -## p9k_chpwd() +## p9kChPwd() *This function is a hook into chpwd to add bindkey support. * #### Arguments @@ -200,7 +200,7 @@ - *Function has no arguments.* -## prompt_powerlevel9k_teardown() +## prompt_p9k_teardown() *This function removed PowerLevel9k hooks and resets the prompts. * #### Arguments diff --git a/api/segments/developer/anaconda.md b/api/segments/anaconda.md similarity index 100% rename from api/segments/developer/anaconda.md rename to api/segments/anaconda.md diff --git a/api/segments/developer/aws.md b/api/segments/aws.md similarity index 100% rename from api/segments/developer/aws.md rename to api/segments/aws.md diff --git a/api/segments/developer/aws_eb_env.md b/api/segments/aws_eb_env.md similarity index 100% rename from api/segments/developer/aws_eb_env.md rename to api/segments/aws_eb_env.md diff --git a/api/segments/core/background_jobs.md b/api/segments/background_jobs.md similarity index 100% rename from api/segments/core/background_jobs.md rename to api/segments/background_jobs.md diff --git a/api/segments/core/battery.md b/api/segments/battery.md similarity index 100% rename from api/segments/core/battery.md rename to api/segments/battery.md diff --git a/api/segments/developer/chruby.md b/api/segments/chruby.md similarity index 100% rename from api/segments/developer/chruby.md rename to api/segments/chruby.md diff --git a/api/segments/core/command_execution_time.md b/api/segments/command_execution_time.md similarity index 100% rename from api/segments/core/command_execution_time.md rename to api/segments/command_execution_time.md diff --git a/api/segments/core/context.md b/api/segments/context.md similarity index 100% rename from api/segments/core/context.md rename to api/segments/context.md diff --git a/api/segments/core/date.md b/api/segments/date.md similarity index 100% rename from api/segments/core/date.md rename to api/segments/date.md diff --git a/api/segments/developer/detect_virt.md b/api/segments/detect_virt.md similarity index 100% rename from api/segments/developer/detect_virt.md rename to api/segments/detect_virt.md diff --git a/api/segments/core/dir.md b/api/segments/dir.md similarity index 100% rename from api/segments/core/dir.md rename to api/segments/dir.md diff --git a/api/segments/core/dir_writable.md b/api/segments/dir_writable.md similarity index 100% rename from api/segments/core/dir_writable.md rename to api/segments/dir_writable.md diff --git a/api/segments/core/disk_usage.md b/api/segments/disk_usage.md similarity index 100% rename from api/segments/core/disk_usage.md rename to api/segments/disk_usage.md diff --git a/api/segments/developer/docker_machine.md b/api/segments/docker_machine.md similarity index 100% rename from api/segments/developer/docker_machine.md rename to api/segments/docker_machine.md diff --git a/api/segments/other/dropbox.md b/api/segments/dropbox.md similarity index 100% rename from api/segments/other/dropbox.md rename to api/segments/dropbox.md diff --git a/api/segments/developer/go_version.md b/api/segments/go_version.md similarity index 100% rename from api/segments/developer/go_version.md rename to api/segments/go_version.md diff --git a/api/segments/core/history.md b/api/segments/history.md similarity index 100% rename from api/segments/core/history.md rename to api/segments/history.md diff --git a/api/segments/core/host.md b/api/segments/host.md similarity index 100% rename from api/segments/core/host.md rename to api/segments/host.md diff --git a/api/segments/other/icons_test.md b/api/segments/icons_test.md similarity index 100% rename from api/segments/other/icons_test.md rename to api/segments/icons_test.md diff --git a/api/segments/core/ip.md b/api/segments/ip.md similarity index 100% rename from api/segments/core/ip.md rename to api/segments/ip.md diff --git a/api/segments/developer/java_version.md b/api/segments/java_version.md similarity index 100% rename from api/segments/developer/java_version.md rename to api/segments/java_version.md diff --git a/api/segments/developer/kubecontext.md b/api/segments/kubecontext.md similarity index 100% rename from api/segments/developer/kubecontext.md rename to api/segments/kubecontext.md diff --git a/api/segments/core/load.md b/api/segments/load.md similarity index 100% rename from api/segments/core/load.md rename to api/segments/load.md diff --git a/api/segments/core/newline.md b/api/segments/newline.md similarity index 100% rename from api/segments/core/newline.md rename to api/segments/newline.md diff --git a/api/segments/developer/node_env.md b/api/segments/node_env.md similarity index 100% rename from api/segments/developer/node_env.md rename to api/segments/node_env.md diff --git a/api/segments/developer/node_version.md b/api/segments/node_version.md similarity index 100% rename from api/segments/developer/node_version.md rename to api/segments/node_version.md diff --git a/api/segments/developer/nvm.md b/api/segments/nvm.md similarity index 100% rename from api/segments/developer/nvm.md rename to api/segments/nvm.md diff --git a/api/segments/other/openfoam.md b/api/segments/openfoam.md similarity index 100% rename from api/segments/other/openfoam.md rename to api/segments/openfoam.md diff --git a/api/segments/core/os_icon.md b/api/segments/os_icon.md similarity index 100% rename from api/segments/core/os_icon.md rename to api/segments/os_icon.md diff --git a/api/segments/developer/php_version.md b/api/segments/php_version.md similarity index 100% rename from api/segments/developer/php_version.md rename to api/segments/php_version.md diff --git a/api/segments/core/public_ip.md b/api/segments/public_ip.md similarity index 100% rename from api/segments/core/public_ip.md rename to api/segments/public_ip.md diff --git a/api/segments/developer/pyenv.md b/api/segments/pyenv.md similarity index 100% rename from api/segments/developer/pyenv.md rename to api/segments/pyenv.md diff --git a/api/segments/core/ram.md b/api/segments/ram.md similarity index 100% rename from api/segments/core/ram.md rename to api/segments/ram.md diff --git a/api/segments/developer/rbenv.md b/api/segments/rbenv.md similarity index 100% rename from api/segments/developer/rbenv.md rename to api/segments/rbenv.md diff --git a/api/segments/core/root_indicator.md b/api/segments/root_indicator.md similarity index 100% rename from api/segments/core/root_indicator.md rename to api/segments/root_indicator.md diff --git a/api/segments/developer/rspec_stats.md b/api/segments/rspec_stats.md similarity index 100% rename from api/segments/developer/rspec_stats.md rename to api/segments/rspec_stats.md diff --git a/api/segments/developer/rust_version.md b/api/segments/rust_version.md similarity index 100% rename from api/segments/developer/rust_version.md rename to api/segments/rust_version.md diff --git a/api/segments/developer/rvm.md b/api/segments/rvm.md similarity index 100% rename from api/segments/developer/rvm.md rename to api/segments/rvm.md diff --git a/api/segments/core/ssh.md b/api/segments/ssh.md similarity index 100% rename from api/segments/core/ssh.md rename to api/segments/ssh.md diff --git a/api/segments/core/status.md b/api/segments/status.md similarity index 100% rename from api/segments/core/status.md rename to api/segments/status.md diff --git a/api/segments/core/swap.md b/api/segments/swap.md similarity index 100% rename from api/segments/core/swap.md rename to api/segments/swap.md diff --git a/api/segments/developer/swift_version.md b/api/segments/swift_version.md similarity index 100% rename from api/segments/developer/swift_version.md rename to api/segments/swift_version.md diff --git a/api/segments/developer/symfony2_tests.md b/api/segments/symfony2_tests.md similarity index 100% rename from api/segments/developer/symfony2_tests.md rename to api/segments/symfony2_tests.md diff --git a/api/segments/developer/symfony2_version.md b/api/segments/symfony2_version.md similarity index 100% rename from api/segments/developer/symfony2_version.md rename to api/segments/symfony2_version.md diff --git a/api/segments/developer/test_stats.md b/api/segments/test_stats.md similarity index 100% rename from api/segments/developer/test_stats.md rename to api/segments/test_stats.md diff --git a/api/segments/core/time.md b/api/segments/time.md similarity index 100% rename from api/segments/core/time.md rename to api/segments/time.md diff --git a/api/segments/other/todo.md b/api/segments/todo.md similarity index 100% rename from api/segments/other/todo.md rename to api/segments/todo.md diff --git a/api/segments/core/user.md b/api/segments/user.md similarity index 100% rename from api/segments/core/user.md rename to api/segments/user.md diff --git a/api/segments/developer/vcs.md b/api/segments/vcs.md similarity index 89% rename from api/segments/developer/vcs.md rename to api/segments/vcs.md index 98fd81408..870b72ae0 100644 --- a/api/segments/developer/vcs.md +++ b/api/segments/vcs.md @@ -14,10 +14,10 @@ ## Table of Contents -- [powerlevel9k_vcs_init](#powerlevel9k_vcs_init) +- [p9k_vcs_init](#p9k_vcs_init) - [prompt_vcs](#prompt_vcs) -## powerlevel9k_vcs_init +## p9k_vcs_init *Initializes the VCS segment by setting the required ZSH options. * #### Arguments diff --git a/api/segments/core/vi_mode.md b/api/segments/vi_mode.md similarity index 100% rename from api/segments/core/vi_mode.md rename to api/segments/vi_mode.md diff --git a/api/segments/developer/virtualenv.md b/api/segments/virtualenv.md similarity index 100% rename from api/segments/developer/virtualenv.md rename to api/segments/virtualenv.md diff --git a/api/segments/core/vpn_ip.md b/api/segments/vpn_ip.md similarity index 100% rename from api/segments/core/vpn_ip.md rename to api/segments/vpn_ip.md diff --git a/docker/base-4.3.11/Dockerfile b/docker/base-4.3.11/Dockerfile index 805a7ae1e..cee8ccb02 100644 --- a/docker/base-4.3.11/Dockerfile +++ b/docker/base-4.3.11/Dockerfile @@ -24,7 +24,7 @@ WORKDIR /home/fred ENV LANG=en_US.UTF-8 ENV TERM=xterm-256color ENV DEFAULT_USER=fred -ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true +ENV P9K_ALWAYS_SHOW_CONTEXT=true RUN touch .zshrc diff --git a/docker/base-5.0.3/Dockerfile b/docker/base-5.0.3/Dockerfile index e0b6c6c3e..a89420e15 100644 --- a/docker/base-5.0.3/Dockerfile +++ b/docker/base-5.0.3/Dockerfile @@ -26,7 +26,7 @@ WORKDIR /home/fred ENV LANG=en_US.UTF-8 ENV TERM=xterm-256color ENV DEFAULT_USER=fred -ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true +ENV P9K_ALWAYS_SHOW_CONTEXT=true RUN touch .zshrc diff --git a/docker/base-5.1.1/Dockerfile b/docker/base-5.1.1/Dockerfile index a7f644bf2..ac0f00804 100644 --- a/docker/base-5.1.1/Dockerfile +++ b/docker/base-5.1.1/Dockerfile @@ -28,7 +28,7 @@ WORKDIR /home/fred ENV LANG=en_US.UTF-8 ENV TERM=xterm-256color ENV DEFAULT_USER=fred -ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true +ENV P9K_ALWAYS_SHOW_CONTEXT=true RUN touch .zshrc diff --git a/docker/base-5.2/Dockerfile b/docker/base-5.2/Dockerfile index 62a10074d..b85f460a7 100644 --- a/docker/base-5.2/Dockerfile +++ b/docker/base-5.2/Dockerfile @@ -28,7 +28,7 @@ WORKDIR /home/fred ENV LANG=en_US.UTF-8 ENV TERM=xterm-256color ENV DEFAULT_USER=fred -ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true +ENV P9K_ALWAYS_SHOW_CONTEXT=true RUN touch .zshrc diff --git a/functions/colors.zsh b/functions/colors.zsh index b6c482f19..3cd57cb58 100755 --- a/functions/colors.zsh +++ b/functions/colors.zsh @@ -20,10 +20,10 @@ # @noargs ## # @note -# You can bypass this check by setting `POWERLEVEL9K_IGNORE_TERM_COLORS=true`. +# You can bypass this check by setting `P9K_IGNORE_TERM_COLORS=true`. ## function termColors() { - [[ $POWERLEVEL9K_IGNORE_TERM_COLORS == true ]] && return + [[ $P9K_IGNORE_TERM_COLORS == true ]] && return local term_colors @@ -55,11 +55,11 @@ function getColor() { fi else # named color added to parameter expansion print -P to test if the name exists in terminal - named="%K{$1}" + local named="%K{$1}" # https://misc.flogisoft.com/bash/tip_colors_and_formatting - default="$'\033'\[49m" + local default="$'\033'\[49m" # http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html - quoted=$(printf "%q" $(print -P "$named")) + local quoted=$(printf "%q" $(print -P "$named")) if [[ $quoted = "$'\033'\[49m" && $1 != "black" ]]; then # color not found, so try to get the code 1=$(getColorCode $1) diff --git a/functions/icons.zsh b/functions/icons.zsh index 4cd51ad21..5ad122456 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -14,7 +14,7 @@ # # These characters require the Powerline fonts to work properly. If you see # boxes or bizarre characters below, your fonts are not correctly installed. If -# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to +# you do not want to install a special font, you can set `P9K_MODE` to # `compatible`. This shows all icons in regular symbols. ## @@ -38,14 +38,14 @@ typeset -gAH icons # You can specify a string, unicode string or codepoint string (for Mapped fonts only). ## # @usage -# register_icon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' +# registerIcon "name_of_icon" 'Gen' $'\uXXX' $'\uXXX' '\u'$CODEPOINT_OF_AWESOME_xxx '\uXXX' ## # @example -# register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +# registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ## -register_icon() { +registerIcon() { local map - case $POWERLEVEL9K_MODE in + case $P9K_MODE in 'flat'|'awesome-patched') map=$3 ;; 'awesome-fontconfig') map=$4 ;; 'awesome-mapped-fontconfig') map=$5 ;; @@ -55,9 +55,9 @@ register_icon() { icons[$1]=${map} } -# Initialize the icon list according to the user's `POWERLEVEL9K_MODE`. +# Initialize the icon list according to the user's `P9K_MODE`. typeset -gAH icons -case $POWERLEVEL9K_MODE in +case $P9K_MODE in 'flat'|'awesome-patched') # Awesome-Patched Font required! See: # https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched @@ -151,7 +151,7 @@ case $POWERLEVEL9K_MODE in esac # Override the above icon settings with any user-defined variables. -case $POWERLEVEL9K_MODE in +case $P9K_MODE in 'flat') # Set the right locale to protect special characters local LC_ALL="" LC_CTYPE="en_US.UTF-8" @@ -168,6 +168,9 @@ case $POWERLEVEL9K_MODE in ;; esac +# Hide branch icon if user wants it hidden +[[ "$P9K_HIDE_BRANCH_ICON" == true ]] && icons[VCS_BRANCH_ICON]='' + ################################################################ # @description # Safety function for printing icons. Prints the named icon, @@ -176,9 +179,9 @@ esac # @args # $1 string Name of icon ## -function print_icon() { +function printIcon() { local icon_name=$1 - local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} + local ICON_USER_VARIABLE=P9K_${icon_name} if defined "$ICON_USER_VARIABLE"; then echo -n "${(P)ICON_USER_VARIABLE}" else @@ -188,18 +191,18 @@ function print_icon() { # Get a list of configured icons # * $1 string - If "original", then the original icons are printed, -# otherwise "print_icon" is used, which takes the users +# otherwise "printIcon" is used, which takes the users # overrides into account. get_icon_names() { # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do - echo -n "POWERLEVEL9K_$key: " + echo -n "P9K_$key: " if [[ "${1}" == "original" ]]; then # print the original icons as they are defined in the array above echo "${icons[$key]}" else # print the icons as they are configured by the user - echo "$(print_icon "$key")" + echo "$(printIcon "$key")" fi done } diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 351b4d5af..42646e015 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -81,6 +81,49 @@ else unset uname fi +############################################################### +# @description +# This function determines if POWERLEVEL9K_ variables have +# been previously defined and changes them to P9K_ variables. +## +# @noargs +## +updateEnvironmentVars() { + local envVar var varName origVar newVar newVal + local oldVarsFound=false + for envVar in $(declare); do + if [[ $envVar =~ "POWERLEVEL9K_" ]]; then + oldVarsFound=true + var=$(declare -p ${envVar}) + varName=${${var##*POWERLEVEL9K_}%=*} + origVar="POWERLEVEL9K_${varName}" + newVar="P9K_${varName}" + if [[ ${var[13]} == "a" ]]; then # array variable + newVal=${${var##*\(}%\)*} + case ${(U)varName} in + BATTERY_LEVEL_BACKGROUND) typeset -g -a P9K_BATTERY_LEVEL_BACKGROUND=(${(s: :)newVal});; + BATTERY_STAGES) + local newVal=${${(P)origVar}//\'/} + typeset -g -a P9K_BATTERY_STAGES=( ${(s: :)newVal} ) + ;; + LEFT_PROMPT_ELEMENTS) typeset -g -a P9K_LEFT_PROMPT_ELEMENTS=(${(s: :)newVal});; + RIGHT_PROMPT_ELEMENTS) typeset -g -a P9K_RIGHT_PROMPT_ELEMENTS=(${(s: :)newVal});; + esac + else + newVal=${(P)origVar} + typeset -g $newVar=$newVal + fi + unset $origVar + fi + done + [[ P9K_IGNORE_VAR_WARNING ]] && oldVarsFound=false # disable warning if user sets P9K_IGNORE_VAR_WARNING to true. + [[ oldVarsFound ]] && print -P "%F{yellow}Information!%f As of this update, the %F{cyan}POWERLEVEL9K_*%f variables have been replaced by %F{cyan}P9K_*%f. + Variables are been converted automatically, but there may still be some errors. For more informations, have a look at the CHANGELOG.md. + To disable this warning, please modify your configuration file to use the new style variables, or add %F{green}P9K_IGNORE_VAR_WARNING=true%f to your config." +} + +updateEnvironmentVars + ############################################################### # @description # This function determines if a variable has been previously @@ -114,7 +157,7 @@ function defined() { # Typeset cannot set the value for an array, so this will only work # for scalar values. ## -function set_default() { +function setDefault() { local varname="$1" local default_value="$2" @@ -141,6 +184,7 @@ printSizeHumanReadable() { # if the base is not Bytes if [[ -n $2 ]]; then + local idx for idx in "${extension[@]}"; do if [[ "$2" == "$idx" ]]; then break @@ -204,14 +248,7 @@ if [[ "$OS" == 'macOS' ]]; then fi # Combine the PROMPT_ELEMENTS -#POWERLEVEL9K_PROMPT_ELEMENTS=(union $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS $POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) -local -a POWERLEVEL9K_PROMPT_ELEMENTS -for (( i=0; i <= ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}; i++ )) do - POWERLEVEL9K_PROMPT_ELEMENTS+=${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[$i]%_joined} -done -for (( i=0; i <= ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}; i++ )) do - POWERLEVEL9K_PROMPT_ELEMENTS+=${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[$i]%_joined} -done +typeset -gU P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") ############################################################### # @description @@ -221,13 +258,9 @@ done # @args # $1 string The segment to be tested. ## -segment_in_use() { - local key=$1 - if [[ -n "${POWERLEVEL9K_PROMPT_ELEMENTS[(r)$key]}" ]]; then - return 0 - else - return 1 - fi +segmentInUse() { + local key=$1 + [[ -n "${P9K_PROMPT_ELEMENTS[(r)$key]}" ]] && return 0 || return 1 } ############################################################### @@ -237,12 +270,12 @@ segment_in_use() { # $1 associative-array An associative array that contains the # deprecated segments as keys, and the new segment names as values. ## -print_deprecation_warning() { +printDeprecationWarning() { typeset -AH raw_deprecated_segments raw_deprecated_segments=(${(kvP@)1}) for key in ${(@k)raw_deprecated_segments}; do - if segment_in_use $key; then + if segmentInUse $key; then # segment is deprecated print -P "%F{yellow}Warning!%f The '$key' segment is deprecated. Use '%F{blue}${raw_deprecated_segments[$key]}%f' instead. For more informations, have a look at the CHANGELOG.md." fi @@ -393,9 +426,9 @@ function truncatePath() { # Deprecated. Use `truncatePath` instead. ## function truncatePathFromRight() { - local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER:-1} + local delim_len=${#P9K_SHORTEN_DELIMITER:-1} echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \ - "s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g" + "s@(([^/]{$((P9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$P9K_SHORTEN_DELIMITER/@g" } ############################################################### @@ -419,31 +452,3 @@ function upsearch () { popd > /dev/null fi } - -############################################################### -# @description -# Union of two or more arrays. -## -# @args -# $@ arrays The arrays to combine. -## -# @returns -# array of unique items. -## -# @note -# This does not work with indexed arrays. -## -# @usage -# union [arr1[ arr2[ ...]]] -## -# @example -# $ arr1=('a' 'b' 'c') -# $ arr2=('b' 'c' 'd') -# $ arr2=('c' 'd' 'e') -# $ union $arr1 $arr2 $arr3 -# > a b c d e -## -union() { - typeset -U sections=("$@") - echo $sections -} diff --git a/functions/vcs.zsh b/functions/vcs.zsh index f4d28a883..a3ae6a07b 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -15,19 +15,19 @@ # https://github.com/bhilburn/powerlevel9k ################################################################ -set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY true +setDefault P9K_VCS_SHOW_SUBMODULE_DIRTY true function +vi-git-untracked() { # TODO: check git >= 1.7.2 - see function git_compare_version() local FLAGS FLAGS=('--porcelain') - if [[ "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "false" ]]; then + if [[ "$P9K_VCS_SHOW_SUBMODULE_DIRTY" == "false" ]]; then FLAGS+='--ignore-submodules=dirty' fi if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ -n $(git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then - hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" + hook_com[unstaged]+=" $(printIcon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true else VCS_WORKDIR_HALF_DIRTY=false @@ -43,12 +43,12 @@ function +vi-git-aheadbehind() { # for git prior to 1.7 # ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) - (( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) + (( ahead )) && gitstatus+=( " $(printIcon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) # for git prior to 1.7 # behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) - (( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) + (( behind )) && gitstatus+=( " $(printIcon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) hook_com[misc]+=${(j::)gitstatus} } @@ -60,18 +60,18 @@ function +vi-git-remotebranch() { remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) - hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" + hook_com[branch]="$(printIcon 'VCS_BRANCH_ICON')${hook_com[branch]}" # Always show the remote #if [[ -n ${remote} ]] ; then # Only show the remote if it differs from the local if [[ -n ${remote} ]] && [[ "${remote#*/}" != "${branch_name}" ]] ; then - hook_com[branch]+="$(print_icon 'VCS_REMOTE_BRANCH_ICON')${remote// /}" + hook_com[branch]+="$(printIcon 'VCS_REMOTE_BRANCH_ICON')${remote// /}" fi } -set_default POWERLEVEL9K_VCS_HIDE_TAGS false +setDefault P9K_VCS_HIDE_TAGS false function +vi-git-tagname() { - if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then + if [[ "$P9K_VCS_HIDE_TAGS" == "false" ]]; then # If we are on a tag, append the tagname to the current branch string. local tag tag=$(git describe --tags --exact-match HEAD 2>/dev/null) @@ -85,11 +85,11 @@ function +vi-git-tagname() { # exists, so we have to manually retrieve it and clobber the branch # string. local revision - revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD) - hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" + revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${P9K_VCS_INTERNAL_HASH_LENGTH} HEAD) + hook_com[branch]="$(printIcon 'VCS_BRANCH_ICON')${revision} $(printIcon 'VCS_TAG_ICON')${tag}" else # We are on both a tag and a branch; print both by appending the tag name. - hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}" + hook_com[branch]+=" $(printIcon 'VCS_TAG_ICON')${tag}" fi fi fi @@ -102,13 +102,13 @@ function +vi-git-stash() { if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then stashes=$(git stash list 2>/dev/null | wc -l) - hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}" + hook_com[misc]+=" $(printIcon 'VCS_STASH_ICON')${stashes// /}" fi } function +vi-hg-bookmarks() { if [[ -n "${hgbmarks[@]}" ]]; then - hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}" + hook_com[hg-bookmark-string]=" $(printIcon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}" # To signal that we want to use the sting we just generated, set the special # variable `ret' to something other than the default zero: @@ -149,15 +149,15 @@ function +vi-vcs-detect-changes() { function +vi-svn-detect-changes() { local svn_status="$(svn status)" if [[ -n "$(echo "$svn_status" | \grep \^\?)" ]]; then - hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" + hook_com[unstaged]+=" $(printIcon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true fi if [[ -n "$(echo "$svn_status" | \grep \^\M)" ]]; then - hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')" + hook_com[unstaged]+=" $(printIcon 'VCS_UNSTAGED_ICON')" VCS_WORKDIR_DIRTY=true fi if [[ -n "$(echo "$svn_status" | \grep \^\A)" ]]; then - hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')" + hook_com[staged]+=" $(printIcon 'VCS_STAGED_ICON')" VCS_WORKDIR_DIRTY=true fi } diff --git a/generator/default.p9k b/generator/default.p9k index 0123fab9c..7c7dd7474 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -22,7 +22,7 @@ # Methodology behind user-defined variables overwriting colors: # The first parameter to the segment constructors is the calling function's # name. From this function name, we strip the "prompt_"-prefix and -# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed +# uppercase it. This is then prefixed with "P9K_" and suffixed # with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable # name. So each new segment is user-overwritten by a variable following # this naming convention. @@ -33,8 +33,8 @@ # right-left but reads the opposite, this isn't necessary for the other side. CURRENT_BG='NONE' -set_default last_left_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " +setDefault last_left_element_index 1 +setDefault P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " ################################################################ # @description # Construct a left prompt segment @@ -48,19 +48,19 @@ set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " # $6 string Content of the segment # $7 string Visual identifier (must be a key of the icons array) ## -left_prompt_segment() { +leftPromptSegment() { local current_index=$2 # Check if the segment should be joined with the previous one local joined - segmentShouldBeJoined $current_index $last_left_element_index "$POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false + segmentShouldBeJoined $current_index $last_left_element_index "$P9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND + local BACKGROUND_USER_VARIABLE=P9K_${(U)1#prompt_}_BACKGROUND local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND + local FOREGROUND_USER_VARIABLE=P9K_${(U)1#prompt_}_FOREGROUND local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" @@ -72,7 +72,7 @@ left_prompt_segment() { echo -n "$bg%F{$CURRENT_BG}" if [[ $joined == false ]]; then # Middle segment - echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "$(printIcon 'LEFT_SEGMENT_SEPARATOR')$P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" fi elif isSameColor "$CURRENT_BG" "$3"; then # Middle segment with same color as previous segment @@ -83,11 +83,11 @@ left_prompt_segment() { [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" echo -n "${bg}${complement}" if [[ $joined == false ]]; then - echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "$(printIcon 'LEFT_SUBSEGMENT_SEPARATOR')$P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" fi else # First segment - echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "${bg}$P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" fi local visual_identifier @@ -97,7 +97,7 @@ left_prompt_segment() { echo -n "${visual_identifier}" # Print the content of the segment, if there is any [[ -n "$6" ]] && echo -n "${fg}${6}" - echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" + echo -n "${P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" CURRENT_BG=$3 last_left_element_index=$current_index @@ -109,20 +109,20 @@ left_prompt_segment() { ## # @noargs ## -left_prompt_end() { +leftPromptEnd() { if [[ -n $CURRENT_BG ]]; then - echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" + echo -n "%k%F{$CURRENT_BG}$(printIcon 'LEFT_SEGMENT_SEPARATOR')" else echo -n "%k" fi - echo -n "%f$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" + echo -n "%f$(printIcon 'LEFT_SEGMENT_END_SEPARATOR')" CURRENT_BG='' } CURRENT_RIGHT_BG='NONE' -set_default last_right_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " +setDefault last_right_element_index 1 +setDefault P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " ################################################################ # @description # Construct a right prompt segment @@ -139,20 +139,20 @@ set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " # @notes # No ending for the right prompt segment is needed (unlike the left prompt, above). ## -right_prompt_segment() { +rightPromptSegment() { local current_index=$2 # Check if the segment should be joined with the previous one local joined - segmentShouldBeJoined $current_index $last_right_element_index "$POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false + segmentShouldBeJoined $current_index $last_right_element_index "$P9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND + local BACKGROUND_USER_VARIABLE=P9K_${(U)1#prompt_}_BACKGROUND local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND + local FOREGROUND_USER_VARIABLE=P9K_${(U)1#prompt_}_FOREGROUND local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" @@ -169,10 +169,10 @@ right_prompt_segment() { # enough contrast. local complement [[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" - echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" + echo -n "$complement$(printIcon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" else # Use the new BG color for the foreground with separator - echo -n "$(foregroundColor $3)$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f" + echo -n "$(foregroundColor $3)$(printIcon 'RIGHT_SEGMENT_SEPARATOR')%f" fi fi @@ -182,12 +182,12 @@ right_prompt_segment() { echo -n "${bg}${fg}" # Print whitespace only if segment is not joined or first right segment - [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" # Print segment content if there is any [[ -n "$6" ]] && echo -n "${6}" # Print the visual identifier - echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + echo -n "${visual_identifier}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" CURRENT_RIGHT_BG=$3 last_right_element_index=$current_index @@ -195,7 +195,7 @@ right_prompt_segment() { ################################################################ # @description -# This function wraps `left_prompt_segment` and `right_prompt_segment` +# This function wraps `leftPromptSegment` and `rightPromptSegment` # (for compatibility with the async generator). ## # @args @@ -210,7 +210,7 @@ right_prompt_segment() { # $9 string Visual identifier (must be a key of the icons array). # $10 string The condition - if the segment should be shown (gets evaluated). ## -serialize_segment() { +serializeSegment() { local NAME="${1}" local STATE="${2}" local ALIGNMENT="${3}" @@ -221,17 +221,17 @@ serialize_segment() { [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${(U)STATE}" # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" + local BACKGROUND_USER_VARIABLE="P9K_${STATEFUL_NAME}_BACKGROUND" local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" + local FOREGROUND_USER_VARIABLE="P9K_${STATEFUL_NAME}_FOREGROUND" local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" # Overwrite given bold directive by user defined variable for this segment. - local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" + local BOLD_USER_VARIABLE="P9K_${STATEFUL_NAME}_BOLD" local BOLD="${(P)BOLD_USER_VARIABLE}" [[ -z "${BOLD}" ]] && BOLD=false || BOLD=true @@ -239,11 +239,11 @@ serialize_segment() { local VISUAL_IDENTIFIER if [[ -n "${9}" ]]; then - VISUAL_IDENTIFIER="$(print_icon ${9})" + VISUAL_IDENTIFIER="$(printIcon ${9})" if [[ -n "${VISUAL_IDENTIFIER}" ]]; then # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" - set_default "${visual_identifier_color_variable}" "${FOREGROUND}" + local visual_identifier_color_variable="P9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + setDefault "${visual_identifier_color_variable}" "${FOREGROUND}" VISUAL_IDENTIFIER="%F{${(P)visual_identifier_color_variable}%}${VISUAL_IDENTIFIER}%f" # Add an whitespace if we print more than just the visual identifier if [[ -n "${CONTENT}" ]]; then @@ -265,7 +265,7 @@ serialize_segment() { # the trump card, and has # highest precedence. local CONDITION - local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" + local SEGMENT_CONDITION="P9K_${STATEFUL_NAME}_CONDITION" if defined "${SEGMENT_CONDITION}"; then CONDITION="${(P)SEGMENT_CONDITION}" elif [[ -n "${10}" ]]; then @@ -279,7 +279,7 @@ serialize_segment() { # if ! ${CONDITION}; then # continue # fi - [[ $CONDITION == true ]] && "$3_prompt_segment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + [[ $CONDITION == true ]] && "$3PromptSegment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" } ################################################################ @@ -303,11 +303,11 @@ CURRENT_BG='NONE' # $4 string Custom segment name ## prompt_custom() { - local command=POWERLEVEL9K_CUSTOM_$4:u + local command=P9K_CUSTOM_$4:u local segment_content="$(eval ${(P)command})" if [[ -n $segment_content ]]; then - serialize_segment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + serializeSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" fi } @@ -322,10 +322,10 @@ prompt_custom() { ## # @noargs ## -build_left_prompt() { +buildLeftPrompt() { local index=1 local element joined - for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do + for element in "${P9K_LEFT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -335,15 +335,23 @@ build_left_prompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi "prompt_custom" "left" "$index" $joined $element[8,-1] else + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi "prompt_$element" "left" "$index" $joined fi index=$((index + 1)) done - left_prompt_end + leftPromptEnd } ############################################################### @@ -353,10 +361,10 @@ build_left_prompt() { ## # @noargs ## -build_right_prompt() { +buildRightPrompt() { local index=1 - local joined - for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do + local element joined + for element in "${P9K_RIGHT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -366,8 +374,16 @@ build_right_prompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi "prompt_custom" "right" "$index" $joined $element[8,-1] else + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi "prompt_$element" "right" "$index" $joined fi @@ -382,11 +398,11 @@ build_right_prompt() { ## # @noargs ## -powerlevel9k_preexec() { +p9k_preexec() { _P9K_TIMER_START=$EPOCHREALTIME } -set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +setDefault P9K_PROMPT_ADD_NEWLINE false ############################################################### # @description # This function is a hook that is run before the prompts are created. @@ -395,7 +411,8 @@ set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false ## # @noargs ## -powerlevel9k_prepare_prompts() { +p9kPreparePrompts() { + local RETVAL RETVALS RPROMPT_PREFIX RPROMPT_SUFFIX RETVAL=$? RETVALS=( "$pipestatus[@]" ) @@ -404,10 +421,10 @@ powerlevel9k_prepare_prompts() { # Reset start time _P9K_TIMER_START=0x7FFFFFFF - if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then - PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) -$(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' - if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then + if [[ "$P9K_PROMPT_ON_NEWLINE" == true ]]; then + PROMPT='$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(buildLeftPrompt) +$(printIcon 'MULTILINE_LAST_PROMPT_PREFIX')' + if [[ "$P9K_RPROMPT_ON_NEWLINE" != true ]]; then # The right prompt should be on the same line as the first line of the left # prompt. To do so, there is just a quite ugly workaround: Before zsh draws # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we @@ -421,21 +438,21 @@ $(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' RPROMPT_SUFFIX='' fi else - PROMPT='%f%b%k$(build_left_prompt)' + PROMPT='%f%b%k$(buildLeftPrompt)' RPROMPT_PREFIX='' RPROMPT_SUFFIX='' fi - if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then - RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' + if [[ "$P9K_DISABLE_RPROMPT" != true ]]; then + RPROMPT='$RPROMPT_PREFIX%f%b%k$(buildRightPrompt)%{$reset_color%}$RPROMPT_SUFFIX' fi -NEWLINE=' +local NEWLINE=' ' - if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + if [[ $P9K_PROMPT_ADD_NEWLINE == true ]]; then NEWLINES="" - repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } + repeat ${P9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } PROMPT="$NEWLINES$PROMPT" fi @@ -443,8 +460,8 @@ NEWLINE=' [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" } -set_default POWERLEVEL9K_IGNORE_TERM_COLORS false -set_default POWERLEVEL9K_IGNORE_TERM_LANG false +setDefault P9K_IGNORE_TERM_COLORS false +setDefault P9K_IGNORE_TERM_LANG false ############################################################### # @description @@ -452,9 +469,9 @@ set_default POWERLEVEL9K_IGNORE_TERM_LANG false ## # @noargs ## -p9k_chpwd() { - powerlevel9k_prepare_prompts - powerlevel9k_preexec +p9kChPwd() { + p9kPreparePrompts + p9k_preexec } ############################################################### @@ -486,7 +503,7 @@ prompt_powerlevel9k_setup() { termColors # If the terminal `LANG` is set to `C`, this theme will not work at all. - if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + if [[ $P9K_IGNORE_TERM_LANG == false ]]; then local term_lang term_lang=$(echo $LANG) if [[ $term_lang == 'C' ]]; then @@ -497,8 +514,14 @@ prompt_powerlevel9k_setup() { fi fi - defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) - defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) + if ! defined P9K_LEFT_PROMPT_ELEMENTS; then + P9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) + P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") + fi + if ! defined P9K_RIGHT_PROMPT_ELEMENTS; then + P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) + P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") + fi # Display a warning if deprecated segments are in use. typeset -AH deprecated_segments @@ -506,7 +529,7 @@ prompt_powerlevel9k_setup() { deprecated_segments=( 'longstatus' 'status' ) - print_deprecation_warning deprecated_segments + printDeprecationWarning deprecated_segments # initialize colors autoload -U colors && colors @@ -521,11 +544,11 @@ prompt_powerlevel9k_setup() { autoload -Uz add-zsh-hook # prepare prompts - add-zsh-hook precmd powerlevel9k_prepare_prompts - add-zsh-hook preexec powerlevel9k_preexec + add-zsh-hook precmd p9kPreparePrompts + add-zsh-hook preexec p9k_preexec # hook into chpwd for bindkey support - chpwd_functions=(${chpwd_functions[@]} "p9k_chpwd") + chpwd_functions=(${chpwd_functions[@]} "p9kChPwd") } ############################################################### @@ -535,8 +558,8 @@ prompt_powerlevel9k_setup() { # @noargs ## prompt_powerlevel9k_teardown() { - add-zsh-hook -D precmd powerlevel9k_\* - add-zsh-hook -D preexec powerlevel9k_\* + add-zsh-hook -D precmd p9k_\* + add-zsh-hook -D preexec p9k_\* PROMPT='%m%# ' RPROMPT= } diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index ddc8aa391..f5f5eca16 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -27,7 +27,7 @@ # Prompt Segment Constructors ################################################################ -POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " +P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " ############################################################### # @description # Spawn a subshell to convert the data into a left prompt segment @@ -41,7 +41,7 @@ POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=" " # $6 string Content - Segment content # $7 string Visual Identifier - Segment icon ## -left_prompt_segment() { +leftPromptSegment() { # Name the parameters and add %K and %F to color variables local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" BOLD="${5}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" # Check if it should be bold @@ -52,14 +52,14 @@ left_prompt_segment() { [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}" # Add the content if [[ -n ${CONTENT} ]]; then - [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b" || SEGMENT+="${CONTENT}" fi # Return the result to the main process, delimited by "·|·" [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" } -POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " +P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " ############################################################### # @description # Spawn a subshell to convert the data into a right prompt segment @@ -73,24 +73,24 @@ POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " # $6 string Content - Segment content # $7 string Visual Identifier - Segment icon ## -right_prompt_segment() { +rightPromptSegment() { # Name the parameters and add %K and %F to color variables local STATEFUL_NAME="${1}" INDEX="${2}" BG="%K{${3}}" FG="%F{${4}}" CONTENT="${6}" VISUAL_IDENTIFIER="${7}" # Check if it should be bold [[ ${BOLD} == "true" ]] && local BD="%B" || local BD="" # Set the colors local SEGMENT="${BG}${FG}" - if [[ ${(L)POWERLEVEL9K_RPROMPT_ICON_LEFT} == "true" ]]; then # Visual identifier before content + if [[ ${(L)P9K_RPROMPT_ICON_LEFT} == "true" ]]; then # Visual identifier before content # Add the visual identifier if it exists - [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" # Add the content [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b" || SEGMENT+="${CONTENT}" else # Content before visual identifier # Add the content - SEGMENT+="${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + SEGMENT+="${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b${BG}${FG}" || SEGMENT+="${CONTENT}" # Add the visual identifier if it exists - [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" fi # Return the result to the main process, delimited by "·|·" [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" @@ -162,14 +162,14 @@ update_left_prompt() { if [[ "${LBG}" == "${LAST_LBG}" ]]; then # Are the backgrounds the same... # We take the current foreground color as color for our subsegment, and # add a left sub segment separator. This should have enough contrast. - LEFT_PROMPT+="%K{${LBG}}%F{${LFG}}${_POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR} " + LEFT_PROMPT+="%K{${LBG}}%F{${LFG}}${_P9K_LEFT_SUBSEGMENT_SEPARATOR} " else # Add a left segment separator - LEFT_PROMPT+="%K{${LBG}}%F{${LAST_LBG}}${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR} " + LEFT_PROMPT+="%K{${LBG}}%F{${LAST_LBG}}${_P9K_LEFT_SEGMENT_SEPARATOR} " fi fi else # ...otherwise it is the first segment and there is no previous background - [[ "${POWERLEVEL9K_FANCY_EDGE}" == "true" ]] && LEFT_PROMPT+="%F{${LBG}}${_POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR}" + [[ "${P9K_FANCY_EDGE}" == "true" ]] && LEFT_PROMPT+="%F{${LBG}}${_P9K_RIGHT_SEGMENT_SEPARATOR}" LEFT_PROMPT+="%K{${LBG}} " fi # Add the segment to the left prompt string @@ -180,7 +180,7 @@ update_left_prompt() { local LBI=$((${#P9K_LP_CONTENT} + 1)) LBG=$(last_left_bg ${LBI}) # Add the last left segment separator and the suffix - LEFT_PROMPT+="%F{${LBG}}%k${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR}%f%b " + LEFT_PROMPT+="%F{${LBG}}%k${_P9K_LEFT_SEGMENT_SEPARATOR}%f%b " # Set the left prompt PROMPT=${LEFT_PROMPT_PREFIX}${LEFT_PROMPT}${LEFT_PROMPT_SUFFIX} # About .reset-prompt see: @@ -214,17 +214,17 @@ update_right_prompt() { if [[ "${RBG}" == "${LAST_RBG}" ]]; then # We take the current foreground color as color for our subsegment, # and add a sub segment separator. This should have enough contrast. - RIGHT_PROMPT+="%K{${RBG}}%F{${RFG}}${_POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR}" + RIGHT_PROMPT+="%K{${RBG}}%F{${RFG}}${_P9K_RIGHT_SUBSEGMENT_SEPARATOR}" else # ...otherwise add a right segment separator - RIGHT_PROMPT+="%K{${LAST_RBG}}%F{${RBG}}${_POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR}" + RIGHT_PROMPT+="%K{${LAST_RBG}}%F{${RBG}}${_P9K_RIGHT_SEGMENT_SEPARATOR}" fi fi # Add the segment to the right prompt string RIGHT_PROMPT+="${P9K_RP_CONTENT[$i]} " fi done - [[ "${POWERLEVEL9K_FANCY_EDGE}" == "true" ]] && RIGHT_PROMPT+="%k%F{$RBG}${_POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR}%f" + [[ "${P9K_FANCY_EDGE}" == "true" ]] && RIGHT_PROMPT+="%k%F{$RBG}${_P9K_LEFT_SEGMENT_SEPARATOR}%f" # Set the left prompt RPROMPT=${RIGHT_PROMPT_PREFIX}${RIGHT_PROMPT}${RIGHT_PROMPT_SUFFIX} # About .reset-prompt see: @@ -256,7 +256,7 @@ p9k_async_callback() { # Determine which function returned output... case $JOB in - p9k_serialize_segment) # Segment code was converted into data + p9k_serializeSegment) # Segment code was converted into data # Make sure we received the data if [[ -n $OUTPUT ]]; then # split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 @@ -273,7 +273,7 @@ p9k_async_callback() { # 1. No segment should print if they provide no content (default condition). # 2. Segments can define a default condition on their own, overriding the previous one. # 3. Users can set a condition for each segment. This is the trump card, and has highest precedence. - local SEGMENT_CONDITION="POWERLEVEL9K_${STATEFUL_NAME}_CONDITION" + local SEGMENT_CONDITION="P9K_${STATEFUL_NAME}_CONDITION" if defined "${SEGMENT_CONDITION}"; then CONDITION="${(P)SEGMENT_CONDITION}" elif [[ -n "${CONDITION}" && "$CONDITION[0,1]" == "[" ]]; then @@ -291,21 +291,21 @@ p9k_async_callback() { P9K_LP_FOREGROUND[$INDEX]="${FOREGROUND}" P9K_LP_JOINED[$INDEX]="${JOINED}" # Send the data to a subshell to be converted into a left prompt segment - async_job "p9k" left_prompt_segment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + async_job "p9k" leftPromptSegment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" else # ...it is a right prompt segment # Store the background, foreground and joined states in separate arrays P9K_RP_BACKGROUND[$INDEX]="${BACKGROUND}" P9K_RP_FOREGROUND[$INDEX]="${FOREGROUND}" P9K_RP_JOINED[$INDEX]="${JOINED}" # Send the data to a subshell to be converted into a left prompt segment - async_job "p9k" right_prompt_segment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + async_job "p9k" rightPromptSegment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" fi else # ...otherwise set the prompt content array to "·" (no segemnt) [[ "${ALIGNMENT}" == "left" ]] && P9K_LP_CONTENT[${INDEX}]="·" || P9K_RP_CONTENT[${INDEX}]="·" fi fi ;; - left_prompt_segment) # Data was converted into a left prompt segment + leftPromptSegment) # Data was converted into a left prompt segment # Make sure we received the segment data if [[ -n $OUTPUT ]]; then # Split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 @@ -318,7 +318,7 @@ p9k_async_callback() { update_left_prompt fi ;; - right_prompt_segment) # Data was converted into a right prompt segment + rightPromptSegment) # Data was converted into a right prompt segment # Make sure we received the segment data if [[ -n $OUTPUT ]]; then # Split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 @@ -356,7 +356,7 @@ p9k_async_callback() { # $9 string Visual identifier - Segment icon # $10 string Condition - The condition, if the segment should be printed (gets evaluated) ## -p9k_serialize_segment() { +p9k_serializeSegment() { local NAME="${(U)1}" STATE="${(U)2}" ALIGNMENT="${3}" INDEX="${4}" JOINED="${5}" CONTENT="${8}" CONDITION="${10}" ################################################################ @@ -364,7 +364,7 @@ p9k_serialize_segment() { # # The first parameter to the segment constructors is the calling function's # name. From this function name, we strip the "prompt_"-prefix and - # uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed + # uppercase it. This is then prefixed with "P9K_" and suffixed # with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable # name. So each new segment is user-overwritten by a variable following # this naming convention. @@ -375,27 +375,27 @@ p9k_serialize_segment() { [[ -n "${STATE}" ]] && STATEFUL_NAME="${STATEFUL_NAME}_${STATE}" # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BACKGROUND" + local BACKGROUND_USER_VARIABLE="P9K_${STATEFUL_NAME}_BACKGROUND" local BACKGROUND="${(P)BACKGROUND_USER_VARIABLE}" [[ -z "${BACKGROUND}" ]] && BACKGROUND="${6}" # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_FOREGROUND" + local FOREGROUND_USER_VARIABLE="P9K_${STATEFUL_NAME}_FOREGROUND" local FOREGROUND="${(P)FOREGROUND_USER_VARIABLE}" [[ -z "${FOREGROUND}" ]] && FOREGROUND="${7}" # Overwrite given bold directive by user defined variable for this segment. - local BOLD_USER_VARIABLE="POWERLEVEL9K_${STATEFUL_NAME}_BOLD" + local BOLD_USER_VARIABLE="P9K_${STATEFUL_NAME}_BOLD" local BOLD="${(P)BOLD_USER_VARIABLE}" [[ -z "${BOLD}" ]] && BOLD="false" || BOLD="true" # Precompile the Visual Identifier with color and spacing local VISUAL_IDENTIFIER if [[ -n "${9}" ]]; then - VISUAL_IDENTIFIER="$(print_icon ${9})" + VISUAL_IDENTIFIER="$(printIcon ${9})" if [[ -n "${VISUAL_IDENTIFIER}" ]]; then # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable="POWERLEVEL9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" + local visual_identifier_color_variable="P9K_${STATEFUL_NAME}_VISUAL_IDENTIFIER_COLOR" local visual_identifier_color="${(P)visual_identifier_color_variable}" # only add color to icon if override color is set and not equal to foreground if [[ -n "${visual_identifier_color}" && "${visual_identifier_color}" != "${FOREGROUND}" ]]; then @@ -403,7 +403,7 @@ p9k_serialize_segment() { fi # Add an whitespace if we print more than just the visual identifier if [[ -n "${CONTENT}" ]]; then - [[ "${POWERLEVEL9K_RPROMPT_ICON_LEFT}" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " || + [[ "${P9K_RPROMPT_ICON_LEFT}" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " || [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" fi fi @@ -421,8 +421,8 @@ p9k_serialize_segment() { # @args # $@ misc The parameters passed from the segment code ## -serialize_segment() { - (async_job "p9k" "p9k_serialize_segment" "${@}") +serializeSegment() { + (async_job "p9k" "p9k_serializeSegment" "${@}") } ################################################################ @@ -440,11 +440,11 @@ serialize_segment() { # $3 boolean Whether the segment should be joined # $4 string Custom segment name prompt_custom() { - local command=POWERLEVEL9K_CUSTOM_$4:u + local command=P9K_CUSTOM_$4:u local segment_content="$(eval ${(P)command})" if [[ -n $segment_content ]]; then - serialize_segment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + serializeSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" fi } @@ -455,10 +455,10 @@ prompt_custom() { ## # @noargs ## -build_left_prompt() { +buildLeftPrompt() { local index=1 local joined - for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do + for element in "${P9K_LEFT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -486,10 +486,10 @@ build_left_prompt() { ## # @noargs ## -build_right_prompt() { +buildRightPrompt() { local index=1 local joined - for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do + for element in "${P9K_RIGHT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -514,7 +514,7 @@ build_right_prompt() { ## # @noargs ## -powerlevel9k_preexec() { +p9k_preexec() { # The Timer is started here, but the end # is taken in powerlevel_prepare_prompts, # as this method is a precmd hook and runs @@ -531,7 +531,7 @@ powerlevel9k_preexec() { ## # @noargs ## -powerlevel9k_prepare_prompts() { +p9kPreparePrompts() { setopt localoptions noshwordsplit # stop any running async jobs @@ -580,11 +580,11 @@ powerlevel9k_prepare_prompts() { local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters # Preset multiline prompt - if [[ "${POWERLEVEL9K_PROMPT_ON_NEWLINE}" == true ]]; then - LEFT_PROMPT_PREFIX="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" + if [[ "${P9K_PROMPT_ON_NEWLINE}" == true ]]; then + LEFT_PROMPT_PREFIX="$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" LEFT_PROMPT_SUFFIX=" -$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" - if [[ "${POWERLEVEL9K_RPROMPT_ON_NEWLINE}" != true ]]; then +$(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" + if [[ "${P9K_RPROMPT_ON_NEWLINE}" != true ]]; then # The right prompt should be on the same line as the first line of the left # prompt. To do so, there is just a quite ugly workaround: Before zsh draws # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we @@ -596,16 +596,16 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" fi # Precompile the Segment Separators here! - _POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR="$(print_icon 'LEFT_SEGMENT_SEPARATOR')" - _POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR="$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')" - _POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR="$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" - _POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR="$(print_icon 'RIGHT_SEGMENT_SEPARATOR')" - _POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR="$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')" + _P9K_LEFT_SEGMENT_SEPARATOR="$(printIcon 'LEFT_SEGMENT_SEPARATOR')" + _P9K_LEFT_SUBSEGMENT_SEPARATOR="$(printIcon 'LEFT_SUBSEGMENT_SEPARATOR')" + _P9K_LEFT_SEGMENT_END_SEPARATOR="$(printIcon 'LEFT_SEGMENT_END_SEPARATOR')" + _P9K_RIGHT_SEGMENT_SEPARATOR="$(printIcon 'RIGHT_SEGMENT_SEPARATOR')" + _P9K_RIGHT_SUBSEGMENT_SEPARATOR="$(printIcon 'RIGHT_SUBSEGMENT_SEPARATOR')" # Call the prompt building functions - build_left_prompt - if [[ "${(L)POWERLEVEL9K_DISABLE_RPROMPT}" != "true" ]]; then - build_right_prompt + buildLeftPrompt + if [[ "${(L)P9K_DISABLE_RPROMPT}" != "true" ]]; then + buildRightPrompt fi } @@ -615,9 +615,9 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" ## # @noargs ## -p9k_chpwd() { - powerlevel9k_prepare_prompts - powerlevel9k_preexec +p9kChPwd() { + p9kPreparePrompts + p9k_preexec } ############################################################### @@ -649,7 +649,7 @@ prompt_powerlevel9k_setup() { termColors # If the terminal `LANG` is set to `C`, this theme will not work at all. - if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + if [[ $P9K_IGNORE_TERM_LANG == false ]]; then local term_lang term_lang=$(echo $LANG) if [[ $term_lang == 'C' ]]; then @@ -669,7 +669,7 @@ prompt_powerlevel9k_setup() { deprecated_segments=( 'longstatus' 'status' ) - print_deprecation_warning deprecated_segments + printDeprecationWarning deprecated_segments # initialize colors autoload -U colors && colors @@ -689,7 +689,7 @@ prompt_powerlevel9k_setup() { # initialize zsh async #autoload -Uz async && async - source $p9k_directory/zsh-async/async.zsh + source $p9kDirectory/zsh-async/async.zsh # initialize async worker (( !${p9k_async_init:-0} )) && { @@ -699,14 +699,14 @@ prompt_powerlevel9k_setup() { } # prepare prompts - add-zsh-hook precmd powerlevel9k_prepare_prompts - add-zsh-hook preexec powerlevel9k_preexec + add-zsh-hook precmd p9kPreparePrompts + add-zsh-hook preexec p9k_preexec # initialize zle zle # hook into chpwd for bindkey support - chpwd_functions=(${chpwd_functions[@]} "p9k_chpwd") + chpwd_functions=(${chpwd_functions[@]} "p9kChPwd") } ############################################################### @@ -715,9 +715,9 @@ prompt_powerlevel9k_setup() { ## # @noargs ## -prompt_powerlevel9k_teardown() { - add-zsh-hook -D precmd powerlevel9k_\* - add-zsh-hook -D preexec powerlevel9k_\* +prompt_p9k_teardown() { + add-zsh-hook -D precmd p9k_\* + add-zsh-hook -D preexec p9k_\* PROMPT='%m%# ' RPROMPT= } diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 002538caa..f037ca2ab 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -26,23 +26,23 @@ #set -o xtrace # Try to set the installation path -if [[ -n "$POWERLEVEL9K_INSTALLATION_DIR" ]]; then - p9k_directory=${POWERLEVEL9K_INSTALLATION_DIR:A} +if [[ -n "$P9K_INSTALLATION_DIR" ]]; then + p9kDirectory=${P9K_INSTALLATION_DIR:A} else if [[ "${(%):-%N}" == '(eval)' ]]; then if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then # Antigen uses eval to load things so it can change the plugin (!!) # https://github.com/zsh-users/antigen/issues/581 - p9k_directory=$PWD + p9kDirectory=$PWD else - print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR to work from within an (eval).%f" + print -P "%F{red}You must set P9K_INSTALLATION_DIR to work from within an (eval).%f" return 1 fi else # Get the path to file this code is executing in; then # get the absolute path and strip the filename. # See https://stackoverflow.com/a/28336473/108857 - p9k_directory=${${(%):-%x}:A:h} + p9kDirectory=${${(%):-%x}:A:h} fi fi @@ -50,25 +50,25 @@ fi # Source icon functions ################################################################ -source "${p9k_directory}/functions/icons.zsh" +source "${p9kDirectory}/functions/icons.zsh" ################################################################ # Source utility functions ################################################################ -source "${p9k_directory}/functions/utilities.zsh" +source "${p9kDirectory}/functions/utilities.zsh" ################################################################ # Source color functions ################################################################ -source "${p9k_directory}/functions/colors.zsh" +source "${p9kDirectory}/functions/colors.zsh" ################################################################ # Color Scheme ################################################################ -if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then +if [[ "$P9K_COLOR_SCHEME" == "light" ]]; then DEFAULT_COLOR=white DEFAULT_COLOR_INVERTED=black else @@ -76,34 +76,36 @@ else DEFAULT_COLOR_INVERTED=white fi -################################################################ -# Load Prompt Segment Definitions -################################################################ - -# load only the segments that are being used! -local segment_name -for segment in $p9k_directory/segments/**/*.p9k; do - segment_name=${${segment##*/}%.p9k} - if segment_in_use "$segment_name"; then - source "${segment}" - fi -done - -# cleanup temporary variable -#unset p9k_directory - ################################################################ # Choose the generator ################################################################ -case "${(L)POWERLEVEL9K_GENERATOR}" in +case "${(L)P9K_GENERATOR}" in "zsh-async") - source "${p9k_directory}/generator/zsh-async.p9k" + source "${p9kDirectory}/generator/zsh-async.p9k" ;; *) - source "${p9k_directory}/generator/default.p9k" + source "${p9kDirectory}/generator/default.p9k" ;; esac +################################################################ +# Load Prompt Segment Definitions +################################################################ + +# load only the segments that are being used! +local segmentName +typeset -gU loadedSegments +for segment in $p9kDirectory/segments/*.p9k; do + segmentName=${${segment##*/}%.p9k} + if segmentInUse "$segmentName"; then + source "${segment}" 2>&1 + loadedSegments+=("${segmentName}") + fi +done + +# cleanup temporary variable - not done because it is used for autoloading segments +#unset p9kDirectory + # Launch the generator prompt_powerlevel9k_setup "$@" diff --git a/segments/developer/anaconda.p9k b/segments/anaconda.p9k similarity index 75% rename from segments/developer/anaconda.p9k rename to segments/anaconda.p9k index 6ccdfa3ce..8611b93a5 100644 --- a/segments/developer/anaconda.p9k +++ b/segments/anaconda.p9k @@ -14,12 +14,12 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  -register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +registerIcon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # Register segment default values -set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" -set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" +setDefault P9K_ANACONDA_LEFT_DELIMITER "(" +setDefault P9K_ANACONDA_RIGHT_DELIMITER ")" ################################################################ # @description @@ -35,6 +35,6 @@ prompt_anaconda() { # variant works even if both are set. _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then - serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' + serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$P9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$P9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' fi } diff --git a/segments/developer/aws.p9k b/segments/aws.p9k similarity index 84% rename from segments/developer/aws.p9k rename to segments/aws.p9k index 43d78b170..cd9c1342b 100644 --- a/segments/developer/aws.p9k +++ b/segments/aws.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' +registerIcon "AWS_ICON" 'AWS:' $'\uE895' $'\uF270' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF270' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_aws() { local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" if [[ -n "$aws_profile" ]]; then - serialize_segment "$0" "" $1 "$2" $3 red white "$aws_profile" 'AWS_ICON' + serializeSegment "$0" "" $1 "$2" $3 red white "$aws_profile" 'AWS_ICON' fi } diff --git a/segments/developer/aws_eb_env.p9k b/segments/aws_eb_env.p9k similarity index 85% rename from segments/developer/aws_eb_env.p9k rename to segments/aws_eb_env.p9k index 45204049a..0fc0fbe7e 100644 --- a/segments/developer/aws_eb_env.p9k +++ b/segments/aws_eb_env.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # 🌱 🌱 🌱 🌱  -register_icon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' +registerIcon "AWS_EB_ICON" $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\U1F331 ' $'\UF1BD ' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_aws_eb_env() { local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') if [[ -n "$eb_env" ]]; then - serialize_segment "$0" "" $1 "$2" $3 black green "$eb_env" 'AWS_EB_ICON' + serializeSegment "$0" "" $1 "$2" $3 black green "$eb_env" 'AWS_EB_ICON' fi } diff --git a/segments/core/background_jobs.p9k b/segments/background_jobs.p9k similarity index 68% rename from segments/core/background_jobs.p9k rename to segments/background_jobs.p9k index 146c84fcf..7cfac6497 100644 --- a/segments/core/background_jobs.p9k +++ b/segments/background_jobs.p9k @@ -11,10 +11,10 @@ # Register icons # ⚙     -register_icon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' +registerIcon "BACKGROUND_JOBS_ICON" $'\u2699' $'\uE82F ' $'\uF013 ' '\u'$CODEPOINT_OF_AWESOME_COG' ' $'\uF013 ' -set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true -set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +setDefault P9K_BACKGROUND_JOBS_VERBOSE true +setDefault P9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false ################################################################ # @description # Displays the number of background jobs with an icon. @@ -32,9 +32,9 @@ prompt_background_jobs() { fi if [[ background_jobs_number -gt 0 ]]; then local background_jobs_number_print="" - if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then + if [[ "$P9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$P9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then background_jobs_number_print="$background_jobs_number" fi - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' fi } diff --git a/segments/core/battery.p9k b/segments/battery.p9k similarity index 73% rename from segments/core/battery.p9k rename to segments/battery.p9k index 264a78ae5..09995f734 100644 --- a/segments/core/battery.p9k +++ b/segments/battery.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # 🔋  🔋   -register_icon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' +registerIcon "BATTERY_ICON" $'\U1F50B' $'\uE894' $'\U1F50B' '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL $'\UF240 ' ################################################################ # @description @@ -36,7 +36,7 @@ prompt_battery() { 'disconnected' "$DEFAULT_COLOR_INVERTED" ) # Set default values if the user did not configure them - set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 + setDefault P9K_BATTERY_LOW_THRESHOLD 10 if [[ $OS =~ macOS && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then # obtain battery information from system @@ -62,7 +62,7 @@ prompt_battery() { remain=" ($tstring)" ;; 'discharging') - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + [[ $bat_percent -lt $P9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" remain=" ($tstring)" ;; *) @@ -89,7 +89,7 @@ prompt_battery() { [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true if [[ -z $connected ]]; then - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + [[ $bat_percent -lt $P9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" else [[ $bat_percent =~ 100 ]] && current_state="charged" [[ $bat_percent -lt 100 ]] && current_state="charging" @@ -107,32 +107,32 @@ prompt_battery() { local message # Default behavior: Be verbose! - set_default POWERLEVEL9K_BATTERY_VERBOSE true - if [[ "$POWERLEVEL9K_BATTERY_VERBOSE" == true ]]; then + setDefault P9K_BATTERY_VERBOSE true + if [[ "$P9K_BATTERY_VERBOSE" == true ]]; then message="$bat_percent%%$remain" else message="$bat_percent%%" fi - if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]] && [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]]; then + if [[ -n "$P9K_BATTERY_STAGES" ]] && [[ -n "$P9K_BATTERY_LEVEL_BACKGROUND" ]]; then # override default icon if we are using battery stages - if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ -n "$P9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#P9K_BATTERY_STAGES} - 1 ) )) if [[ $segment > 1 ]]; then local offset=$(( ($bat_percent / $segment) + 1 )) # check if the stages are in an array or a string - [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + [[ "${(t)P9K_BATTERY_STAGES}" =~ "array" ]] && P9K_BATTERY_ICON="$P9K_BATTERY_STAGES[$offset]" || P9K_BATTERY_ICON=${P9K_BATTERY_STAGES:$offset:1} fi fi # override the default color if we are using a color level array - if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then - local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + if [[ -n "$P9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)P9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#P9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) local offset=$(( ($bat_percent / $segment) + 1 )) - serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${P9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi else # Draw the prompt_segment - serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi } diff --git a/segments/developer/chruby.p9k b/segments/chruby.p9k similarity index 86% rename from segments/developer/chruby.p9k rename to segments/chruby.p9k index c51c610c4..681cae620 100644 --- a/segments/developer/chruby.p9k +++ b/segments/chruby.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +registerIcon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ # Segment to display @@ -34,6 +34,6 @@ prompt_chruby() { chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" # Don't show anything if the chruby did not change the default ruby if [[ "${chrb_env:-system}" != "system" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' + serializeSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' fi } diff --git a/segments/core/command_execution_time.p9k b/segments/command_execution_time.p9k similarity index 74% rename from segments/core/command_execution_time.p9k rename to segments/command_execution_time.p9k index 596b5466f..59cc6e35d 100644 --- a/segments/core/command_execution_time.p9k +++ b/segments/command_execution_time.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    -register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' +registerIcon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END $'\uF252' ################################################################ # @description @@ -26,8 +26,8 @@ register_icon "EXECUTION_TIME_ICON" 'Dur' $'\UE89C' $'\uF253' '\u'$CODEPOINT # $3 boolean Whether the segment should be joined ## prompt_command_execution_time() { - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 + setDefault P9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 + setDefault P9K_COMMAND_EXECUTION_TIME_PRECISION 2 # Print time in human readable format # For that use `strftime` and convert @@ -42,17 +42,17 @@ prompt_command_execution_time() { else # If the command executed in seconds, print as float. # Convert to float - if [[ "${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION}" == "0" ]]; then + if [[ "${P9K_COMMAND_EXECUTION_TIME_PRECISION}" == "0" ]]; then # If user does not want microseconds, then we need to convert # the duration to an integer. typeset -i humanReadableDuration else - typeset -F ${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION} humanReadableDuration + typeset -F ${P9K_COMMAND_EXECUTION_TIME_PRECISION} humanReadableDuration fi humanReadableDuration=$_P9K_COMMAND_DURATION fi - if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - serialize_segment "$0" "" $1 "$2" $3 "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + if (( _P9K_COMMAND_DURATION >= P9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then + serializeSegment "$0" "" $1 "$2" $3 "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' fi } diff --git a/segments/core/context.p9k b/segments/context.p9k similarity index 70% rename from segments/core/context.p9k rename to segments/context.p9k index bc5154942..08642dcc0 100644 --- a/segments/core/context.p9k +++ b/segments/context.p9k @@ -9,9 +9,9 @@ # Dominic Ritter (dritter) ## -set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false -set_default POWERLEVEL9K_ALWAYS_SHOW_USER false -set_default POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" +setDefault P9K_ALWAYS_SHOW_CONTEXT false +setDefault P9K_ALWAYS_SHOW_USER false +setDefault P9K_CONTEXT_TEMPLATE "%n@%m" ################################################################ # @description # Displays the context - user@hostname (who am I and where am I). @@ -37,9 +37,9 @@ prompt_context() { local content="" - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then - content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" - elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + if [[ "$P9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + content="${P9K_CONTEXT_TEMPLATE}" + elif [[ "$P9K_ALWAYS_SHOW_USER" == true ]]; then content="$(whoami)" else return @@ -57,5 +57,5 @@ prompt_context() { current_state="SUDO" fi - serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" + serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" } diff --git a/segments/core/date.p9k b/segments/date.p9k similarity index 76% rename from segments/core/date.p9k rename to segments/date.p9k index 0bd6911fd..7fe536d93 100644 --- a/segments/core/date.p9k +++ b/segments/date.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' +registerIcon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' ################################################################ # @description @@ -26,7 +26,7 @@ register_icon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' # $3 boolean Whether the segment should be joined ## prompt_date() { - set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" + setDefault P9K_DATE_FORMAT "%D{%d.%m.%y}" - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_DATE_FORMAT" "DATE_ICON" } diff --git a/segments/developer/detect_virt.p9k b/segments/detect_virt.p9k similarity index 84% rename from segments/developer/detect_virt.p9k rename to segments/detect_virt.p9k index a341df297..ffe21ab1e 100644 --- a/segments/developer/detect_virt.p9k +++ b/segments/detect_virt.p9k @@ -26,11 +26,11 @@ prompt_detect_virt() { if [[ "$virt" == "none" ]]; then if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then virt="chroot" - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" else ; fi else - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" fi } diff --git a/segments/core/dir.p9k b/segments/dir.p9k similarity index 69% rename from segments/core/dir.p9k rename to segments/dir.p9k index ba9c7240a..e067a7ee2 100644 --- a/segments/core/dir.p9k +++ b/segments/dir.p9k @@ -14,17 +14,17 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' +registerIcon "HOME_ICON" '' $'\uE12C' $'\uF015' '\u'$CODEPOINT_OF_AWESOME_HOME $'\uF015' #     -register_icon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' +registerIcon "HOME_SUB_ICON" '' $'\uE18D' $'\uF07C' '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN $'\uF07C' #     -register_icon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' +registerIcon "FOLDER_ICON" '' $'\uE818' $'\uF115' '\u'$CODEPOINT_OF_AWESOME_FOLDER_O $'\uF115' #     -register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' -set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" -set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" -set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +setDefault P9K_DIR_PATH_SEPARATOR "/" +setDefault P9K_HOME_FOLDER_ABBREVIATION "~" +setDefault P9K_DIR_PATH_HIGHLIGHT_BOLD false ################################################################ # @description # Display information about the current working directory. @@ -35,33 +35,33 @@ set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false # $3 boolean Whether the segment should be joined ## prompt_dir() { - # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE + # using $PWD instead of "$(print -P '%~')" to allow use of P9K_DIR_PATH_ABSOLUTE local current_path=$PWD # WAS: local current_path="$(print -P '%~')" # check if the user wants to use absolute paths or "~" paths - [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + [[ ${(L)P9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} # declare all local variables local paths directory test_dir test_dir_length trunc_path threshhold # if we are not in "~" or "/", split the paths into an array and exclude "~" (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. - if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then - set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" + if [[ -n "$P9K_SHORTEN_DIR_LENGTH" || "$P9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$P9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then + setDefault P9K_SHORTEN_DELIMITER "\u2026" # convert delimiter from unicode to literal character, so that we can get the correct length later - local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) + local delim=$(echo -n $P9K_SHORTEN_DELIMITER) - case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + case "$P9K_SHORTEN_STRATEGY" in truncate_middle) # truncate characters from the middle of the path - current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") + current_path=$(truncatePath $current_path $P9K_SHORTEN_DIR_LENGTH $P9K_SHORTEN_DELIMITER "middle") ;; truncate_from_right) # truncate characters from the right of the path - current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + current_path=$(truncatePath "$current_path" $P9K_SHORTEN_DIR_LENGTH $P9K_SHORTEN_DELIMITER) ;; truncate_absolute|truncate_absolute_chars) - # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters - if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then - current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + # truncate all characters except the last P9K_SHORTEN_DIR_LENGTH characters + if [ ${#current_path} -gt $(( $P9K_SHORTEN_DIR_LENGTH + ${#P9K_SHORTEN_DELIMITER} )) ]; then + current_path=$P9K_SHORTEN_DELIMITER${current_path:(-P9K_SHORTEN_DIR_LENGTH)} fi ;; truncate_to_last) @@ -69,15 +69,15 @@ prompt_dir() { current_path=${current_path##*/} ;; truncate_to_first_and_last) - if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then - threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) + if (( ${#current_path} > 1 )) && (( ${P9K_SHORTEN_DIR_LENGTH} > 0 )); then + threshhold=$(( ${P9K_SHORTEN_DIR_LENGTH} * 2)) # if we are in "~", add it back into the paths array [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") if (( ${#paths} > $threshhold )); then - local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) + local num=$(( ${#paths} - ${P9K_SHORTEN_DIR_LENGTH} )) # repace the middle elements - for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do - paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER + for (( i=$P9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do + paths[$i+1]=$P9K_SHORTEN_DELIMITER done [[ $current_path != '~'* ]] && current_path="/" || current_path="" current_path+="${(j:/:)paths}" @@ -110,12 +110,12 @@ prompt_dir() { truncate_with_folder_marker) if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this local last_marked_folder marked_folder - set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker" + setDefault P9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker" # Search for the folder marker in the parent directories and # buildup a pattern that is removed from the current path # later on. - for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do + for marked_folder in $(upsearch $P9K_SHORTEN_FOLDER_MARKER); do if [[ "$marked_folder" == "/" ]]; then # If we reached root folder, stop upsearch. trunc_path="/" @@ -125,7 +125,7 @@ prompt_dir() { elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then trunc_path="${trunc_path%/}/${marked_folder##*/}" else - trunc_path="${trunc_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}" + trunc_path="${trunc_path%/}/$P9K_SHORTEN_DELIMITER/${marked_folder##*/}" fi last_marked_folder=$marked_folder done @@ -162,13 +162,13 @@ prompt_dir() { # Then, find the length of the package_path string, and save the # subdirectory path as a substring of the current directory's path from 0 # to the length of the package path's string - subdirectory_path=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + subdirectory_path=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $P9K_SHORTEN_DIR_LENGTH $P9K_SHORTEN_DELIMITER) # Parse the 'name' from the package.json; if there are any problems, just # print the file path - defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json) + defined P9K_DIR_PACKAGE_FILES || P9K_DIR_PACKAGE_FILES=(package.json composer.json) local pkgFile="unknown" - for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do + for file in "${P9K_DIR_PACKAGE_FILES[@]}"; do if [[ -f "${package_path}/${file}" ]]; then pkgFile="${package_path}/${file}" break; @@ -186,7 +186,7 @@ prompt_dir() { fi ;; *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + current_path="$(print -P "%$((P9K_SHORTEN_DIR_LENGTH+1))(c:$P9K_SHORTEN_DELIMITER/:)%${P9K_SHORTEN_DIR_LENGTH}c")" ;; esac fi @@ -203,7 +203,7 @@ prompt_dir() { ) local state_path="$(print -P '%~')" local current_state="DEFAULT" - if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + if [[ "${P9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then current_state="NOT_WRITABLE" elif [[ $state_path == '~' ]]; then current_state="HOME" @@ -212,9 +212,9 @@ prompt_dir() { fi # declare variables used for bold and state colors - local bld dir_state_foreground dir_state_user_foreground + local bld_on bld_off dir_state_foreground dir_state_user_foreground # test if user wants the last directory printed in bold - if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then + if [[ "${(L)P9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then bld_on="%B" bld_off="%b" else @@ -222,7 +222,7 @@ prompt_dir() { bld_off="" fi # determine is the user has set a last directory color - local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND + local dir_state_user_foreground=P9K_DIR_${current_state}_FOREGROUND local dir_state_foreground=${(P)dir_state_user_foreground} [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" @@ -232,16 +232,16 @@ prompt_dir() { base_name=${path_opt##*/} # if the user wants the last directory colored... - if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then + if [[ -n ${P9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then # it the path is "/" or "~" if [[ $path_opt == "/" || $path_opt == "~" ]]; then - current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" + current_path="${bld_on}%F{$P9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" else # has a subfolder # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute if [[ $dir_name != $base_name ]]; then - current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + current_path="${dir_name}/${bld_on}%F{$P9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" else - current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + current_path="${bld_on}%F{$P9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" fi fi else # no coloring @@ -259,26 +259,26 @@ prompt_dir() { fi # check if we need to omit the first character and only do it if we are not in "~" or "/" - if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then + if [[ "${P9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then current_path="${current_path[2,-1]}" fi # check if the user wants the separator colored. - if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then + if [[ -n ${P9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then # because this contains color changing codes, it is easier to set a variable for what should be replaced - local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" + local repl="%F{$P9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" # escape the / with a \ current_path=${current_path//\//$repl} fi - if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then - current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} + if [[ "${P9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then + current_path=${current_path//\//$P9K_DIR_PATH_SEPARATOR} fi - if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + if [[ "${P9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)P9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then # use :s to only replace the first occurance - current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} + current_path=${current_path:s/~/$P9K_HOME_FOLDER_ABBREVIATION} fi - serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" + serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" } diff --git a/segments/core/dir_writable.p9k b/segments/dir_writable.p9k similarity index 84% rename from segments/core/dir_writable.p9k rename to segments/dir_writable.p9k index bb16a19fd..bdee0fa00 100644 --- a/segments/core/dir_writable.p9k +++ b/segments/dir_writable.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' +registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ################################################################ # @description @@ -27,6 +27,6 @@ register_icon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AW ## prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then - serialize_segment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' + serializeSegment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' fi } diff --git a/segments/core/disk_usage.p9k b/segments/disk_usage.p9k similarity index 70% rename from segments/core/disk_usage.p9k rename to segments/disk_usage.p9k index ccc0694bb..bb2c5e34f 100644 --- a/segments/core/disk_usage.p9k +++ b/segments/disk_usage.p9k @@ -14,12 +14,12 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' +registerIcon "DISK_ICON" $'hdd ' $'\uE1AE ' $'\uF0A0 ' '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' $'\uF0A0' -set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 -set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 +setDefault P9K_DISK_USAGE_ONLY_WARNING false +setDefault P9K_DISK_USAGE_WARNING_LEVEL 90 +setDefault P9K_DISK_USAGE_CRITICAL_LEVEL 95 ################################################################ # @description # Display information about the usage level of current partition. @@ -46,13 +46,13 @@ prompt_disk_usage() { local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then + if [ "$disk_usage" -ge "$P9K_DISK_USAGE_WARNING_LEVEL" ]; then current_state='warning' - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then + if [ "$disk_usage" -ge "$P9K_DISK_USAGE_CRITICAL_LEVEL" ]; then current_state='critical' fi else - if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then + if [[ "$P9K_DISK_USAGE_ONLY_WARNING" == true ]]; then current_state='' return fi @@ -63,6 +63,6 @@ prompt_disk_usage() { # Draw the prompt_segment if [[ -n $disk_usage ]]; then - serialize_segment "$0" "${(U)current_state}" $1 "$2" $3 "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' + serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' fi } diff --git a/segments/developer/docker_machine.p9k b/segments/docker_machine.p9k similarity index 83% rename from segments/developer/docker_machine.p9k rename to segments/docker_machine.p9k index 16fb74973..9ee5d7d96 100644 --- a/segments/developer/docker_machine.p9k +++ b/segments/docker_machine.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' +registerIcon "SERVER_ICON" '' $'\uE895' $'\uF233' '\u'$CODEPOINT_OF_AWESOME_SERVER $'\uF0AE' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_docker_machine() { local docker_machine="$DOCKER_MACHINE_NAME" if [[ -n "$docker_machine" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' + serializeSegment "$0" "" $1 "$2" $3 "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' fi } diff --git a/segments/other/dropbox.p9k b/segments/dropbox.p9k similarity index 86% rename from segments/other/dropbox.p9k rename to segments/dropbox.p9k index e37d58508..5bb30c06e 100644 --- a/segments/other/dropbox.p9k +++ b/segments/dropbox.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' +registerIcon "DROPBOX_ICON" 'Dropbox' $'\UF16B' $'\UF16B' '\u'$CODEPOINT_OF_AWESOME_DROPBOX $'\UF16B' ################################################################ # @description @@ -36,7 +36,7 @@ prompt_dropbox() { dropbox_status="" fi - serialize_segment "$0" "" $1 "$2" $3 "white" "blue" "$dropbox_status" "DROPBOX_ICON" + serializeSegment "$0" "" $1 "$2" $3 "white" "blue" "$dropbox_status" "DROPBOX_ICON" fi } diff --git a/segments/developer/go_version.p9k b/segments/go_version.p9k similarity index 88% rename from segments/developer/go_version.p9k rename to segments/go_version.p9k index aeffb2cf6..a87b14bdd 100644 --- a/segments/developer/go_version.p9k +++ b/segments/go_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  -register_icon "GO_ICON" 'Go' '' '' '' $'\uE626' +registerIcon "GO_ICON" 'Go' '' '' '' $'\uE626' ################################################################ # @description @@ -32,6 +32,6 @@ prompt_go_version() { go_path=$(go env GOPATH 2>/dev/null) if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "green" "grey93" "$go_version" "GO_ICON" + serializeSegment "$0" "" $1 "$2" $3 "green" "grey93" "$go_version" "GO_ICON" fi } diff --git a/segments/core/history.p9k b/segments/history.p9k similarity index 84% rename from segments/core/history.p9k rename to segments/history.p9k index 7a2839e7a..416639d68 100644 --- a/segments/core/history.p9k +++ b/segments/history.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    -register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' +registerIcon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' ################################################################ # @description @@ -26,5 +26,5 @@ register_icon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' # $3 boolean Whether the segment should be joined ## prompt_history() { - serialize_segment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' + serializeSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' } diff --git a/segments/core/host.p9k b/segments/host.p9k similarity index 74% rename from segments/core/host.p9k rename to segments/host.p9k index e5c4eb370..129741cf3 100644 --- a/segments/core/host.p9k +++ b/segments/host.p9k @@ -14,11 +14,11 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  -register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' +registerIcon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' #    -register_icon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' +registerIcon "HOST_ICON" '' '' $'\uF67C' $'\uF67C' $'\uF67C' -set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +setDefault P9K_HOST_TEMPLATE "%m" ################################################################ # @description # Display information about the Host - machine (where am I). @@ -34,7 +34,7 @@ prompt_host() { if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then host_state=( "STATE" "REMOTE" - "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "CONTENT" "${P9K_HOST_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "SSH_ICON" @@ -42,11 +42,11 @@ prompt_host() { else host_state=( "STATE" "LOCAL" - "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "CONTENT" "${P9K_HOST_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "HOST_ICON" ) fi - serialize_segment "$0" "${(U)host_state[STATE]}" $1 "$2" $3 "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" + serializeSegment "$0" "${(U)host_state[STATE]}" $1 "$2" $3 "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" } diff --git a/segments/other/icons_test.p9k b/segments/icons_test.p9k similarity index 90% rename from segments/other/icons_test.p9k rename to segments/icons_test.p9k index 61bdeffc6..add8f4a8f 100644 --- a/segments/other/icons_test.p9k +++ b/segments/icons_test.p9k @@ -24,6 +24,6 @@ prompt_icons_test() { # the next color has enough contrast to read. local random_color=$((RANDOM % 8)) local next_color=$((random_color+1)) - serialize_segment "$0" "" $1 "$2" $3 "$random_color" "$next_color" "$key" "$key" + serializeSegment "$0" "" $1 "$2" $3 "$random_color" "$next_color" "$key" "$key" done } diff --git a/segments/core/ip.p9k b/segments/ip.p9k similarity index 79% rename from segments/core/ip.p9k rename to segments/ip.p9k index 4f4099729..b1886bd1d 100644 --- a/segments/core/ip.p9k +++ b/segments/ip.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' +registerIcon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWESOME_RSS $'\uF1EB' ################################################################ # @description @@ -27,9 +27,9 @@ register_icon "NETWORK_ICON" 'IP' $'\uE1AD' $'\uF09E' '\u'$CODEPOINT_OF_AWES ## prompt_ip() { if [[ "$OS" == "OSX" ]]; then - if defined POWERLEVEL9K_IP_INTERFACE; then + if defined P9K_IP_INTERFACE; then # Get the IP address of the specified interface. - ip=$(ipconfig getifaddr "$POWERLEVEL9K_IP_INTERFACE") + ip=$(ipconfig getifaddr "$P9K_IP_INTERFACE") else local interfaces callback # Get network interface names ordered by service precedence. @@ -39,9 +39,9 @@ prompt_ip() { ip=$(getRelevantItem "$interfaces" "$callback") fi else - if defined POWERLEVEL9K_IP_INTERFACE; then + if defined P9K_IP_INTERFACE; then # Get the IP address of the specified interface. - ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") + ip=$(ip -4 a show "$P9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") else local interfaces callback # Get all network interface names that are up @@ -52,5 +52,5 @@ prompt_ip() { fi fi - serialize_segment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' + serializeSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' } diff --git a/segments/developer/java_version.p9k b/segments/java_version.p9k similarity index 86% rename from segments/developer/java_version.p9k rename to segments/java_version.p9k index 6212a5b52..2c441985b 100644 --- a/segments/developer/java_version.p9k +++ b/segments/java_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ☕ ☕  -register_icon "JAVA_ICON" 'Java' '' $'\u2615' $'\u2615' $'\uE256' +registerIcon "JAVA_ICON" 'Java' '' $'\u2615' $'\u2615' $'\uE256' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_java_version() { local java_version java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) if [[ -n "$java_version" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "red" "white" "${java_version}" 'JAVA_ICON' + serializeSegment "$0" "" $1 "$2" $3 "red" "white" "${java_version}" 'JAVA_ICON' fi } diff --git a/segments/developer/kubecontext.p9k b/segments/kubecontext.p9k similarity index 89% rename from segments/developer/kubecontext.p9k rename to segments/kubecontext.p9k index df8ab73a2..61edf5b46 100644 --- a/segments/developer/kubecontext.p9k +++ b/segments/kubecontext.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⎈ ⎈ ⎈ ⎈ ⎈ -register_icon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' +registerIcon "KUBERNETES_ICON" $'\U2388' $'\U2388' $'\U2388' $'\U2388' $'\U2388' ################################################################ # @description @@ -46,6 +46,6 @@ prompt_kubecontext() { k8s_final_text="$cur_ctx/$cur_namespace" fi - serialize_segment "$0" "" $1 "$2" $3 "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + serializeSegment "$0" "" $1 "$2" $3 "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" fi } diff --git a/segments/core/load.p9k b/segments/load.p9k similarity index 85% rename from segments/core/load.p9k rename to segments/load.p9k index 7ba055330..f31d5d0a5 100644 --- a/segments/core/load.p9k +++ b/segments/load.p9k @@ -14,9 +14,9 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' +registerIcon "LOAD_ICON" 'L' $'\uE190 ' $'\uF080 ' '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' $'\uF080 ' -set_default POWERLEVEL9K_LOAD_WHICH 5 +setDefault P9K_LOAD_WHICH 5 ################################################################ # @description # Display the current load. @@ -40,7 +40,7 @@ prompt_load() { 'normal' 'green' ) - case "$POWERLEVEL9K_LOAD_WHICH" in + case "$P9K_LOAD_WHICH" in 1) load_select=1 ;; @@ -77,5 +77,5 @@ prompt_load() { current_state="normal" fi - serialize_segment "$0" "${current_state}" $1 "$2" $3 "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' + serializeSegment "$0" "${current_state}" $1 "$2" $3 "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' } diff --git a/segments/core/newline.p9k b/segments/newline.p9k similarity index 70% rename from segments/core/newline.p9k rename to segments/newline.p9k index 8570314da..2962859e9 100644 --- a/segments/core/newline.p9k +++ b/segments/newline.p9k @@ -22,14 +22,14 @@ prompt_newline() { local lws newline [[ "$1" == "right" ]] && return newline=$'\n' - lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS - if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then - newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + lws=$P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$P9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(printIcon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" fi - POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= - "$1_prompt_segment" \ + P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + "$1PromptSegment" \ "$0" \ "$2" \ "NONE" "NONE" "${newline}" - POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws + P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws } diff --git a/segments/developer/node_env.p9k b/segments/node_env.p9k similarity index 86% rename from segments/developer/node_env.p9k rename to segments/node_env.p9k index 0e74d4eed..9a35bb742 100644 --- a/segments/developer/node_env.p9k +++ b/segments/node_env.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  -register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +registerIcon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_node_env() { local node_env_path="$NODE_VIRTUAL_ENV" if [[ -n "$node_env_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then local info="$(node -v)[$(basename "$node_env_path")]" - serialize_segment "$0" "" $1 "$2" $3 "black" "green" "$info" 'NODE_ICON' + serializeSegment "$0" "" $1 "$2" $3 "black" "green" "$info" 'NODE_ICON' fi } diff --git a/segments/developer/node_version.p9k b/segments/node_version.p9k similarity index 84% rename from segments/developer/node_version.p9k rename to segments/node_version.p9k index 703a01226..0011a7fbd 100644 --- a/segments/developer/node_version.p9k +++ b/segments/node_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  -register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +registerIcon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # @description @@ -29,5 +29,5 @@ prompt_node_version() { local node_version=$(node -v 2>/dev/null) [[ -z "${node_version}" ]] && return - serialize_segment "$0" "" $1 "$2" $3 "green" "white" "${node_version:1}" 'NODE_ICON' + serializeSegment "$0" "" $1 "$2" $3 "green" "white" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/developer/nvm.p9k b/segments/nvm.p9k similarity index 87% rename from segments/developer/nvm.p9k rename to segments/nvm.p9k index 2c2422d16..c4783496e 100644 --- a/segments/developer/nvm.p9k +++ b/segments/nvm.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⬢ ⬢ ⬢ ⬢  -register_icon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' +registerIcon "NODE_ICON" $'\u2B22' $'\u2B22' $'\u2B22' $'\u2B22' $'\uE617 ' ################################################################ # @description @@ -38,5 +38,5 @@ prompt_nvm() { nvm_default=$(nvm_version default) [[ "$node_version" =~ "$nvm_default" ]] && return - serialize_segment "$0" "" $1 "$2" $3 "magenta" "black" "${node_version:1}" 'NODE_ICON' + serializeSegment "$0" "" $1 "$2" $3 "magenta" "black" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/other/openfoam.p9k b/segments/openfoam.p9k similarity index 78% rename from segments/other/openfoam.p9k rename to segments/openfoam.p9k index c79079c78..ede0019bc 100644 --- a/segments/other/openfoam.p9k +++ b/segments/openfoam.p9k @@ -22,8 +22,8 @@ prompt_openfoam() { local wm_project_version="$WM_PROJECT_VERSION" local wm_fork="$WM_FORK" if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then - serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then - serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" fi } diff --git a/segments/core/os_icon.p9k b/segments/os_icon.p9k similarity index 68% rename from segments/core/os_icon.p9k rename to segments/os_icon.p9k index 607e0b996..d7833231c 100644 --- a/segments/core/os_icon.p9k +++ b/segments/os_icon.p9k @@ -16,17 +16,17 @@ case "$OS" in "macOS") #     - register_icon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' + registerIcon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' OS_ICON='APPLE_ICON' ;; "Windows") #     - register_icon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' + registerIcon "WINDOWS_ICON" 'WIN' $'\uE26F' $'\uF17A' $'\uF17A' $'\uF17A' OS_ICON='WINDOWS_ICON' ;; "BSD") # 😈 😈 😈  - register_icon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' + registerIcon "FREEBSD_ICON" 'BSD' $'\U1F608 ' $'\U1F608 ' $'\U1F608 ' $'\UF30E ' OS_ICON='FREEBSD_ICON' ;; # OpenBSD) @@ -39,84 +39,84 @@ case "$OS" in case "$OS_ID" in "arch") #  - register_icon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' + registerIcon "LINUX_ARCH_ICON" 'Arc' 'Arc' 'Arc' 'Arc' $'\uF300' OS_ICON='LINUX_ARCH_ICON' ;; "debian") #  - register_icon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' + registerIcon "LINUX_DEBIAN_ICON" 'Deb' 'Deb' 'Deb' 'Deb' $'\uF302' OS_ICON='LINUX_DEBIAN_ICON' ;; "ubuntu") #  - register_icon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' + registerIcon "LINUX_UBUNTU_ICON" 'Ubu' 'Ubu' 'Ubu' 'Ubu' $'\uF30C' OS_ICON='LINUX_UBUNTU_ICON' ;; "elementary") #  - register_icon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' + registerIcon "LINUX_ELEMENTARY_ICON" 'Elm' 'Elm' 'Elm' 'Elm' $'\uF311' OS_ICON='LINUX_ELEMENTARY_ICON' ;; "fedora") #  - register_icon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' + registerIcon "LINUX_FEDORA_ICON" 'Fed' 'Fed' 'Fed' 'Fed' $'\uF303' OS_ICON='LINUX_FEDORA_ICON' ;; "coreos") #  - register_icon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' + registerIcon "LINUX_COREOS_ICON" 'Cor' 'Cor' 'Cor' 'Cor' $'\uF30F' OS_ICON='LINUX_COREOS_ICON' ;; "gentoo") #  - register_icon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' + registerIcon "LINUX_GENTOO_ICON" 'Gen' 'Gen' 'Gen' 'Gen' $'\uF310' OS_ICON='LINUX_GENTOO_ICON' ;; "mageia") #  - register_icon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' + registerIcon "LINUX_MAGEIA_ICON" 'Mag' 'Mag' 'Mag' 'Mag' $'\uF306' OS_ICON='LINUX_MAGEIA_ICON' ;; "centos") #  - register_icon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' + registerIcon "LINUX_CENTOS_ICON" 'Cen' 'Cen' 'Cen' 'Cen' $'\uF301' OS_ICON='LINUX_CENTOS_ICON' ;; "opensuse"|"tumbleweed") #  - register_icon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' + registerIcon "LINUX_OPENSUSE_ICON" 'OSu' 'OSu' 'OSu' 'OSu' $'\uF308' OS_ICON='LINUX_OPENSUSE_ICON' ;; "sabayon") #  - register_icon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' + registerIcon "LINUX_SABAYON_ICON" 'Sab' 'Sab' 'Sab' 'Sab' $'\uF313' OS_ICON='LINUX_SABAYON_ICON' ;; "slackware") #  - register_icon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' + registerIcon "LINUX_SLACKWARE_ICON" 'Sla' 'Sla' 'Sla' 'Sla' $'\uF30A' OS_ICON='LINUX_SLACKWARE_ICON' ;; "linuxmint") #  - register_icon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' + registerIcon "LINUX_MINT_ICON" 'LMi' 'LMi' 'LMi' 'LMi' $'\uF304' OS_ICON='LINUX_MINT_ICON' ;; *) #     - register_icon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' + registerIcon "LINUX_ICON" 'Lx' $'\uE271' $'\uF17C' '\u'$CODEPOINT_OF_AWESOME_LINUX $'\uF17C' OS_ICON='LINUX_ICON' ;; esac ;; "Android") #     - register_icon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' + registerIcon "ANDROID_ICON" 'And' $'\uE270' $'\uE17B' $'\uF17B' $'\uF17B' OS_ICON='ANDROID_ICON' ;; "Solaris") # 🌞    - register_icon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' + registerIcon "SUNOS_ICON" 'Sun' $'\U1F31E ' $'\uF185 ' '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' $'\uF185 ' OS_ICON='SUNOS_ICON' ;; *) @@ -139,5 +139,5 @@ esac # otherwise just uses the Tux icon. ## prompt_os_icon() { - serialize_segment "$0" "" $1 "$2" $3 "black" "white" $(print_icon "$OS_ICON") + serializeSegment "$0" "" $1 "$2" $3 "black" "white" $(printIcon "$OS_ICON") } diff --git a/segments/developer/php_version.p9k b/segments/php_version.p9k similarity index 85% rename from segments/developer/php_version.p9k rename to segments/php_version.p9k index 01b37a7de..375c2e31c 100644 --- a/segments/developer/php_version.p9k +++ b/segments/php_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "PHP_ICON" 'PHP' $'\uF457' $'\uF457' $'\uF457' $'\uE73D' +registerIcon "PHP_ICON" 'PHP' $'\uF457' $'\uF457' $'\uF457' $'\uE73D' ################################################################ # @description @@ -30,6 +30,6 @@ prompt_php_version() { php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") if [[ -n "$php_version" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "${php_version}" 'PHP_ICON' + serializeSegment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "${php_version}" 'PHP_ICON' fi } diff --git a/segments/core/public_ip.p9k b/segments/public_ip.p9k similarity index 54% rename from segments/core/public_ip.p9k rename to segments/public_ip.p9k index 38386454f..ffc88508e 100644 --- a/segments/core/public_ip.p9k +++ b/segments/public_ip.p9k @@ -14,9 +14,9 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   -register_icon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' +registerIcon "PUBLIC_IP_ICON" '' '' '' '\u'$CODEPOINT_OF_AWESOME_GLOBE $'\UF0AC' #    -register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\uF023' +registerIcon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\uF023' ################################################################ # Public IP segment @@ -26,44 +26,44 @@ register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME # * $3 Joined: bool - If the segment should be joined prompt_public_ip() { # set default values for segment - set_default POWERLEVEL9K_PUBLIC_IP_TIMEOUT "300" - set_default POWERLEVEL9K_PUBLIC_IP_NONE "" - set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" - set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" - defined POWERLEVEL9K_PUBLIC_IP_METHODS || POWERLEVEL9K_PUBLIC_IP_METHODS=(dig curl wget) + setDefault P9K_PUBLIC_IP_TIMEOUT "300" + setDefault P9K_PUBLIC_IP_NONE "" + setDefault P9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" + setDefault P9K_PUBLIC_IP_HOST "http://ident.me" + defined P9K_PUBLIC_IP_METHODS || P9K_PUBLIC_IP_METHODS=(dig curl wget) # Do we need a fresh IP? local refresh_ip=false - if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if [[ -f $P9K_PUBLIC_IP_FILE ]]; then typeset -i timediff # if saved IP is more than if [[ "$OS" == "OSX" ]]; then - timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + timediff=$(($(date +%s) - $(stat -f "%m" $P9K_PUBLIC_IP_FILE))) else - timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + timediff=$(($(date +%s) - $(date -r $P9K_PUBLIC_IP_FILE +%s))) fi - [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true + [[ $timediff -gt $P9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true - [[ -n $POWERLEVEL9K_PUBLIC_IP_NONE ]] && [[ $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true + [[ -z $(cat $P9K_PUBLIC_IP_FILE) ]] && refresh_ip=true + [[ -n $P9K_PUBLIC_IP_NONE ]] && [[ $(cat $P9K_PUBLIC_IP_FILE) =~ "$P9K_PUBLIC_IP_NONE" ]] && refresh_ip=true else - touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true + touch $P9K_PUBLIC_IP_FILE && refresh_ip=true fi # grab a fresh IP if needed local fresh_ip - if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - for method in "${POWERLEVEL9K_PUBLIC_IP_METHODS[@]}"; do + if [[ $refresh_ip =~ true && -w $P9K_PUBLIC_IP_FILE ]]; then + for method in "${P9K_PUBLIC_IP_METHODS[@]}"; do case $method in 'dig') fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip ;; 'curl') - fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fresh_ip="$(curl --max-time 10 -w '\n' "$P9K_PUBLIC_IP_HOST" 2> /dev/null)" ;; 'wget') - fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fresh_ip="$(wget -T 10 -qO- "$P9K_PUBLIC_IP_HOST" 2> /dev/null)" ;; esac # If we found a fresh IP, break loop. @@ -77,23 +77,23 @@ prompt_public_ip() { # is truncated to zero length if it exists, even if CLOBBER is unset. # If the file already exists, and a simple `>` redirection and CLOBBER # unset, ZSH will produce an error. - [[ -n "${fresh_ip}" ]] && echo $fresh_ip >! $POWERLEVEL9K_PUBLIC_IP_FILE || echo $POWERLEVEL9K_PUBLIC_IP_NONE >! $POWERLEVEL9K_PUBLIC_IP_FILE + [[ -n "${fresh_ip}" ]] && echo $fresh_ip >! $P9K_PUBLIC_IP_FILE || echo $P9K_PUBLIC_IP_NONE >! $P9K_PUBLIC_IP_FILE fi # read public IP saved to tmp file - local public_ip="$(cat $POWERLEVEL9K_PUBLIC_IP_FILE)" + local public_ip="$(cat $P9K_PUBLIC_IP_FILE)" # Draw the prompt segment if [[ -n $public_ip ]]; then icon='PUBLIC_IP_ICON' # Check VPN is on if VPN interface is set - if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then - for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) + if [[ -n $P9K_PUBLIC_IP_VPN_INTERFACE ]]; then + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$P9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) do icon='VPN_ICON' break done fi - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" fi } diff --git a/segments/developer/pyenv.p9k b/segments/pyenv.p9k similarity index 85% rename from segments/developer/pyenv.p9k rename to segments/pyenv.p9k index 00dc38024..0c90f9ce6 100644 --- a/segments/developer/pyenv.p9k +++ b/segments/pyenv.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  -register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +registerIcon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # @description @@ -30,6 +30,6 @@ register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ## prompt_pyenv() { if [[ -n "$PYENV_VERSION" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' fi } diff --git a/segments/core/ram.p9k b/segments/ram.p9k similarity index 86% rename from segments/core/ram.p9k rename to segments/ram.p9k index 0ac460510..8446eedca 100644 --- a/segments/core/ram.p9k +++ b/segments/ram.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' +registerIcon "RAM_ICON" 'RAM' $'\uE1E2 ' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF0E4' ################################################################ # @description @@ -44,5 +44,5 @@ prompt_ram() { fi fi - serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' + serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } diff --git a/segments/developer/rbenv.p9k b/segments/rbenv.p9k similarity index 74% rename from segments/developer/rbenv.p9k rename to segments/rbenv.p9k index ea1953cfa..00d2166a8 100644 --- a/segments/developer/rbenv.p9k +++ b/segments/rbenv.p9k @@ -14,9 +14,9 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +registerIcon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' -set_default POWERLEVEL9K_RBENV_ALWAYS false +setDefault P9K_RBENV_ALWAYS false ################################################################ # @description # Display the current rbenv information. @@ -32,9 +32,9 @@ prompt_rbenv() { local rbenv_global="$(rbenv global)" # Don't show anything if the current Ruby is the same as the global Ruby - # unless `POWERLEVEL9K_RBENV_ALWAYS` is set. - if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then - serialize_segment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + # unless `P9K_RBENV_ALWAYS` is set. + if [[ $P9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then + serializeSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi fi } diff --git a/segments/core/root_indicator.p9k b/segments/root_indicator.p9k similarity index 83% rename from segments/core/root_indicator.p9k rename to segments/root_indicator.p9k index cfe6df030..badd39042 100644 --- a/segments/core/root_indicator.p9k +++ b/segments/root_indicator.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⚡     -register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' +registerIcon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' ################################################################ # @description @@ -27,6 +27,6 @@ register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OC ## prompt_root_indicator() { if [[ "$UID" -eq 0 ]]; then - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' fi } diff --git a/segments/developer/rspec_stats.p9k b/segments/rspec_stats.p9k similarity index 93% rename from segments/developer/rspec_stats.p9k rename to segments/rspec_stats.p9k index b78cdd7c8..eda3f33a7 100644 --- a/segments/developer/rspec_stats.p9k +++ b/segments/rspec_stats.p9k @@ -10,7 +10,7 @@ ## # Source test stats script & icons -source $p9k_directory/segments/developer/test_stats.p9k +source $p9kDirectory/segments/developer/test_stats.p9k ############################################################### # @description diff --git a/segments/developer/rust_version.p9k b/segments/rust_version.p9k similarity index 85% rename from segments/developer/rust_version.p9k rename to segments/rust_version.p9k index cb7b6f639..5a7623565 100644 --- a/segments/developer/rust_version.p9k +++ b/segments/rust_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #    -register_icon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' +registerIcon "RUST_ICON" '' '' $'\uE6A8' $'\uE6A8' $'\uE7A8 ' ################################################################ # @description @@ -30,6 +30,6 @@ prompt_rust_version() { rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') if [[ -n "$rust_version" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + serializeSegment "$0" "" $1 "$2" $3 "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' fi } diff --git a/segments/developer/rvm.p9k b/segments/rvm.p9k similarity index 82% rename from segments/developer/rvm.p9k rename to segments/rvm.p9k index a807f3c39..9de67c2c9 100644 --- a/segments/developer/rvm.p9k +++ b/segments/rvm.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' +registerIcon "RUBY_ICON" '' $'\uE847 ' $'\uF219 ' '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' $'\uF219 ' ################################################################ # @description @@ -29,6 +29,6 @@ prompt_rvm() { local version_and_gemset=${rvm_env_string/ruby-} if [[ -n "$version_and_gemset" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + serializeSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' fi } diff --git a/segments/core/ssh.p9k b/segments/ssh.p9k similarity index 85% rename from segments/core/ssh.p9k rename to segments/ssh.p9k index 3c3773494..5b9c7d585 100644 --- a/segments/core/ssh.p9k +++ b/segments/ssh.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #  -register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' +registerIcon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' ################################################################ # @description @@ -27,6 +27,6 @@ register_icon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' ## prompt_ssh() { if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' fi } diff --git a/segments/core/status.p9k b/segments/status.p9k similarity index 50% rename from segments/core/status.p9k rename to segments/status.p9k index c342a7b18..d02fec693 100644 --- a/segments/core/status.p9k +++ b/segments/status.p9k @@ -14,23 +14,30 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ↵ ↵ ↵ ↵ ↵ -register_icon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' +registerIcon "CARRIAGE_RETURN_ICON" $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' $'\u21B5' # ✔ ✔ ✔   -register_icon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' +registerIcon "OK_ICON" $'\u2714' $'\u2714' $'\u2714' '\u'$CODEPOINT_OF_AWESOME_CHECK $'\uF00C' # ✘ ✘ ✘   -register_icon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' +registerIcon "FAIL_ICON" $'\u2718' $'\u2718' $'\u2718' '\u'$CODEPOINT_OF_AWESOME_TIMES $'\uF00D' -set_default POWERLEVEL9K_STATUS_CROSS false -set_default POWERLEVEL9K_STATUS_OK true -set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true -set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +setDefault P9K_STATUS_CROSS false +setDefault P9K_STATUS_OK true +setDefault P9K_STATUS_SHOW_PIPESTATUS true +setDefault P9K_STATUS_HIDE_SIGNAME false # old options, retro compatibility -set_default POWERLEVEL9K_STATUS_VERBOSE true -set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false +setDefault P9K_STATUS_VERBOSE true +setDefault P9K_STATUS_OK_IN_NON_VERBOSE false +################################################################ +# @description +# Returns an exit code or status text. +## +# @args +# $1 integer Exit code +## exit_code_or_status() { local ec=$1 - if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + if [[ "$P9K_STATUS_HIDE_SIGNAME" = true ]]; then echo "$ec" elif (( ec <= 128 )); then echo "$ec" @@ -52,18 +59,21 @@ exit_code_or_status() { # $3 boolean Whether the segment should be joined ## prompt_status() { - local ec_text - local ec_sum + local ec_text ec_sum local ec - if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=$(exit_code_or_status "${RETVALS[1]}") - ec_sum=${RETVALS[1]} - - for ec in "${(@)RETVALS[2,-1]}"; do - ec_text="${ec_text}|$(exit_code_or_status "$ec")" - ec_sum=$(( $ec_sum + $ec )) - done + if [[ $P9K_STATUS_SHOW_PIPESTATUS == true ]]; then + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|$(exit_code_or_status "$ec")" + ec_sum=$(( $ec_sum + $ec )) + done + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi else # We use RETVAL instead of the right-most RETVALS item because # PIPE_FAIL may be set. @@ -72,12 +82,12 @@ prompt_status() { fi if (( ec_sum > 0 )); then - if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - serialize_segment "$0" "ERROR" $1 "$2" $3 "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + if [[ "$P9K_STATUS_CROSS" == false && "$P9K_STATUS_VERBOSE" == true ]]; then + serializeSegment "$0" "ERROR" $1 "$2" $3 "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' else - serialize_segment "$0" "ERROR" $1 "$2" $3 "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + serializeSegment "$0" "ERROR" $1 "$2" $3 "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi - elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then - serialize_segment "$0" "OK" $1 "$2" $3 "$DEFAULT_COLOR" "green" "" 'OK_ICON' + elif [[ "$P9K_STATUS_OK" == true ]] && [[ "$P9K_STATUS_VERBOSE" == true || "$P9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + serializeSegment "$0" "OK" $1 "$2" $3 "$DEFAULT_COLOR" "green" "" 'OK_ICON' fi } diff --git a/segments/core/swap.p9k b/segments/swap.p9k similarity index 86% rename from segments/core/swap.p9k rename to segments/swap.p9k index b73fbfb30..6c6e224a2 100644 --- a/segments/core/swap.p9k +++ b/segments/swap.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' +registerIcon "SWAP_ICON" 'SWP' $'\uE87D' $'\uF0E4' '\u'$CODEPOINT_OF_AWESOME_DASHBOARD $'\uF464' ################################################################ # @description @@ -46,5 +46,5 @@ prompt_swap() { base='K' fi - serialize_segment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' + serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' } diff --git a/segments/developer/swift_version.p9k b/segments/swift_version.p9k similarity index 87% rename from segments/developer/swift_version.p9k rename to segments/swift_version.p9k index eb68c3080..237abb2d5 100644 --- a/segments/developer/swift_version.p9k +++ b/segments/swift_version.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   -register_icon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' +registerIcon "SWIFT_ICON" 'Swift' '' '' $'\uE655' $'\uE755' ################################################################ # @description @@ -30,7 +30,7 @@ prompt_swift_version() { local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) [[ -z "${swift_version}" ]] && return - serialize_segment "$0" "" $1 "$2" $3 "magenta" "white" "${swift_version}" 'SWIFT_ICON' + serializeSegment "$0" "" $1 "$2" $3 "magenta" "white" "${swift_version}" 'SWIFT_ICON' } # diff --git a/segments/developer/symfony2_tests.p9k b/segments/symfony2_tests.p9k similarity index 94% rename from segments/developer/symfony2_tests.p9k rename to segments/symfony2_tests.p9k index b5af15be8..73331ac6a 100644 --- a/segments/developer/symfony2_tests.p9k +++ b/segments/symfony2_tests.p9k @@ -10,7 +10,7 @@ ## # Source test stats script & icons -source $p9k_directory/segments/developer/test_stats.p9k +source $p9kDirectory/segments/developer/test_stats.p9k ################################################################ # @description diff --git a/segments/developer/symfony2_version.p9k b/segments/symfony2_version.p9k similarity index 86% rename from segments/developer/symfony2_version.p9k rename to segments/symfony2_version.p9k index 5ff58c900..99197bf33 100644 --- a/segments/developer/symfony2_version.p9k +++ b/segments/symfony2_version.p9k @@ -15,7 +15,7 @@ # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # Register icons #  -register_icon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' +registerIcon "SYMFONY_ICON" 'SF' 'SF' 'SF' 'SF' $'\uE757' ################################################################ # @description @@ -30,6 +30,6 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - serialize_segment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' + serializeSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } diff --git a/segments/developer/test_stats.p9k b/segments/test_stats.p9k similarity index 74% rename from segments/developer/test_stats.p9k rename to segments/test_stats.p9k index 4072b8551..4d659bed6 100644 --- a/segments/developer/test_stats.p9k +++ b/segments/test_stats.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' +registerIcon "TEST_ICON" '' $'\uE891' $'\uF291' '\u'$CODEPOINT_OF_AWESOME_BUG $'\uF188' ################################################################ # @description @@ -41,7 +41,7 @@ build_test_stats() { typeset -F 2 ratio local ratio=$(( (tests_amount/code_amount) * 100 )) - (( ratio >= 75 )) && serialize_segment "$1" "GOOD" "$2" $3 $4 "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio >= 50 && ratio < 75 )) && serialize_segment "$1" "AVG" "$2" $3 $4 "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio < 50 )) && serialize_segment "$1" "BAD" "$2" $3 $4 "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 75 )) && serializeSegment "$1" "GOOD" "$2" $3 $4 "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && serializeSegment "$1" "AVG" "$2" $3 $4 "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && serializeSegment "$1" "BAD" "$2" $3 $4 "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" } diff --git a/segments/core/time.p9k b/segments/time.p9k similarity index 76% rename from segments/core/time.p9k rename to segments/time.p9k index 59595a11b..d61cd077d 100644 --- a/segments/core/time.p9k +++ b/segments/time.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' +registerIcon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' ################################################################ # @description @@ -26,7 +26,7 @@ register_icon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' # $3 boolean Whether the segment should be joined ## prompt_time() { - set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" + setDefault P9K_TIME_FORMAT "%D{%H:%M:%S}" - serialize_segment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" + serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_TIME_FORMAT" "TIME_ICON" } diff --git a/segments/other/todo.p9k b/segments/todo.p9k similarity index 84% rename from segments/other/todo.p9k rename to segments/todo.p9k index a0f8bc70b..51bb0bd8b 100644 --- a/segments/other/todo.p9k +++ b/segments/todo.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ☑ ☑ ☑   -register_icon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' +registerIcon "TODO_ICON" $'\u2611' $'\u2611' $'\u2611' '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O $'\uF133' ################################################################ # @description @@ -29,7 +29,7 @@ prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') if [[ "$count" = <-> ]]; then - serialize_segment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' + serializeSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' fi fi } diff --git a/segments/core/user.p9k b/segments/user.p9k similarity index 72% rename from segments/core/user.p9k rename to segments/user.p9k index 2de855a94..52b1d1771 100644 --- a/segments/core/user.p9k +++ b/segments/user.p9k @@ -14,13 +14,13 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # ⚡     -register_icon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' +registerIcon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCTICONS_ZAP $'\uE614 ' #      -register_icon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' +registerIcon "SUDO_ICON" $'\uE0A2' $'\uF09C' $'\uF09C' '\u'$CODEPOINT_OF_AWESOME_UNLOCK $'\uF09C' #    -register_icon "USER_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' +registerIcon "USER_ICON" '' '' $'\uF2C0' $'\uF2C0' $'\uF2C0' -set_default POWERLEVEL9K_USER_TEMPLATE "%n" +setDefault P9K_USER_TEMPLATE "%n" ################################################################ # @description # Display information about the user (Who am I). @@ -35,11 +35,11 @@ set_default POWERLEVEL9K_USER_TEMPLATE "%n" prompt_user() { local current_state="DEFAULT" typeset -AH user_state - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then + if [[ "$P9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then if [[ $(print -P "%#") == '#' ]]; then user_state=( "STATE" "ROOT" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "CONTENT" "${P9K_USER_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" @@ -47,7 +47,7 @@ prompt_user() { elif sudo -n true 2>/dev/null; then user_state=( "STATE" "SUDO" - "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "CONTENT" "${P9K_USER_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "SUDO_ICON" @@ -61,6 +61,6 @@ prompt_user() { "VISUAL_IDENTIFIER" "USER_ICON" ) fi - serialize_segment "$0" ${(U)user_state[STATE]} $1 "$2" $3 "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + serializeSegment "$0" ${(U)user_state[STATE]} $1 "$2" $3 "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" fi } diff --git a/segments/developer/vcs.p9k b/segments/vcs.p9k similarity index 57% rename from segments/developer/vcs.p9k rename to segments/vcs.p9k index b0604e6ca..e7d4dab36 100644 --- a/segments/developer/vcs.p9k +++ b/segments/vcs.p9k @@ -14,61 +14,61 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #     -register_icon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' +registerIcon "VCS_UNTRACKED_ICON" '?' $'\uE16C' $'\uF059' '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE $'\uF059' # ●     -register_icon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' +registerIcon "VCS_UNSTAGED_ICON" $'\u25CF' $'\uE17C' $'\uF06A' '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE $'\uF06A' # ✚     -register_icon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' +registerIcon "VCS_STAGED_ICON" $'\u271A' $'\uE168' $'\uF055' '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE $'\uF055' # ⍟     -register_icon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' +registerIcon "VCS_STASH_ICON" $'\u235F' $'\uE133 ' $'\uF01C ' '\u'$CODEPOINT_OF_AWESOME_INBOX' ' $'\uF01C ' # ↓     -register_icon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' +registerIcon "VCS_INCOMING_CHANGES_ICON" $'\u2193' $'\uE131 ' $'\uF01A ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' $'\uF01A ' # ↑     -register_icon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' +registerIcon "VCS_OUTGOING_CHANGES_ICON" $'\u2191' $'\uE132 ' $'\uF01B ' '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' $'\uF01B ' #     -register_icon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' +registerIcon "VCS_TAG_ICON" '' $'\uE817 ' $'\uF217 ' '\u'$CODEPOINT_OF_AWESOME_TAG' ' $'\uF02B ' # ☿     -register_icon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' +registerIcon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK $'\uF461 ' #     -register_icon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' +registerIcon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' -if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" != true ]]; then - if [[ $POWERLEVEL9K_MODE != 'compatible' ]]; then +if [[ "$P9K_HIDE_BRANCH_ICON" != true ]]; then + if [[ $P9K_MODE != 'compatible' ]]; then #      - register_icon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + registerIcon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' else #     - register_icon "VCS_BRANCH_ICON" "@ " $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' + registerIcon "VCS_BRANCH_ICON" "@ " $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 ' fi fi # → → →   -register_icon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' +registerIcon "VCS_REMOTE_BRANCH_ICON" $'\u2192' $'\u2192' $'\u2192' '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH $'\uE728 ' #     -register_icon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' +registerIcon "VCS_GIT_ICON" '' $'\uE20E ' $'\uF1D3 ' '\u'$CODEPOINT_OF_AWESOME_GIT' ' $'\uF1D3 ' #    -register_icon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' +registerIcon "VCS_GIT_GITHUB_ICON" '' $'\uE20E ' $'\uF113 ' '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' $'\uF113 ' #    -register_icon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' +registerIcon "VCS_GIT_BITBUCKET_ICON" '' $'\uE20E ' $'\uF171 ' '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' $'\uE703 ' #    -register_icon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' +registerIcon "VCS_GIT_GITLAB_ICON" '' $'\uE20E ' $'\uF296 ' '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' $'\uF296 ' #     -register_icon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' +registerIcon "VCS_HG_ICON" '' $'\uE1C3 ' $'\uF0C3 ' '\u'$CODEPOINT_OF_AWESOME_FLASK' ' $'\uF0C3 ' #  -register_icon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' +registerIcon "VCS_SVN_ICON" '' '(svn) ' '(svn) ' '(svn) ' $'\uE72D ' ################################################################ # Source VCS_INFO hooks / helper functions ################################################################ -source "${p9k_directory}/functions/vcs.zsh" +source "${p9kDirectory}/functions/vcs.zsh" ################################################################ # VCS segment: shows the state of your repository, if you are in a folder under # version control -set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" +setDefault P9K_VCS_ACTIONFORMAT_FOREGROUND "red" # Default: Just display the first 8 characters of our changeset-ID. -set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" +setDefault P9K_VCS_INTERNAL_HASH_LENGTH "8" ################################################################ # @description # Initializes the VCS segment by setting the required ZSH options. @@ -78,9 +78,9 @@ set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" # @note # This function is only called once. ## -powerlevel9k_vcs_init() { - if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then - POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" +p9k_vcs_init() { + if [[ -n "$P9K_CHANGESET_HASH_LENGTH" ]]; then + P9K_VCS_INTERNAL_HASH_LENGTH="$P9K_CHANGESET_HASH_LENGTH" fi # Load VCS_INFO @@ -98,8 +98,8 @@ powerlevel9k_vcs_init() { ) VCS_CHANGESET_PREFIX='' - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then - VCS_CHANGESET_PREFIX="$(print_icon 'VCS_COMMIT_ICON')%0.$POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH""i " + if [[ "$P9K_SHOW_CHANGESET" == true ]]; then + VCS_CHANGESET_PREFIX="$(printIcon 'VCS_COMMIT_ICON')%0.$P9K_VCS_INTERNAL_HASH_LENGTH""i " fi zstyle ':vcs_info:*' enable git hg svn @@ -108,20 +108,20 @@ powerlevel9k_vcs_init() { VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m" zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" - zstyle ':vcs_info:*' actionformats "%b %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + zstyle ':vcs_info:*' actionformats "%b %F{${P9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - zstyle ':vcs_info:*' stagedstr " $(print_icon 'VCS_STAGED_ICON')" - zstyle ':vcs_info:*' unstagedstr " $(print_icon 'VCS_UNSTAGED_ICON')" + zstyle ':vcs_info:*' stagedstr " $(printIcon 'VCS_STAGED_ICON')" + zstyle ':vcs_info:*' unstagedstr " $(printIcon 'VCS_UNSTAGED_ICON')" - defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) - zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS - defined POWERLEVEL9K_VCS_HG_HOOKS || POWERLEVEL9K_VCS_HG_HOOKS=(vcs-detect-changes) - zstyle ':vcs_info:hg*+set-message:*' hooks $POWERLEVEL9K_VCS_HG_HOOKS - defined POWERLEVEL9K_VCS_SVN_HOOKS || POWERLEVEL9K_VCS_SVN_HOOKS=(vcs-detect-changes svn-detect-changes) - zstyle ':vcs_info:svn*+set-message:*' hooks $POWERLEVEL9K_VCS_SVN_HOOKS + defined P9K_VCS_GIT_HOOKS || P9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) + zstyle ':vcs_info:git*+set-message:*' hooks $P9K_VCS_GIT_HOOKS + defined P9K_VCS_HG_HOOKS || P9K_VCS_HG_HOOKS=(vcs-detect-changes) + zstyle ':vcs_info:hg*+set-message:*' hooks $P9K_VCS_HG_HOOKS + defined P9K_VCS_SVN_HOOKS || P9K_VCS_SVN_HOOKS=(vcs-detect-changes svn-detect-changes) + zstyle ':vcs_info:svn*+set-message:*' hooks $P9K_VCS_SVN_HOOKS # For Hg, only show the branch name - zstyle ':vcs_info:hg*:*' branchformat "$(print_icon 'VCS_BRANCH_ICON')%b" + zstyle ':vcs_info:hg*:*' branchformat "$(printIcon 'VCS_BRANCH_ICON')%b" # The `get-revision` function must be turned on for dirty-check to work for Hg zstyle ':vcs_info:hg*:*' get-revision true zstyle ':vcs_info:hg*:*' get-bookmarks true @@ -131,9 +131,9 @@ powerlevel9k_vcs_init() { # TODO fix the %b (branch) format for svn. Using %b breaks # color-encoding of the foreground for the rest of the powerline. zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u" - zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${P9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then + if [[ "$P9K_SHOW_CHANGESET" == true ]]; then zstyle ':vcs_info:*' get-revision true fi } @@ -168,8 +168,8 @@ prompt_vcs() { current_state='clean' fi fi - serialize_segment $0 ${(U)current_state} $1 "$2" $3 "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" + serializeSegment $0 ${(U)current_state} $1 "$2" $3 "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi } -powerlevel9k_vcs_init +p9k_vcs_init diff --git a/segments/core/vi_mode.p9k b/segments/vi_mode.p9k similarity index 72% rename from segments/core/vi_mode.p9k rename to segments/vi_mode.p9k index a1775bea6..3535627ab 100644 --- a/segments/core/vi_mode.p9k +++ b/segments/vi_mode.p9k @@ -9,9 +9,9 @@ # Dominic Ritter (dritter) ## -set_default "POWERLEVEL9K_VI_INSERT_MODE_STRING" "INSERT" -set_default "POWERLEVEL9K_VI_COMMAND_MODE_STRING" "NORMAL" -set_default "POWERLEVEL9K_VI_VISUAL_MODE_STRING" "VISUAL" +setDefault "P9K_VI_INSERT_MODE_STRING" "INSERT" +setDefault "P9K_VI_COMMAND_MODE_STRING" "NORMAL" +setDefault "P9K_VI_VISUAL_MODE_STRING" "VISUAL" ############################################################### # Vi Mode: show editing mode (NORMAL|INSERT) # Parameters: @@ -45,32 +45,32 @@ prompt_vi_mode() { case "${KEYMAP}" in vicmd) current_state="NORMAL" - vi_mode="${POWERLEVEL9K_VI_COMMAND_MODE_STRING}" + vi_mode="${P9K_VI_COMMAND_MODE_STRING}" ;; vivis) current_state="VISUAL" - vi_mode="${POWERLEVEL9K_VI_VISUAL_MODE_STRING}" + vi_mode="${P9K_VI_VISUAL_MODE_STRING}" ;; main|viins|*) - if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi + if [[ -z $P9K_VI_INSERT_MODE_STRING ]]; then return; fi current_state="INSERT" - vi_mode="${POWERLEVEL9K_VI_INSERT_MODE_STRING}" + vi_mode="${P9K_VI_INSERT_MODE_STRING}" ;; esac - serialize_segment "$0" "${current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${vi_states[$current_state]}" "${vi_mode}" '' + serializeSegment "$0" "${current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${vi_states[$current_state]}" "${vi_mode}" '' } ############################################################### function rebuild_vi_mode { - case "${POWERLEVEL9K_GENERATOR}" in + case "${P9K_GENERATOR}" in # async) # if (( ${+terminfo[smkx]} )); then # printf '%s' ${terminfo[smkx]} # fi - # for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}"); do + # for index in $(get_indices_of_segment "vi_mode" "${P9K_LEFT_PROMPT_ELEMENTS}"); do # prompt_vi_mode "left" "${index}" "${1}" &! # done - # for index in $(get_indices_of_segment "vi_mode" "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}"); do + # for index in $(get_indices_of_segment "vi_mode" "${P9K_RIGHT_PROMPT_ELEMENTS}"); do # prompt_vi_mode "right" "${index}" "${1}" &! # done # ;; @@ -79,16 +79,16 @@ function rebuild_vi_mode { printf '%s' ${terminfo[smkx]} fi local element - for (( i = 1; i <= ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}; i++ )); do - element="${(L)POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[$i]}" + for (( i = 1; i <= ${#P9K_LEFT_PROMPT_ELEMENTS}; i++ )); do + element="${(L)P9K_LEFT_PROMPT_ELEMENTS[$i]}" if [[ "${element}" =~ "vi_mode" ]]; then [[ "${element[-7,-1]}" == '_joined' ]] && joined=true prompt_vi_mode "left" "${i}" "$joined" break fi done - for (( i = 1; i <= ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}; i++ )); do - element="${(L)POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[$i]}" + for (( i = 1; i <= ${#P9K_RIGHT_PROMPT_ELEMENTS}; i++ )); do + element="${(L)P9K_RIGHT_PROMPT_ELEMENTS[$i]}" if [[ "${element}" =~ "vi_mode" ]]; then [[ "${element[-7,-1]}" == '_joined' ]] && joined=true prompt_vi_mode "left" "${i}" "$joined" @@ -152,14 +152,14 @@ cursorShape() { cursor_shape_line=$CS_konsole[prefix]$CS_konsole[$1]$CS_konsole[suffix] ;; gnometerm | rxvt | termite | tmux) - if [[ $POWERLEVEL9K_CURSOR_NOBLINK ]]; then + if [[ $P9K_CURSOR_NOBLINK ]]; then cursor_shape_line=$CS_rxvt_noblink[prefix]$CS_rxvt_noblink[$1]$CS_rxvt_noblink[suffix] else cursor_shape_line=$CS_rxvt[prefix]$CS_rxvt[$1]$CS_rxvt[suffix] fi ;; xterm) - if [[ $POWERLEVEL9K_CURSOR_NOBLINK ]]; then + if [[ $P9K_CURSOR_NOBLINK ]]; then cursor_shape_line=$CS_xterm_noblink[prefix]$CS_xterm_noblink[$1]$CS_xterm_noblink[suffix] else cursor_shape_line=$CS_xterm[prefix]$CS_xterm[$1]$CS_xterm[suffix] @@ -172,18 +172,18 @@ cursorShape() { ############################################################### function zle-line-init { - case $POWERLEVEL9K_GENERATOR in + case $P9K_GENERATOR in zsh-async) rebuild_vi_mode "${KEYMAP}" ;; esac # change cursor shape - if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then + if [[ $P9K_CURSOR_SHAPE ]]; then case $KEYMAP in - vicmd) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_NORMAL};; - viins|main) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_INSERT};; - vivis) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_VISUAL};; - *) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT};; + vicmd) cursorShape ${P9K_CURSOR_SHAPE_NORMAL};; + viins|main) cursorShape ${P9K_CURSOR_SHAPE_INSERT};; + vivis) cursorShape ${P9K_CURSOR_SHAPE_VISUAL};; + *) cursorShape ${P9K_CURSOR_SHAPE_DEFAULT};; esac fi } @@ -191,14 +191,14 @@ function zle-line-init { ############################################################### function zle-line-finish { #rebuild_vi_mode "${KEYMAP}" - if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then - cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT} + if [[ $P9K_CURSOR_SHAPE ]]; then + cursorShape ${P9K_CURSOR_SHAPE_DEFAULT} fi } ############################################################### function zle-keymap-select { - case $POWERLEVEL9K_GENERATOR in + case $P9K_GENERATOR in zsh-async) rebuild_vi_mode "${KEYMAP}" break; @@ -212,12 +212,12 @@ function zle-keymap-select { ;; esac # change cursor shape - if [[ $POWERLEVEL9K_CURSOR_SHAPE ]]; then + if [[ $P9K_CURSOR_SHAPE ]]; then case $KEYMAP in - vicmd) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_NORMAL};; - viins|main) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_INSERT};; - vivis) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_VISUAL};; - *) cursorShape ${POWERLEVEL9K_CURSOR_SHAPE_DEFAULT};; + vicmd) cursorShape ${P9K_CURSOR_SHAPE_NORMAL};; + viins|main) cursorShape ${P9K_CURSOR_SHAPE_INSERT};; + vivis) cursorShape ${P9K_CURSOR_SHAPE_VISUAL};; + *) cursorShape ${P9K_CURSOR_SHAPE_DEFAULT};; esac fi } diff --git a/segments/developer/virtualenv.p9k b/segments/virtualenv.p9k similarity index 85% rename from segments/developer/virtualenv.p9k rename to segments/virtualenv.p9k index d4c7d02fc..5d0bd3c61 100644 --- a/segments/developer/virtualenv.p9k +++ b/segments/virtualenv.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont #   🐍  -register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' +registerIcon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ################################################################ # @description @@ -31,6 +31,6 @@ register_icon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - serialize_segment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' + serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' fi } diff --git a/segments/core/vpn_ip.p9k b/segments/vpn_ip.p9k similarity index 72% rename from segments/core/vpn_ip.p9k rename to segments/vpn_ip.p9k index 9cc0e61bd..b3457e27c 100644 --- a/segments/core/vpn_ip.p9k +++ b/segments/vpn_ip.p9k @@ -14,9 +14,9 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont # -register_icon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' +registerIcon "VPN_ICON" '(vpn)' '(vpn)' $'\uF023' '\u'$CODEPOINT_OF_AWESOME_LOCK '(vpn)' -set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +setDefault P9K_VPN_IP_INTERFACE "tun" ################################################################ # @description # Segment to display if the VPN is active. @@ -27,9 +27,9 @@ set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" # $3 boolean Whether the segment should be joined ## prompt_vpn_ip() { - for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$P9K_VPN_IP_INTERFACE" | cut -d":" -f1) do ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) - serialize_segment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + serializeSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' done } diff --git a/test/functions/icons.spec b/test/functions/icons.spec index c8d88644b..3ab1ebe26 100755 --- a/test/functions/icons.spec +++ b/test/functions/icons.spec @@ -12,7 +12,7 @@ function setUp() { unset LC_CTYPE # Store old P9K mode - _OLD_P9K_MODE="${POWERLEVEL9K_MODE}" + _OLD_P9K_MODE="${P9K_MODE}" } function tearDown() { @@ -20,11 +20,11 @@ function tearDown() { LC_CTYPE="${_OLD_LC_CTYPE}" # Restore old P9K mode - POWERLEVEL9K_MODE="${_OLD_P9K_MODE}" + P9K_MODE="${_OLD_P9K_MODE}" } function testLcCtypeIsSetCorrectlyInDefaultMode() { - POWERLEVEL9K_MODE="default" + P9K_MODE="default" # Load Powerlevel9k source functions/icons.zsh @@ -32,7 +32,7 @@ function testLcCtypeIsSetCorrectlyInDefaultMode() { } function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() { - POWERLEVEL9K_MODE="awesome-patched" + P9K_MODE="awesome-patched" # Load Powerlevel9k source functions/icons.zsh @@ -40,7 +40,7 @@ function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() { } function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() { - POWERLEVEL9K_MODE="awesome-fontconfig" + P9K_MODE="awesome-fontconfig" # Load Powerlevel9k source functions/icons.zsh @@ -48,7 +48,7 @@ function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() { } function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() { - POWERLEVEL9K_MODE="nerdfont-fontconfig" + P9K_MODE="nerdfont-fontconfig" # Load Powerlevel9k source functions/icons.zsh @@ -56,7 +56,7 @@ function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() { } function testLcCtypeIsSetCorrectlyInFlatMode() { - POWERLEVEL9K_MODE="flat" + P9K_MODE="flat" # Load Powerlevel9k source functions/icons.zsh @@ -64,7 +64,7 @@ function testLcCtypeIsSetCorrectlyInFlatMode() { } function testLcCtypeIsSetCorrectlyInCompatibleMode() { - POWERLEVEL9K_MODE="compatible" + P9K_MODE="compatible" # Load Powerlevel9k source functions/icons.zsh @@ -76,7 +76,7 @@ function testLcCtypeIsSetCorrectlyInCompatibleMode() { function testAllIconsAreDefinedLikeInDefaultMode() { # Always compare against this mode local _P9K_TEST_MODE="default" - POWERLEVEL9K_MODE="${_P9K_TEST_MODE}" + P9K_MODE="${_P9K_TEST_MODE}" source functions/icons.zsh # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key @@ -85,14 +85,14 @@ function testAllIconsAreDefinedLikeInDefaultMode() { _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "awesome-patched" mode - POWERLEVEL9K_MODE="awesome-patched" + P9K_MODE="awesome-patched" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the - # current POWERLEVEL9K_MODE. + # current P9K_MODE. # Use parameter expansion, to directly check if the # key exists in the flat current array of keys. That # is quite complicated, but there seems no easy way @@ -100,43 +100,43 @@ function testAllIconsAreDefinedLikeInDefaultMode() { # The usual way would always return the value, so that # would do the wrong thing as we have some (on purpose) # empty values. - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "awesome-fontconfig" mode - POWERLEVEL9K_MODE="awesome-fontconfig" + P9K_MODE="awesome-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "nerdfont-fontconfig" mode - POWERLEVEL9K_MODE="nerdfont-fontconfig" + P9K_MODE="nerdfont-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "flat" mode - POWERLEVEL9K_MODE="flat" + P9K_MODE="flat" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "compatible" mode - POWERLEVEL9K_MODE="compatible" + P9K_MODE="compatible" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done unset current_icons @@ -148,7 +148,7 @@ function testAllIconsAreDefinedLikeInDefaultMode() { function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # Always compare against this mode local _P9K_TEST_MODE="awesome-patched" - POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + P9K_MODE="$_P9K_TEST_MODE" source functions/icons.zsh # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key @@ -157,14 +157,14 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode - POWERLEVEL9K_MODE="default" + P9K_MODE="default" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the - # current POWERLEVEL9K_MODE. + # current P9K_MODE. # Use parameter expansion, to directly check if the # key exists in the flat current array of keys. That # is quite complicated, but there seems no easy way @@ -172,43 +172,43 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { # The usual way would always return the value, so that # would do the wrong thing as we have some (on purpose) # empty values. - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "awesome-fontconfig" mode - POWERLEVEL9K_MODE="awesome-fontconfig" + P9K_MODE="awesome-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "nerdfont-fontconfig" mode - POWERLEVEL9K_MODE="nerdfont-fontconfig" + P9K_MODE="nerdfont-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "flat" mode - POWERLEVEL9K_MODE="flat" + P9K_MODE="flat" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "compatible" mode - POWERLEVEL9K_MODE="compatible" + P9K_MODE="compatible" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done unset current_icons @@ -220,7 +220,7 @@ function testAllIconsAreDefinedLikeInAwesomePatchedMode() { function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # Always compare against this mode local _P9K_TEST_MODE="awesome-fontconfig" - POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + P9K_MODE="$_P9K_TEST_MODE" source functions/icons.zsh # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key @@ -229,14 +229,14 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode - POWERLEVEL9K_MODE="default" + P9K_MODE="default" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the - # current POWERLEVEL9K_MODE. + # current P9K_MODE. # Use parameter expansion, to directly check if the # key exists in the flat current array of keys. That # is quite complicated, but there seems no easy way @@ -244,43 +244,43 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { # The usual way would always return the value, so that # would do the wrong thing as we have some (on purpose) # empty values. - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "awesome-patched" mode - POWERLEVEL9K_MODE="awesome-patched" + P9K_MODE="awesome-patched" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "nerdfont-fontconfig" mode - POWERLEVEL9K_MODE="nerdfont-fontconfig" + P9K_MODE="nerdfont-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "flat" mode - POWERLEVEL9K_MODE="flat" + P9K_MODE="flat" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "compatible" mode - POWERLEVEL9K_MODE="compatible" + P9K_MODE="compatible" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done unset current_icons @@ -292,7 +292,7 @@ function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # Always compare against this mode local _P9K_TEST_MODE="nerdfont-fontconfig" - POWERLEVEL9K_MODE="$_P9K_TEST_MODE" + P9K_MODE="$_P9K_TEST_MODE" source functions/icons.zsh # _ICONS_UNDER_TEST is an array of just the keys of $icons. # We later check via (r) "subscript" flag that our key @@ -301,14 +301,14 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { _ICONS_UNDER_TEST=(${(k)icons[@]}) # Switch to "default" mode - POWERLEVEL9K_MODE="default" + P9K_MODE="default" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do # Iterate over all keys found in the _ICONS_UNDER_TEST # array and compare it with the icons array of the - # current POWERLEVEL9K_MODE. + # current P9K_MODE. # Use parameter expansion, to directly check if the # key exists in the flat current array of keys. That # is quite complicated, but there seems no easy way @@ -316,47 +316,47 @@ function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { # The usual way would always return the value, so that # would do the wrong thing as we have some (on purpose) # empty values. - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "awesome-patched" mode - POWERLEVEL9K_MODE="awesome-patched" + P9K_MODE="awesome-patched" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "awesome-fontconfig" mode - POWERLEVEL9K_MODE="awesome-fontconfig" + P9K_MODE="awesome-fontconfig" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "flat" mode - POWERLEVEL9K_MODE="flat" + P9K_MODE="flat" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done # Switch to "compatible" mode - POWERLEVEL9K_MODE="compatible" + P9K_MODE="compatible" source functions/icons.zsh typeset -ah current_icons current_icons=(${(k)icons[@]}) for key in ${_ICONS_UNDER_TEST}; do - assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" + assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${P9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" done unset current_icons unset _ICONS_UNDER_TEST } -source shunit2/source/2.1/src/shunit2 \ No newline at end of file +source shunit2/source/2.1/src/shunit2 diff --git a/test/functions/utilities.spec b/test/functions/utilities.spec index a9bd67e35..1faafba31 100755 --- a/test/functions/utilities.spec +++ b/test/functions/utilities.spec @@ -23,7 +23,7 @@ function testDefinedDoesNotFindUndefinedVariable() { } function testSetDefaultSetsVariable() { - set_default 'my_var' 'x' + setDefault 'my_var' 'x' assertEquals 'x' "$my_var" unset my_var diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index bfd9f1ac8..3849c4fbc 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -16,96 +16,96 @@ function setUp() { # Unset mode, so that user settings # do not interfere with tests - unset POWERLEVEL9K_MODE + unset P9K_MODE # Load all segments that need to be tested so that they can be sourced - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator background_jobs) + P9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator background_jobs) } function testJoinedSegments() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir dir_joined) + P9K_LEFT_PROMPT_ELEMENTS=(dir dir_joined) cd /tmp - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS cd - } function testTransitiveJoinedSegments() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator_joined dir_joined) + P9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator_joined dir_joined) cd /tmp - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS cd - } function testJoiningWithConditionalSegment() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir background_jobs dir_joined) + P9K_LEFT_PROMPT_ELEMENTS=(dir background_jobs dir_joined) cd /tmp - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black} %F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS cd - } function testDynamicColoringOfSegmentsWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_DIR_DEFAULT_BACKGROUND='red' cd /tmp - assertEquals "%K{red} %F{black}/tmp %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{black}/tmp %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_DIR_DEFAULT_BACKGROUND cd - } function testDynamicColoringOfVisualIdentifiersWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' - POWERLEVEL9K_FOLDER_ICON="icon-here" + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' + P9K_FOLDER_ICON="icon-here" cd /tmp - assertEquals "%K{blue} %F{green%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{green%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR - unset POWERLEVEL9K_FOLDER_ICON + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR + unset P9K_FOLDER_ICON cd - } function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' - POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='red' - POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='yellow' - POWERLEVEL9K_FOLDER_ICON="icon-here" + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' + P9K_DIR_DEFAULT_FOREGROUND='red' + P9K_DIR_DEFAULT_BACKGROUND='yellow' + P9K_FOLDER_ICON="icon-here" - # Re-Source the icons, as the POWERLEVEL9K_MODE is directly + # Re-Source the icons, as the P9K_MODE is directly # evaluated there. source functions/icons.zsh source segments/core/dir.p9k cd /tmp - assertEquals "%K{yellow} %F{green%}icon-here%f %F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{green%}icon-here%f %F{red}/tmp %k%F{yellow}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR - unset POWERLEVEL9K_DIR_DEFAULT_FOREGROUND - unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND - unset POWERLEVEL9K_FOLDER_ICON + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR + unset P9K_DIR_DEFAULT_FOREGROUND + unset P9K_DIR_DEFAULT_BACKGROUND + unset P9K_FOLDER_ICON cd - } function testOverwritingIconsWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_FOLDER_ICON='icon-here' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_FOLDER_ICON='icon-here' #local testFolder=$(mktemp -d -p p9k) # Move testFolder under home folder #mv testFolder ~ @@ -113,10 +113,10 @@ function testOverwritingIconsWork() { #cd ~/$testFolder cd /tmp - assertEquals "%K{blue} %F{black%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_FOLDER_ICON + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_DIR_FOLDER_ICON cd - # rm -fr ~/$testFolder } diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec index 11386c5a4..58454ada0 100755 --- a/test/segments/command_execution_time.spec +++ b/test/segments/command_execution_time.spec @@ -13,84 +13,84 @@ function setUp() { } function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time) - POWERLEVEL9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time) + P9K_CUSTOM_WORLD='echo world' _P9K_COMMAND_DURATION=2 - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD unset _P9K_COMMAND_DURATION } function testCommandExecutionTimeThresholdCouldBeChanged() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 _P9K_COMMAND_DURATION=2.03 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}2.03 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD + unset P9K_COMMAND_EXECUTION_TIME_THRESHOLD } function testCommandExecutionTimeThresholdCouldBeSetToZero() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 _P9K_COMMAND_DURATION=0.03 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.03 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD + unset P9K_COMMAND_EXECUTION_TIME_THRESHOLD } function testCommandExecutionTimePrecisionCouldBeChanged() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 - POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 + P9K_COMMAND_EXECUTION_TIME_PRECISION=4 _P9K_COMMAND_DURATION=0.0001 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.0001 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD + unset P9K_COMMAND_EXECUTION_TIME_PRECISION + unset P9K_COMMAND_EXECUTION_TIME_THRESHOLD } function testCommandExecutionTimePrecisionCouldBeSetToZero() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_COMMAND_EXECUTION_TIME_PRECISION=0 _P9K_COMMAND_DURATION=23.5001 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}23 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION + unset P9K_COMMAND_EXECUTION_TIME_PRECISION } function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=180 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}03:00 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION } function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) + P9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=7200 - assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}02:00:00 %k%F{red}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION } diff --git a/test/segments/dir.spec b/test/segments/dir.spec index c1a98d01c..73a38805b 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -13,154 +13,154 @@ function setUp() { source segments/core/dir.p9k # Every test should at least use the dir segment - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_LEFT_PROMPT_ELEMENTS=(dir) } function tearDown() { - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS } function testDirPathAbsoluteWorks() { - POWERLEVEL9K_DIR_PATH_ABSOLUTE=true + P9K_DIR_PATH_ABSOLUTE=true cd ~ - assertEquals "%K{blue} %F{black}/home/travis %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/home/travis %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_ABSOLUTE + unset P9K_DIR_PATH_ABSOLUTE } function testTruncateFoldersWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_folders' FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncateMiddleWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_middle' FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_STRATEGY } function testTruncationFromRightWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_from_right' FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncateToLastWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY="truncate_to_last" FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncateToFirstAndLastWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY="truncate_to_first_and_last" FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncateAbsoluteWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY="truncate_absolute" FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}…89 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}…89 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncationFromRightWithEmptyDelimiter() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_DELIMITER="" - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_DELIMITER="" + P9K_SHORTEN_STRATEGY='truncate_from_right' FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_DELIMITER - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_DELIMITER + unset P9K_SHORTEN_STRATEGY } function testTruncateWithFolderMarkerWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_SHORTEN_STRATEGY="truncate_with_folder_marker" local BASEFOLDER=/tmp/powerlevel9k-test local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 @@ -168,20 +168,20 @@ function testTruncateWithFolderMarkerWorks() { # Setup folder marker touch $BASEFOLDER/1/12/.shorten_folder_marker cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr $BASEFOLDER unset BASEFOLDER unset FOLDER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS } function testTruncateWithFolderMarkerWithChangedFolderMarker() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" - POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_SHORTEN_STRATEGY="truncate_with_folder_marker" + P9K_SHORTEN_FOLDER_MARKER='.xxx' local BASEFOLDER=/tmp/powerlevel9k-test local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 @@ -189,15 +189,15 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() { # Setup folder marker touch $BASEFOLDER/1/12/.xxx cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr $BASEFOLDER unset BASEFOLDER unset FOLDER - unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_FOLDER_MARKER + unset P9K_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS } function testTruncateWithPackageNameWorks() { @@ -218,18 +218,18 @@ function testTruncateWithPackageNameWorks() { # Go back to deeper folder cd "${FOLDER}" - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_with_package_name' - assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(buildLeftPrompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH } function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() { @@ -257,18 +257,18 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() { # Go to deep folder inside linked repo cd linked-repo/asdfasdf/qwerqwer - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_with_package_name' - assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(buildLeftPrompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH } function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() { @@ -292,337 +292,337 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() { cd linked-repo/.git/refs/heads - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + P9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_with_package_name' - assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(buildLeftPrompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_SHORTEN_STRATEGY + unset P9K_SHORTEN_DIR_LENGTH } function testHomeFolderDetectionWorks() { - POWERLEVEL9K_HOME_ICON='home-icon' + P9K_HOME_ICON='home-icon' cd ~ - assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_HOME_ICON + unset P9K_HOME_ICON } function testHomeSubfolderDetectionWorks() { - POWERLEVEL9K_HOME_SUB_ICON='sub-icon' + P9K_HOME_SUB_ICON='sub-icon' FOLDER=~/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr $FOLDER unset FOLDER - unset POWERLEVEL9K_HOME_SUB_ICON + unset P9K_HOME_SUB_ICON } function testOtherFolderDetectionWorks() { - POWERLEVEL9K_FOLDER_ICON='folder-icon' + P9K_FOLDER_ICON='folder-icon' FOLDER=/tmp/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr $FOLDER unset FOLDER - unset POWERLEVEL9K_FOLDER_ICON + unset P9K_FOLDER_ICON } function testChangingDirPathSeparator() { - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + P9K_DIR_PATH_SEPARATOR='xXx' local FOLDER="/tmp/powerlevel9k-test/1/2" mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(buildLeftPrompt)" cd - unset FOLDER rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR + unset P9K_DIR_PATH_SEPARATOR } function testHomeFolderAbbreviation() { - local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION + local P9K_HOME_FOLDER_ABBREVIATION local dir=$PWD cd ~/ # default - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' - assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + P9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(buildLeftPrompt)" # substituted - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' - assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" + P9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(buildLeftPrompt)" cd /tmp # default - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' - assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + P9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" # substituted - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' - assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + P9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(buildLeftPrompt)" cd "$dir" } function testOmittingFirstCharacterWorks() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_FOLDER_ICON='folder-icon' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_FOLDER_ICON='folder-icon' cd /tmp - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_FOLDER_ICON + unset P9K_DIR_OMIT_FIRST_CHARACTER } function testOmittingFirstCharacterWorksWithChangingPathSeparator() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_FOLDER_ICON='folder-icon' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_DIR_PATH_SEPARATOR='xXx' + P9K_FOLDER_ICON='folder-icon' mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_FOLDER_ICON + unset P9K_DIR_PATH_SEPARATOR + unset P9K_DIR_OMIT_FIRST_CHARACTER } # This test makes it obvious that combining a truncation strategy # that cuts off folders from the left and omitting the the first # character does not make much sense. The truncation strategy # comes first, prints an ellipsis and that gets then cut off by -# POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER.. +# P9K_DIR_OMIT_FIRST_CHARACTER.. # But it does more sense in combination with other truncation # strategies. function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_DIR_PATH_SEPARATOR='xXx' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_folders' mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}xXx1xXx2 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_DIR_PATH_SEPARATOR + unset P9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_DIR_PATH_SEPARATOR='xXx' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_middle' mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}tmpxXxpo…stxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}tmpxXxpo…stxXx1xXx2 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_DIR_PATH_SEPARATOR + unset P9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_DIR_PATH_SEPARATOR='xXx' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_from_right' mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}tmpxXxpo…xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}tmpxXxpo…xXx1xXx2 %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_DIR_PATH_SEPARATOR + unset P9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testTruncateToUniqueWorks() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' + P9K_DIR_OMIT_FIRST_CHARACTER=true + P9K_DIR_PATH_SEPARATOR='xXx' + P9K_SHORTEN_DIR_LENGTH=2 + P9K_SHORTEN_STRATEGY='truncate_to_unique' mkdir -p /tmp/powerlevel9k-test/adam/devl mkdir -p /tmp/powerlevel9k-test/alice/devl mkdir -p /tmp/powerlevel9k-test/alice/docs mkdir -p /tmp/powerlevel9k-test/bob/docs cd /tmp/powerlevel9k-test/alice/devl - assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY + unset P9K_DIR_PATH_SEPARATOR + unset P9K_DIR_OMIT_FIRST_CHARACTER + unset P9K_SHORTEN_DIR_LENGTH + unset P9K_SHORTEN_STRATEGY } function testBoldHomeDirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + P9K_DIR_PATH_HIGHLIGHT_BOLD=true cd ~ - assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD + unset P9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + P9K_DIR_PATH_HIGHLIGHT_BOLD=true mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}~/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD + unset P9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootDirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + P9K_DIR_PATH_HIGHLIGHT_BOLD=true cd / - assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD + unset P9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + P9K_DIR_PATH_HIGHLIGHT_BOLD=true cd /tmp - assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD + unset P9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + P9K_DIR_PATH_HIGHLIGHT_BOLD=true mkdir -p /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}/tmp/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD + unset P9K_DIR_PATH_HIGHLIGHT_BOLD } function testHighlightHomeWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + P9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' cd ~ - assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND + unset P9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + P9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}~/%F{red}powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND + unset P9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + P9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' cd / - assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND + unset P9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + P9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' cd /tmp - assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(buildLeftPrompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND + unset P9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + P9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' mkdir /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}/tmp/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}/tmp/%F{red}powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND + unset P9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testDirSeparatorColorHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + P9K_DIR_PATH_SEPARATOR_FOREGROUND='red' mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}~%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND + unset P9K_DIR_PATH_SEPARATOR_FOREGROUND } function testDirSeparatorColorRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + P9K_DIR_PATH_SEPARATOR_FOREGROUND='red' mkdir -p /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND + unset P9K_DIR_PATH_SEPARATOR_FOREGROUND } source shunit2/source/2.1/src/shunit2 diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 622722236..70d1d7851 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -36,51 +36,51 @@ function mockGoEmptyGopath() { function testGo() { alias go=mockGo - POWERLEVEL9K_GO_ICON="" - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version) + P9K_GO_ICON="" + P9K_LEFT_PROMPT_ELEMENTS=(go_version) PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" - assertEquals "%K{green} %F{grey93%}%f %F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{grey93%}%f %F{grey93}go1.5.3 %k%F{green}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_GO_ICON + unset P9K_GO_ICON unset PWD - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unalias go } function testGoSegmentPrintsNothingIfEmptyGopath() { alias go=mockGoEmptyGopath - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) + P9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD } function testGoSegmentPrintsNothingIfNotInGopath() { alias go=mockGo - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) + P9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD } function testGoSegmentPrintsNothingIfGoIsNotAvailable() { alias go=noGo - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) + P9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD unalias go } diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index bde909953..0234de0a1 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -68,31 +68,31 @@ function mockKubectlOtherNamespace() { function testKubeContext() { alias kubectl=mockKubectl - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + P9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unalias kubectl } function testKubeContextOtherNamespace() { alias kubectl=mockKubectlOtherNamespace - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + P9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unalias kubectl } function testKubeContextPrintsNothingIfKubectlNotAvailable() { alias kubectl=noKubectl - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext) + P9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext) - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD unalias kubectl } diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 0be94d249..195152a5f 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -18,23 +18,23 @@ function mockRust() { function testRust() { alias rustc=mockRust - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) + P9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{darkorange}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_LEFT_PROMPT_ELEMENTS unalias rustc } function testRustPrintsNothingIfRustIsNotAvailable() { alias rustc=noRust - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) + P9K_CUSTOM_WORLD='echo world' + P9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(buildLeftPrompt)" - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_CUSTOM_WORLD unalias rustc } diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index dd87b4092..6d31be627 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -13,29 +13,29 @@ function setUp() { } function testColorOverridingForCleanStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' - POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_CLEAN_FOREGROUND='cyan' + P9K_VCS_CLEAN_BACKGROUND='white' FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER cd $FOLDER git init 1>/dev/null - assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(build_left_prompt)" + assertEquals "%K{white} %F{cyan} master %k%F{white}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_CLEAN_FOREGROUND - unset POWERLEVEL9K_VCS_CLEAN_BACKGROUND + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_CLEAN_FOREGROUND + unset P9K_VCS_CLEAN_BACKGROUND } function testColorOverridingForModifiedStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red' - POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow' + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_MODIFIED_FOREGROUND='red' + P9K_VCS_MODIFIED_BACKGROUND='yellow' FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER @@ -48,20 +48,20 @@ function testColorOverridingForModifiedStateWorks() { git commit -m "test" 1>/dev/null echo "test" > testfile - assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{red} master ● %k%F{yellow}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_MODIFIED_FOREGROUND - unset POWERLEVEL9K_VCS_MODIFIED_BACKGROUND + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_MODIFIED_FOREGROUND + unset P9K_VCS_MODIFIED_BACKGROUND } function testColorOverridingForUntrackedStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan' - POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow' + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_UNTRACKED_FOREGROUND='cyan' + P9K_VCS_UNTRACKED_BACKGROUND='yellow' FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER @@ -69,14 +69,14 @@ function testColorOverridingForUntrackedStateWorks() { git init 1>/dev/null touch testfile - assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{cyan} master ? %k%F{yellow}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND - unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_UNTRACKED_FOREGROUND + unset P9K_VCS_UNTRACKED_BACKGROUND } source shunit2/source/2.1/src/shunit2 From 54295b0bce8aff42bfbfa41e9112fef50a609fde Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 11:38:32 +0400 Subject: [PATCH 31/55] Minor update Forgot to prefix variables in tests with $ *hides in the corner* --- functions/utilities.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 42646e015..877ba19f5 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -116,8 +116,8 @@ updateEnvironmentVars() { unset $origVar fi done - [[ P9K_IGNORE_VAR_WARNING ]] && oldVarsFound=false # disable warning if user sets P9K_IGNORE_VAR_WARNING to true. - [[ oldVarsFound ]] && print -P "%F{yellow}Information!%f As of this update, the %F{cyan}POWERLEVEL9K_*%f variables have been replaced by %F{cyan}P9K_*%f. + [[ $P9K_IGNORE_VAR_WARNING ]] && oldVarsFound=false # disable warning if user sets P9K_IGNORE_VAR_WARNING to true. + [[ $oldVarsFound ]] && print -P "%F{yellow}Information!%f As of this update, the %F{cyan}POWERLEVEL9K_*%f variables have been replaced by %F{cyan}P9K_*%f. Variables are been converted automatically, but there may still be some errors. For more informations, have a look at the CHANGELOG.md. To disable this warning, please modify your configuration file to use the new style variables, or add %F{green}P9K_IGNORE_VAR_WARNING=true%f to your config." } From 5b8e32b6cc62b679ecf4b28d2440208001b58086 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 11:42:52 +0400 Subject: [PATCH 32/55] Update for Travis Travis requires [[ $var == true ]] to work and not just [[ $var ]] --- functions/utilities.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 877ba19f5..78bc72964 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -116,8 +116,8 @@ updateEnvironmentVars() { unset $origVar fi done - [[ $P9K_IGNORE_VAR_WARNING ]] && oldVarsFound=false # disable warning if user sets P9K_IGNORE_VAR_WARNING to true. - [[ $oldVarsFound ]] && print -P "%F{yellow}Information!%f As of this update, the %F{cyan}POWERLEVEL9K_*%f variables have been replaced by %F{cyan}P9K_*%f. + [[ $P9K_IGNORE_VAR_WARNING == true ]] && oldVarsFound=false # disable warning if user sets P9K_IGNORE_VAR_WARNING to true. + [[ $oldVarsFound == true ]] && print -P "%F{yellow}Information!%f As of this update, the %F{cyan}POWERLEVEL9K_*%f variables have been replaced by %F{cyan}P9K_*%f. Variables are been converted automatically, but there may still be some errors. For more informations, have a look at the CHANGELOG.md. To disable this warning, please modify your configuration file to use the new style variables, or add %F{green}P9K_IGNORE_VAR_WARNING=true%f to your config." } From 6fd69dfab12151e840fb8c636ebcdffa494ccc45 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 11:47:28 +0400 Subject: [PATCH 33/55] Travis update #2 Travis seems to have a problem with this line: typeset -gU P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") replaced it with: typeset -gU P9K_PROMPT_ELEMENTS P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") --- functions/utilities.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 78bc72964..646c3bb27 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -248,7 +248,8 @@ if [[ "$OS" == 'macOS' ]]; then fi # Combine the PROMPT_ELEMENTS -typeset -gU P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") +typeset -gU P9K_PROMPT_ELEMENTS +P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") ############################################################### # @description From 12638387af709d927fc04574cbed6d6b86039fce Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 12:29:18 +0400 Subject: [PATCH 34/55] Segment Auto Loading updates Custom segments: - Check if the custom segment is a variable/definition. If so, use it. - Next, check if a custom segment file exists. If so, use it. Segments: - Check if a segment file exists. If so, use it. --- generator/default.p9k | 24 ++++++++++++++++------- test/powerlevel9k.spec | 3 --- test/segments/command_execution_time.spec | 1 - 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index 7c7dd7474..c969ada96 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -336,14 +336,20 @@ buildLeftPrompt() { # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then if [[ -z "${loadedSegments[(r)$element]}" ]]; then - source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 - loadedSegments+=("$element") + if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + loadedSegments+=("$element") + elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi fi "prompt_custom" "left" "$index" $joined $element[8,-1] else if [[ -z "${loadedSegments[(r)$element]}" ]]; then - source "${p9kDirectory}/segments/${element}.p9k" 2>&1 - loadedSegments+=("$element") + if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi fi "prompt_$element" "left" "$index" $joined fi @@ -375,12 +381,16 @@ buildRightPrompt() { # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then if [[ -z "${loadedSegments[(r)$element]}" ]]; then - source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 - loadedSegments+=("$element") + if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + loadedSegments+=("$element") + elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi fi "prompt_custom" "right" "$index" $joined $element[8,-1] else - if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -z "${loadedSegments[(r)$element]}" ]]; then # check if segment file exists source "${p9kDirectory}/segments/${element}.p9k" 2>&1 loadedSegments+=("$element") fi diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 3849c4fbc..0878cfd2c 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -10,9 +10,6 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* - source segments/core/dir.p9k - source segments/core/background_jobs.p9k - source segments/core/root_indicator.p9k # Unset mode, so that user settings # do not interfere with tests diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec index 58454ada0..4ee4d438d 100755 --- a/test/segments/command_execution_time.spec +++ b/test/segments/command_execution_time.spec @@ -9,7 +9,6 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/core/command_execution_time.p9k } function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() { From 44abba6724b5983ab5e27caa90f50bdcae9d97ac Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 12:35:47 +0400 Subject: [PATCH 35/55] Updated tests Since we now have autoloading of segments, removed sourcing of segments in the setUp function of the tests. --- test/segments/dir.spec | 1 - test/segments/go_version.spec | 1 - test/segments/kubecontext.spec | 1 - test/segments/rust_version.spec | 1 - test/segments/vcs.spec | 1 - 5 files changed, 5 deletions(-) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 73a38805b..9879b8c74 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -10,7 +10,6 @@ function setUp() { # Load Powerlevel9k source powerlevel9k.zsh-theme source functions/* - source segments/core/dir.p9k # Every test should at least use the dir segment P9K_LEFT_PROMPT_ELEMENTS=(dir) diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 70d1d7851..05a84c142 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -9,7 +9,6 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/developer/go_version.p9k } function mockGo() { diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index 0234de0a1..2dd19c880 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -9,7 +9,6 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/developer/kubecontext.p9k } function mockKubectl() { diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 195152a5f..e93f8109c 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -9,7 +9,6 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/developer/rust_version.p9k } function mockRust() { diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index 6d31be627..652a9148f 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -9,7 +9,6 @@ function setUp() { export TERM="xterm-256color" # Load Powerlevel9k source powerlevel9k.zsh-theme - source segments/developer/vcs.p9k } function testColorOverridingForCleanStateWorks() { From 9a719d35e582406f9241e61adaf8e1daf507bc28 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 13:01:08 +0400 Subject: [PATCH 36/55] Updates to zsh-async Coding style updates, and sync with default generator --- generator/default.p9k | 18 ++++-- generator/zsh-async.p9k | 120 ++++++++++++++++++++++++++++------------ 2 files changed, 98 insertions(+), 40 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index c969ada96..1c5950013 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -390,9 +390,11 @@ buildRightPrompt() { fi "prompt_custom" "right" "$index" $joined $element[8,-1] else - if [[ -z "${loadedSegments[(r)$element]}" ]]; then # check if segment file exists - source "${p9kDirectory}/segments/${element}.p9k" 2>&1 - loadedSegments+=("$element") + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi fi "prompt_$element" "right" "$index" $joined fi @@ -409,7 +411,12 @@ buildRightPrompt() { # @noargs ## p9k_preexec() { - _P9K_TIMER_START=$EPOCHREALTIME + # The Timer is started here, but the end + # is taken in p9kPreparePrompts, as this + # method is a precmd hook and runs right + # before the prompt gets rendered. So we + # can calculate the duration there. + _P9K_TIMER_START=${EPOCHREALTIME} } setDefault P9K_PROMPT_ADD_NEWLINE false @@ -431,6 +438,8 @@ p9kPreparePrompts() { # Reset start time _P9K_TIMER_START=0x7FFFFFFF + local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters + if [[ "$P9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT='$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(buildLeftPrompt) $(printIcon 'MULTILINE_LAST_PROMPT_PREFIX')' @@ -440,7 +449,6 @@ $(printIcon 'MULTILINE_LAST_PROMPT_PREFIX')' # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we # advise it to go one line down. See: # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 - local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down else diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index f5f5eca16..0361d29b3 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -103,7 +103,7 @@ rightPromptSegment() { # @args # $1 integer Index - Left prompt source segment index ## -last_left_bg() { +lastLeftBg() { # Name the parameters local CURRENT_INDEX="${1}" LAST_BG=0 # Start at the segment before the current segment and work to the left @@ -124,7 +124,7 @@ last_left_bg() { # @args # $1 integer Index - Right prompt source segment index ## -last_right_bg() { +lastRightBg() { # Name the parameters local CURRENT_INDEX="${1}" LAST_BG=0 # Start at the segment before the current segment and work to the left @@ -145,7 +145,7 @@ last_right_bg() { ## # @noargs ## -update_left_prompt() { +updateLeftPrompt() { local LBG LAST_LBG LSEGMENTS # Determine how many segments are visible in the left prompt LSEGMENTS=${#P9K_LP_CONTENT} @@ -157,7 +157,7 @@ update_left_prompt() { LFG=${P9K_LP_FOREGROUND[$i]} if [[ $i != 1 ]]; then # If it is not the first segment... # Find previous left segment background - LAST_LBG=$(last_left_bg $i) + LAST_LBG=$(lastLeftBg $i) if [[ $P9K_LP_JOINED[$i] == "false" ]]; then # If the segment are not joined... if [[ "${LBG}" == "${LAST_LBG}" ]]; then # Are the backgrounds the same... # We take the current foreground color as color for our subsegment, and @@ -178,11 +178,11 @@ update_left_prompt() { done # Prompt is complete, so find the background of the last segment local LBI=$((${#P9K_LP_CONTENT} + 1)) - LBG=$(last_left_bg ${LBI}) + LBG=$(lastLeftBg ${LBI}) # Add the last left segment separator and the suffix LEFT_PROMPT+="%F{${LBG}}%k${_P9K_LEFT_SEGMENT_SEPARATOR}%f%b " # Set the left prompt - PROMPT=${LEFT_PROMPT_PREFIX}${LEFT_PROMPT}${LEFT_PROMPT_SUFFIX} + PROMPT=${LPROMPT_PREFIX}${LEFT_PROMPT}${LPROMPT_SUFFIX} # About .reset-prompt see: # https://github.com/sorin-ionescu/prezto/issues/1026 # https://github.com/zsh-users/zsh-autosuggestions/issues/107#issuecomment-183824034 @@ -196,7 +196,7 @@ update_left_prompt() { ## # @noargs ## -update_right_prompt() { +updateRightPrompt() { local RBG LAST_RBG RSEGMENTS # Determine how many segments are visible in the left prompt RSEGMENTS=${#P9K_RP_CONTENT} @@ -207,7 +207,7 @@ update_right_prompt() { RBG=${P9K_RP_BACKGROUND[$i]} RFG=${P9K_RP_FOREGROUND[$i]} # Find previous right segment background - LAST_RBG=$(last_right_bg $i) + LAST_RBG=$(lastRightBg $i) # Should the segment not be joined? if [[ $P9K_RP_JOINED[$i] == "false" ]]; then # Are the backgrounds the same... @@ -226,7 +226,7 @@ update_right_prompt() { done [[ "${P9K_FANCY_EDGE}" == "true" ]] && RIGHT_PROMPT+="%k%F{$RBG}${_P9K_LEFT_SEGMENT_SEPARATOR}%f" # Set the left prompt - RPROMPT=${RIGHT_PROMPT_PREFIX}${RIGHT_PROMPT}${RIGHT_PROMPT_SUFFIX} + RPROMPT=${RPROMPT_PREFIX}${RIGHT_PROMPT}${RPROMPT_SUFFIX} # About .reset-prompt see: # https://github.com/sorin-ionescu/prezto/issues/1026 # https://github.com/zsh-users/zsh-autosuggestions/issues/107#issuecomment-183824034 @@ -250,13 +250,13 @@ update_right_prompt() { # $4 number Exec_Time - Execution time, floating point (in seconds) # $5 string Err - Resulting (stderr) output from the job ## -p9k_async_callback() { +p9kAsyncCallback() { # Name the parameters (CODE, EXEC_TIME and ERR are not currently used, but are included for possible future use) local JOB="${1}" CODE="${2}" OUTPUT="${3}" EXEC_TIME="${4}" ERR="${5}" # Determine which function returned output... case $JOB in - p9k_serializeSegment) # Segment code was converted into data + p9kSerializeSegment) # Segment code was converted into data # Make sure we received the data if [[ -n $OUTPUT ]]; then # split $OUTPUT into an array - see https://unix.stackexchange.com/a/28873 @@ -315,7 +315,7 @@ p9k_async_callback() { # See: https://www.zsh.org/mla/users/2007/msg00086.html [[ ${ar[1]} == <-> ]] && P9K_LP_CONTENT[${ar[1]}]="${ar[2]}" # Update the left prompt - update_left_prompt + updateLeftPrompt fi ;; rightPromptSegment) # Data was converted into a right prompt segment @@ -329,7 +329,7 @@ p9k_async_callback() { # See: https://www.zsh.org/mla/users/2007/msg00086.html [[ ${ar[1]} == <-> ]] && P9K_RP_CONTENT[${ar[1]}]="${ar[2]}" # Update the right prompt - update_right_prompt + updateRightPrompt fi ;; esac @@ -342,7 +342,7 @@ p9k_async_callback() { ############################################################### # @description # This function processes the segment code in a subshell. -# When done, the resulting data is sent to `p9k_async_callback`. +# When done, the resulting data is sent to `p9kAsyncCallback`. ## # @args # $1 string Name - Segment name @@ -356,7 +356,7 @@ p9k_async_callback() { # $9 string Visual identifier - Segment icon # $10 string Condition - The condition, if the segment should be printed (gets evaluated) ## -p9k_serializeSegment() { +p9kSerializeSegment() { local NAME="${(U)1}" STATE="${(U)2}" ALIGNMENT="${3}" INDEX="${4}" JOINED="${5}" CONTENT="${8}" CONDITION="${10}" ################################################################ @@ -422,7 +422,7 @@ p9k_serializeSegment() { # $@ misc The parameters passed from the segment code ## serializeSegment() { - (async_job "p9k" "p9k_serializeSegment" "${@}") + (async_job "p9k" "p9kSerializeSegment" "${@}") } ################################################################ @@ -457,7 +457,7 @@ prompt_custom() { ## buildLeftPrompt() { local index=1 - local joined + local element joined for element in "${P9K_LEFT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -468,8 +468,22 @@ buildLeftPrompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + loadedSegments+=("$element") + elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi + fi "prompt_custom" "left" "${index}" "${joined}" "${element[8,-1]}" &! else + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi + fi # Could we display placeholders? # -> At most it could be static ones, but # e.g. states are the result of calculation.. @@ -488,7 +502,7 @@ buildLeftPrompt() { ## buildRightPrompt() { local index=1 - local joined + local element joined for element in "${P9K_RIGHT_PROMPT_ELEMENTS[@]}"; do # Check if segment should be joined [[ "${element[-7,-1]}" == '_joined' ]] && joined=true || joined=false @@ -499,8 +513,22 @@ buildRightPrompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + loadedSegments+=("$element") + elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi + fi "prompt_custom" "right" "$index" $joined "${element[8,-1]}" &! else + if [[ -z "${loadedSegments[(r)$element]}" ]]; then + if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + loadedSegments+=("$element") + fi + fi "prompt_$element" "right" "$index" "${joined}" &! fi index=$((index + 1)) @@ -516,10 +544,10 @@ buildRightPrompt() { ## p9k_preexec() { # The Timer is started here, but the end - # is taken in powerlevel_prepare_prompts, - # as this method is a precmd hook and runs - # right before the prompt gets rendered. So - # we can calculate the duration there. + # is taken in p9kPreparePrompts, as this + # method is a precmd hook and runs right + # before the prompt gets rendered. So we + # can calculate the duration there. _P9K_TIMER_START=${EPOCHREALTIME} } @@ -532,6 +560,10 @@ p9k_preexec() { # @noargs ## p9kPreparePrompts() { + local RETVAL RETVALS RPROMPT_PREFIX RPROMPT_SUFFIX + RETVAL=$? + RETVALS=( "$pipestatus[@]" ) + setopt localoptions noshwordsplit # stop any running async jobs @@ -554,7 +586,7 @@ p9kPreparePrompts() { # Timing calculation _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) # Reset start time - Maximum integer on 32-bit CPUs - [[ "$ARCH" == "x64" ]] && _P9K_TIMER_START=99999999999 || _P9K_TIMER_START=2147483647 + _P9K_TIMER_START=0x7FFFFFFF # I decided to use the value above for better supporting 32-bit CPUs, since the previous value "99999999999" was # causing issues on my Android phone, which is powered by an armv7l # We don't have to change that until 19 January of 2038! :) @@ -562,10 +594,10 @@ p9kPreparePrompts() { # Reset the prompts PROMPT="" RPROMPT="" - LEFT_PROMPT_PREFIX="" - LEFT_PROMPT_SUFFIX="" - RIGHT_PROMPT_PREFIX="" - RIGHT_PROMPT_SUFFIX="" + LPROMPT_PREFIX="" + LPROMPT_SUFFIX="" + RPROMPT_PREFIX="" + RPROMPT_SUFFIX="" # The prompt function will set these prompt_* options after the setup function # returns. We need prompt_subst so we can safely run commands in the prompt @@ -581,8 +613,8 @@ p9kPreparePrompts() { # Preset multiline prompt if [[ "${P9K_PROMPT_ON_NEWLINE}" == true ]]; then - LEFT_PROMPT_PREFIX="$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" - LEFT_PROMPT_SUFFIX=" + LPROMPT_PREFIX="$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" + LPROMPT_SUFFIX=" $(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" if [[ "${P9K_RPROMPT_ON_NEWLINE}" != true ]]; then # The right prompt should be on the same line as the first line of the left @@ -590,12 +622,18 @@ $(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we # advise it to go one line down. See: # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 - RIGHT_PROMPT_PREFIX='%{'$'\e[1A''%}' # one line up - RIGHT_PROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down + RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up + RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down + else + RPROMPT_PREFIX='' + RPROMPT_SUFFIX='' fi + else + RPROMPT_PREFIX='' + RPROMPT_SUFFIX='' fi - # Precompile the Segment Separators here! +# Precompile the Segment Separators here! _P9K_LEFT_SEGMENT_SEPARATOR="$(printIcon 'LEFT_SEGMENT_SEPARATOR')" _P9K_LEFT_SUBSEGMENT_SEPARATOR="$(printIcon 'LEFT_SUBSEGMENT_SEPARATOR')" _P9K_LEFT_SEGMENT_END_SEPARATOR="$(printIcon 'LEFT_SEGMENT_END_SEPARATOR')" @@ -607,8 +645,14 @@ $(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" if [[ "${(L)P9K_DISABLE_RPROMPT}" != "true" ]]; then buildRightPrompt fi + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" } +setDefault P9K_IGNORE_TERM_COLORS false +setDefault P9K_IGNORE_TERM_LANG false + ############################################################### # @description # This function is a hook into chpwd to add bindkey support. @@ -660,8 +704,14 @@ prompt_powerlevel9k_setup() { fi fi - defined P9K_LP_ELEMENTS || P9K_LP_ELEMENTS=(context dir rbenv vcs) - defined P9K_RP_ELEMENTS || P9K_RP_ELEMENTS=(status root_indicator background_jobs history time) + if ! defined P9K_LEFT_PROMPT_ELEMENTS; then + P9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) + P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") + fi + if ! defined P9K_RIGHT_PROMPT_ELEMENTS; then + P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) + P9K_PROMPT_ELEMENTS=("${P9K_LEFT_PROMPT_ELEMENTS[@]}" "${P9K_RIGHT_PROMPT_ELEMENTS[@]}") + fi # Display a warning if deprecated segments are in use. typeset -AH deprecated_segments @@ -694,7 +744,7 @@ prompt_powerlevel9k_setup() { # initialize async worker (( !${p9k_async_init:-0} )) && { async_start_worker "p9k" -n - async_register_callback "p9k" "p9k_async_callback" + async_register_callback "p9k" "p9kAsyncCallback" p9k_async_init=1 } From e7d805c50f34bdea2f9426b9e6e62b40dd2e176e Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 13:02:17 +0400 Subject: [PATCH 37/55] Updates to zsh-async.md --- api/generator/zsh-async.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/api/generator/zsh-async.md b/api/generator/zsh-async.md index 61589eb5c..963bc4768 100644 --- a/api/generator/zsh-async.md +++ b/api/generator/zsh-async.md @@ -28,12 +28,12 @@ - [leftPromptSegment()](#leftPromptSegment) - [rightPromptSegment()](#rightPromptSegment) -- [last_left_bg()](#last_left_bg) -- [last_right_bg()](#last_right_bg) -- [update_left_prompt()](#update_left_prompt) -- [update_right_prompt()](#update_right_prompt) -- [p9k_async_callback()](#p9k_async_callback) -- [p9k_serializeSegment()](#p9k_serializeSegment) +- [lastLeftBg()](#lastLeftBg) +- [lastRightBg()](#lastRightBg) +- [updateLeftPrompt()](#updateLeftPrompt) +- [updateRightPrompt()](#updateRightPrompt) +- [p9kAsyncCallback()](#p9kAsyncCallback) +- [p9kSerializeSegment()](#p9kSerializeSegment) - [serializeSegment()](#serializeSegment) - [prompt_custom()](#prompt_custom) - [buildLeftPrompt()](#buildLeftPrompt) @@ -72,7 +72,7 @@ - **$7** (string) Visual Identifier - Segment icon -## last_left_bg() +## lastLeftBg() *This function determines the background of the previous VISIBLE segment in the left prompt. * #### Arguments @@ -80,7 +80,7 @@ - **$1** (integer) Index - Left prompt source segment index -## last_right_bg() +## lastRightBg() *This function determines the background of the previous VISIBLE segment in the right prompt. * #### Arguments @@ -88,7 +88,7 @@ - **$1** (integer) Index - Right prompt source segment index -## update_left_prompt() +## updateLeftPrompt() *This function walks through the Left Prompt segment array and rebuilds the left prompt every time a subshell returns. * #### Arguments @@ -96,7 +96,7 @@ - *Function has no arguments.* -## update_right_prompt() +## updateRightPrompt() *This function walks through the Right Prompt segment array and rebuilds the right prompt every time a subshell returns. * #### Arguments @@ -104,7 +104,7 @@ - *Function has no arguments.* -## p9k_async_callback() +## p9kAsyncCallback() *This function is the heart of the async engine. Whenever a subshell is completed, this function is called to deal with the generated output. * #### Arguments @@ -116,8 +116,8 @@ - **$5** (string) Err - Resulting (stderr) output from the job -## p9k_serializeSegment() -*This function processes the segment code in a subshell. When done, the resulting data is sent to `p9k_async_callback`. * +## p9kSerializeSegment() +*This function processes the segment code in a subshell. When done, the resulting data is sent to `p9kAsyncCallback`. * #### Arguments From 85e869abf82bc32d94c94c963012244d49e3da1d Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 14:41:52 +0400 Subject: [PATCH 38/55] zsh-async fixes - segment separator colors - first right prompt segment background color - vi-mode coding error - iTerm integration - made some variables local - changed MULTILINE_SECOND_PROMPT_PREFIX to MULTILINE_LAST_PROMPT_PREFIX It works better now, but some of the segments still have occasional hiccups and print the wrong thing. --- generator/zsh-async.p9k | 32 +++++++++++++++++++------------- segments/vi_mode.p9k | 3 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index 0361d29b3..0c8107c0a 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -107,9 +107,9 @@ lastLeftBg() { # Name the parameters local CURRENT_INDEX="${1}" LAST_BG=0 # Start at the segment before the current segment and work to the left - for (( i = ${CURRENT_INDEX} - 1; i > 0; i-- )); do + for (( i = ${CURRENT_INDEX} - 1; i >= 0; i-- )); do # If the segment is not empty, we have our color - if [[ ${P9K_LP_CONTENT[$i]} != "·" ]]; then + if [[ ${P9K_LP_CONTENT[$i]} != "" ]]; then local LAST_BG="${P9K_LP_BACKGROUND[$i]}" break fi @@ -128,9 +128,9 @@ lastRightBg() { # Name the parameters local CURRENT_INDEX="${1}" LAST_BG=0 # Start at the segment before the current segment and work to the left - for (( i = ${CURRENT_INDEX} - 1; i > 0; i-- )); do + for (( i = ${CURRENT_INDEX} - 1; i >= 0; i-- )); do # If the segment is not empty, we have our color - if [[ ${P9K_RP_CONTENT[$i]} != "·" ]]; then + if [[ ${P9K_RP_CONTENT[$i]} != "" ]]; then local LAST_BG="${P9K_RP_BACKGROUND[$i]}" break fi @@ -146,7 +146,7 @@ lastRightBg() { # @noargs ## updateLeftPrompt() { - local LBG LAST_LBG LSEGMENTS + local LBG LAST_LBG LEFT_PROMPT LSEGMENTS # Determine how many segments are visible in the left prompt LSEGMENTS=${#P9K_LP_CONTENT} # Build the left prompt string @@ -197,7 +197,7 @@ updateLeftPrompt() { # @noargs ## updateRightPrompt() { - local RBG LAST_RBG RSEGMENTS + local RBG LAST_RBG RIGHT_PROMPT RSEGMENTS firstSegment=false # Determine how many segments are visible in the left prompt RSEGMENTS=${#P9K_RP_CONTENT} # Build the left prompt string @@ -215,9 +215,15 @@ updateRightPrompt() { # We take the current foreground color as color for our subsegment, # and add a sub segment separator. This should have enough contrast. RIGHT_PROMPT+="%K{${RBG}}%F{${RFG}}${_P9K_RIGHT_SUBSEGMENT_SEPARATOR}" + firstSegment=true else # ...otherwise add a right segment separator - RIGHT_PROMPT+="%K{${LAST_RBG}}%F{${RBG}}${_P9K_RIGHT_SEGMENT_SEPARATOR}" + if [[ $firstSegment == true ]]; then + RIGHT_PROMPT+="%K{${LAST_RBG}}%F{${RBG}}${_P9K_RIGHT_SEGMENT_SEPARATOR}" + else + # don't set the background color on the first segment + RIGHT_PROMPT+="%F{${RBG}}${_P9K_RIGHT_SEGMENT_SEPARATOR}" + fi fi fi # Add the segment to the right prompt string @@ -403,7 +409,7 @@ p9kSerializeSegment() { fi # Add an whitespace if we print more than just the visual identifier if [[ -n "${CONTENT}" ]]; then - [[ "${P9K_RPROMPT_ICON_LEFT}" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " || + [[ "${P9K_RPROMPT_ICON_LEFT}" ]] && VISUAL_IDENTIFIER="${VISUAL_IDENTIFIER} " [[ "${ALIGNMENT}" == "right" ]] && VISUAL_IDENTIFIER=" ${VISUAL_IDENTIFIER}" fi fi @@ -615,7 +621,7 @@ p9kPreparePrompts() { if [[ "${P9K_PROMPT_ON_NEWLINE}" == true ]]; then LPROMPT_PREFIX="$(printIcon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k${PROMPT}" LPROMPT_SUFFIX=" -$(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" +$(printIcon 'MULTILINE_LAST_PROMPT_PREFIX')" if [[ "${P9K_RPROMPT_ON_NEWLINE}" != true ]]; then # The right prompt should be on the same line as the first line of the left # prompt. To do so, there is just a quite ugly workaround: Before zsh draws @@ -633,21 +639,21 @@ $(printIcon 'MULTILINE_SECOND_PROMPT_PREFIX')" RPROMPT_SUFFIX='' fi -# Precompile the Segment Separators here! + # Precompile the Segment Separators here! _P9K_LEFT_SEGMENT_SEPARATOR="$(printIcon 'LEFT_SEGMENT_SEPARATOR')" _P9K_LEFT_SUBSEGMENT_SEPARATOR="$(printIcon 'LEFT_SUBSEGMENT_SEPARATOR')" _P9K_LEFT_SEGMENT_END_SEPARATOR="$(printIcon 'LEFT_SEGMENT_END_SEPARATOR')" _P9K_RIGHT_SEGMENT_SEPARATOR="$(printIcon 'RIGHT_SEGMENT_SEPARATOR')" _P9K_RIGHT_SUBSEGMENT_SEPARATOR="$(printIcon 'RIGHT_SUBSEGMENT_SEPARATOR')" + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && LPROMPT_PREFIX="%{$(iterm2_prompt_mark)%}$LPROMPT_PREFIX" + # Call the prompt building functions buildLeftPrompt if [[ "${(L)P9K_DISABLE_RPROMPT}" != "true" ]]; then buildRightPrompt fi - - # Allow iTerm integration to work - [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" } setDefault P9K_IGNORE_TERM_COLORS false diff --git a/segments/vi_mode.p9k b/segments/vi_mode.p9k index 3535627ab..426507754 100644 --- a/segments/vi_mode.p9k +++ b/segments/vi_mode.p9k @@ -78,7 +78,7 @@ function rebuild_vi_mode { if (( ${+terminfo[smkx]} )); then printf '%s' ${terminfo[smkx]} fi - local element + local element joined=false for (( i = 1; i <= ${#P9K_LEFT_PROMPT_ELEMENTS}; i++ )); do element="${(L)P9K_LEFT_PROMPT_ELEMENTS[$i]}" if [[ "${element}" =~ "vi_mode" ]]; then @@ -201,7 +201,6 @@ function zle-keymap-select { case $P9K_GENERATOR in zsh-async) rebuild_vi_mode "${KEYMAP}" - break; ;; *) # About .reset-prompt see: From 19351e54850f951e6c2c2d86fd79d953be88308f Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 15:10:45 +0400 Subject: [PATCH 39/55] default generator updates - Added support for bolded segments - Added support to have the right segment icon displayed on the left --- generator/default.p9k | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/generator/default.p9k b/generator/default.p9k index 1c5950013..b150d75a2 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -93,10 +93,18 @@ leftPromptSegment() { local visual_identifier [[ -n $7 ]] && visual_identifier="$7" + # Support for bold segment + local bld_on="" + local bld_off="" + if [[ $5 == true ]]; then + bld_on="%B" + bld_off="%b" + fi + # Print the visual identifier echo -n "${visual_identifier}" # Print the content of the segment, if there is any - [[ -n "$6" ]] && echo -n "${fg}${6}" + [[ -n "$6" ]] && echo -n "${fg}${bld_on}${6}${bld_off}" echo -n "${P9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" CURRENT_BG=$3 @@ -184,10 +192,25 @@ rightPromptSegment() { # Print whitespace only if segment is not joined or first right segment [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" - # Print segment content if there is any - [[ -n "$6" ]] && echo -n "${6}" - # Print the visual identifier - echo -n "${visual_identifier}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + # Support for bold segment + local bld_on="" + local bld_off="" + if [[ $5 == true ]]; then + bld_on="%B" + bld_off="%b" + fi + + if [[ ${(L)P9K_RPROMPT_ICON_LEFT} == "true" ]]; then # Visual identifier before content + # Print the visual identifier + echo -n "${visual_identifier}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" + # Print segment content if there is any + [[ -n "$6" ]] && echo -n "${bld_on}${6}${bld_off}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + else + # Print segment content if there is any + [[ -n "$6" ]] && echo -n "${bld_on}${6}${bld_off}" + # Print the visual identifier + echo -n "${visual_identifier}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + fi CURRENT_RIGHT_BG=$3 last_right_element_index=$current_index From 6b0ec7e9a86d6f480ff8471c080697d8837b2bea Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 29 Mar 2018 16:00:38 +0400 Subject: [PATCH 40/55] Updated README.md - Added missing links in index - Reordered everything to match index --- README.md | 364 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 201 insertions(+), 163 deletions(-) diff --git a/README.md b/README.md index 5c5fd2355..fa182cbd2 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,14 @@ Powerlevel9k can be used to create both very useful and beautiful terminal envir ### Table of Contents 1. [Installation](#installation) -2. [Customization](#prompt-customization) +2. [Disabling / Enabling Powerlevel9k](#disabling-/-enabling-powerlevel9k) +3. [Prompt Customization](#prompt-customization) 1. [Stylizing Your Prompt](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt) 2. [Customizing Prompt Segments](#customizing-prompt-segments) 3. [Available Prompt Segments](#available-prompt-segments) -3. [Troubleshooting](https://github.com/bhilburn/powerlevel9k/wiki/Troubleshooting) +4. [Troubleshooting](https://github.com/bhilburn/powerlevel9k/wiki/Troubleshooting) +5. [tl; dr](#tl;-dr) +6. [License](#license) Be sure to also [check out the Wiki](https://github.com/bhilburn/powerlevel9k/wiki)! @@ -50,7 +53,6 @@ There are two installation steps to go from a vanilla terminal to a PL9k terminal. Once you are done, you can optionally customize your prompt. [Installation Instructions](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions) - 1. [Install the Powerlevel9k Theme](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k) 2. [Install Powerline Fonts](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-2-install-a-powerline-font) @@ -58,6 +60,21 @@ No configuration is necessary post-installation if you like the default settings, but there are plenty of segment customization options available if you are interested. +### Disabling / Enabling Powerlevel9k + +You can disable P9k and return to a very basic prompt at any time simply by +calling: + +```zsh +$ prompt_p9k_teardown +``` + +You can then re-enable it by calling: + +```zsh +$ prompt_powerlevel9k_setup +``` + ### Prompt Customization Be sure to check out the wiki page on the additional prompt customization @@ -81,10 +98,10 @@ your `~/.zshrc`: P9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) ``` -#### Available Prompt Segments -The segments that are currently available are: +### Available Prompt Segments +The available segments are: -**System Status Segments:** +#### System Status Segments * [`background_jobs`](#background_jobs) - Indicator for background jobs. * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host, conditionalized based on $USER and SSH status. @@ -95,27 +112,29 @@ The segments that are currently available are: * `history` - The command number for the current line. * [`host`](#host) - Your current host name * [`ip`](#ip) - Shows the current IP address. -* [`vpn_ip`](#vpn_ip) - Shows the current VPN IP address. * [`public_ip`](#public_ip) - Shows your public IP address. +* [`vpn_ip`](#vpn_ip) - Shows the current VPN IP address. * [`load`](#load) - Your machine's load averages. * `os_icon` - Display a nice little icon, depending on your operating system. -* `ram` - Show free RAM. +* [`ram`](#ram) - Show free RAM. * `root_indicator` - An indicator if the user has superuser status. +* `ssh` - Indicates whether or not you are in an SSH session. * [`status`](#status) - The return code of the previous command. * `swap` - Prints the current swap size. * [`time`](#time) - System time. * [`user`](#user) - Your current username * [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT). -* `ssh` - Indicates whether or not you are in an SSH session. -**Development Environment Segments:** +#### Development Environment Segments * [`vcs`](#vcs) - Information about this `git` or `hg` repository (if you are in one). -**Language Segments:** +#### Language Segments * **GoLang Segments:** * `go_version` - Show the current GO version. +* **Java Segments:** + * `java_version` - Show the current Java version. * **Javascript / Node.js Segments:** - * `node_version` - Show the version number of the installed Node.js. + * [`node_version`](#node_version) - Show the version number of the installed Node.js. * `nodeenv` - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM * **PHP Segments:** @@ -123,9 +142,9 @@ The segments that are currently available are: * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * **Python Segments:** - * `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). * [`anaconda`](#anaconda) - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment. * `pyenv` - Your active python version as reported by the first word of [`pyenv version`](https://github.com/yyuu/pyenv). Note that the segment is not displayed if that word is _system_ i.e. the segment is inactive if you are using system python. + * `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). * **Ruby Segments:** * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). @@ -134,57 +153,31 @@ The segments that are currently available are: * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** * `swift_version` - Show the version number of the installed Swift. -* **Java Segments:** - * `java_version` - Show the current Java version. -**Cloud Segments:** +#### Cloud Segments * **AWS Segments:** * [`aws`](#aws) - The current AWS profile, if active. * `aws_eb_env` - The current Elastic Beanstalk Environment. + + * `docker_machine` - The current Docker Machine. -* `kubecontext` - The current context of your `kubectl` configuration. * `dropbox` - Indicates Dropbox directory and syncing status using `dropbox-cli` +* `kubecontext` - The current context of your `kubectl` configuration. -**Other:** +#### Other * [`custom_command`](#custom_command) - Create a custom segment to display the output of an arbitrary command. * [`command_execution_time`](#command_execution_time) - Display the time the current command took to execute. -* [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. * `detect_virt` - Virtualization detection with systemd -* `newline` - Continues the prompt on a new line. +* [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. +* [`newline`](#newline) - Continues the prompt on a new line. * `openfoam` - Shows the currently sourced [OpenFOAM](https://openfoam.org/) environment. --------------------------------------------------------------------------------- +### Segment Descriptions -##### anaconda - -This segment shows your active anaconda environment. It relies on either the -`CONDA_ENV_PATH` or the `CONDA_PREFIX` (depending on the `conda` version) -environment variable to be set which happens when you properly `source -activate` an environment. - -Special configuration variables: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`P9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| -|`P9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| - -Additionally the following segment specific parameters can be used to customize -it: `P9K_PYTHON_ICON`, `P9K_ANACONDA_BACKGROUND`, and -`P9K_ANACONDA_FOREGROUND`. - -##### aws - -If you would like to display the [current AWS -profile](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), add -the `aws` segment to one of the prompts, and define `AWS_DEFAULT_PROFILE` in -your `~/.zshrc`: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`AWS_DEFAULT_PROFILE`|None|Your AWS profile name| +#### System Status Segments ##### background_jobs @@ -216,6 +209,7 @@ level. This will override the default battery icon. In order to do this, you need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. | Variable | Default Value | Description | +|----------|---------------|-------------| | `P9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| Powerlevel9k will use each index of the string or array as a stage to indicate battery @@ -256,60 +250,13 @@ As with the battery stages, you can use any number of colors and Powerlevel9k will automatically use all of them appropriately. Some example settings: + |Brightness|Possible Array| +|----------|--------------| |Bright Colors|(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)| |Normal Colors|(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)| |Subdued Colors|(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)| -##### command_execution_time - -Display the time the previous command took to execute if the time is above -`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be -"human readable", and so scales the units based on the length of execution time. -If you want more precision, just set the -`P9K_COMMAND_EXECUTION_TIME_PRECISION` field. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.| -|`P9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.| - -##### custom_command - -The `custom_...` segment allows you to turn the output of a custom command into -a prompt segment. As an example, if you wanted to create a custom segment to -display your WiFi signal strength, you might define a custom segment called -`custom_wifi_signal` like this: -```zsh -P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) -P9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" -P9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" -P9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" -``` -If you prefer, you can also define the function in your `.zshrc` rather than -putting it in-line with the variable export, as shown above. Just don't forget -to invoke your function from your segment! Example code that achieves the same -result as the above: -```zsh -zsh_wifi_signal(){ - local signal=$(nmcli device wifi | grep yes | awk '{print $8}') - local color='%F{yellow}' - [[ $signal -gt 75 ]] && color='%F{green}' - [[ $signal -lt 50 ]] && color='%F{red}' - echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is  -} - -P9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal" -P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) -``` -The command, above, gives you the wireless signal segment shown below: - -![signal](http://i.imgur.com/hviMATC.png) - -You can define as many custom segments as you wish. If you think you have -a segment that others would find useful, please consider upstreaming it to the -main theme distribution so that everyone can use it! - ##### context The `context` segment (user@host string) is conditional. By default, it will @@ -463,7 +410,6 @@ P9K_HOST_ICON="\uF109 " P9K_SSH_ICON="\uF489 " ``` - ##### ip This segment tries to examine all currently used network interfaces and prints @@ -474,14 +420,6 @@ specify the correct network interface by setting: |----------|---------------|-------------| |`P9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| -##### vpn_ip - -This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`P9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| - ##### public_ip This segment will display your public IP address. There are several methods of obtaining this @@ -507,6 +445,14 @@ segment will not be displayed. |`P9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| |`P9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| +##### vpn_ip + +This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| + ##### load Displays one of your load averages with appropriate state coloring. The thresholds are: @@ -518,31 +464,11 @@ Displays one of your load averages with appropriate state coloring. The threshol |----------|---------------|-------------| |`P9K_LOAD_WHICH`|5|Which average to show. Possible values: 1, 5 or 15| -##### newline - -Puts a newline in your prompt so you can continue using segments on the next -line. This allows you to use segments on both lines, unlike -`P9K_PROMPT_ON_NEWLINE`, which simply separates segments from the -prompt itself. - -This only works on the left side. On the right side it does nothing. - -##### rbenv - -This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. - -It figures out the version being used by taking the output of the `rbenv version-name` command. - -* If `rbenv` is not in $PATH, nothing will be shown. -* By default, if the current local Ruby version is the same as the global Ruby version, nothing will be shown. See the configuration variable, below, to modify this behavior. +##### ram -Variable | Default Value | Description | +| Variable | Default Value | Description | |----------|---------------|-------------| -|`P9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| - -##### rspec_stats - -See [Unit Test Ratios](#unit-test-ratios), below. +|`P9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.| ##### status @@ -555,16 +481,6 @@ This segment shows the return code of the last command. |`P9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| |`P9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to false, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| -##### ram - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`P9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.| - -##### symfony2_tests - -See [Unit Test Ratios](#unit-test-ratios), below. - ##### time | Variable | Default Value | Description | @@ -600,6 +516,22 @@ P9K_SUDO_ICON=$'\uF09C' #  |`P9K_ALWAYS_SHOW_USER`|`false`|Always print this segment.| |`P9K_USER_TEMPLATE`|`%n`|Default username prompt. Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| +##### vi_mode + +This segment shows ZSH's current input mode. Note that this is only useful if +you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html) +(VI mode). You can enable this either by `.zshrc` configuration or using a plugin, like +[Oh-My-Zsh's vi-mode plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh). + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.| +|`P9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.| + +To hide the segment entirely when in `INSERT` mode, set `P9K_VI_INSERT_MODE_STRING=''` + +#### Development Environment Segments + ##### vcs By default, the `vcs` segment will provide quite a bit of information. Further @@ -618,7 +550,7 @@ customization is provided via: |`P9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| -##### vcs symbols +###### vcs symbols The `vcs` segment uses various symbols to tell you the state of your repository. These symbols depend on your installed font and selected `P9K_MODE` @@ -639,43 +571,149 @@ from the [Installation](#Installation) section above. | None | None | ![icon_git](https://cloud.githubusercontent.com/assets/1544760/7976092/b5909f80-0a76-11e5-9950-1438b9d72465.gif) | Repository is a git repository | None | None | ![icon_mercurial](https://cloud.githubusercontent.com/assets/1544760/7976090/b5908da6-0a76-11e5-8c91-452b6e73f631.gif) | Repository is a Mercurial repository -##### vi_mode +#### Language Segments -This segment shows ZSH's current input mode. Note that this is only useful if -you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html) -(VI mode). You can enable this either by `.zshrc` configuration or using a plugin, like -[Oh-My-Zsh's vi-mode plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh). +##### Javascript / Node.js Segments + +###### node_version + +This segment shows the _NodeJS_ version, that is currently active. | Variable | Default Value | Description | |----------|---------------|-------------| -|`P9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.| -|`P9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.| +|`POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY`|`false`|If `true` this segment only appears inside _NodeJS_ projects described by a `package.json`.| -To hide the segment entirely when in `INSERT` mode, set `P9K_VI_INSERT_MODE_STRING=''` +##### PHP Segments -#### Unit Test Ratios +##### symfony2_tests -The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" -classes vs test classes in your source code. This is just a very simple ratio, -and does not show your code coverage or any sophisticated stats. All this does -is count your source files and test files, and calculate the ratio between them. -Just enough to give you a quick overview about the test situation of the project -you are dealing with. +See [Unit Test Ratios](#unit-test-ratios), below. -### Disabling / Enabling Powerlevel9k +##### Python Segments -You can disable P9k and return to a very basic prompt at any time simply by -calling: +###### anaconda -```zsh -$ prompt_p9k_teardown -``` +This segment shows your active anaconda environment. It relies on either the +`CONDA_ENV_PATH` or the `CONDA_PREFIX` (depending on the `conda` version) +environment variable to be set which happens when you properly `source +activate` an environment. -You can then re-enable it by calling: +Special configuration variables: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| +|`P9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| + +Additionally the following segment specific parameters can be used to customize +it: `P9K_PYTHON_ICON`, `P9K_ANACONDA_BACKGROUND`, and +`P9K_ANACONDA_FOREGROUND`. + +##### Ruby Segments + +###### chruby + +###### rbenv + +This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. + +It figures out the version being used by taking the output of the `rbenv version-name` command. + +* If `rbenv` is not in $PATH, nothing will be shown. +* By default, if the current local Ruby version is the same as the global Ruby version, nothing will be shown. See the configuration variable, below, to modify this behavior. + +Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| + +###### rspec_stats + +See [Unit Test Ratios](#unit-test-ratios), below. + +#### Cloud Segments + +##### AWS Segments +###### aws + +If you would like to display the [current AWS +profile](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), add +the `aws` segment to one of the prompts, and define `AWS_DEFAULT_PROFILE` in +your `~/.zshrc`: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`AWS_DEFAULT_PROFILE`|None|Your AWS profile name| + + +#### Other + +##### custom_command + +The `custom_...` segment allows you to turn the output of a custom command into +a prompt segment. As an example, if you wanted to create a custom segment to +display your WiFi signal strength, you might define a custom segment called +`custom_wifi_signal` like this: ```zsh -$ prompt_powerlevel9k_setup +P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) +P9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" +P9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" +P9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" +``` +If you prefer, you can also define the function in your `.zshrc` rather than +putting it in-line with the variable export, as shown above. Just don't forget +to invoke your function from your segment! Example code that achieves the same +result as the above: +```zsh +zsh_wifi_signal(){ + local signal=$(nmcli device wifi | grep yes | awk '{print $8}') + local color='%F{yellow}' + [[ $signal -gt 75 ]] && color='%F{green}' + [[ $signal -lt 50 ]] && color='%F{red}' + echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is  +} + +P9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal" +P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) ``` +The command, above, gives you the wireless signal segment shown below: + +![signal](http://i.imgur.com/hviMATC.png) + +You can define as many custom segments as you wish. If you think you have +a segment that others would find useful, please consider upstreaming it to the +main theme distribution so that everyone can use it! + +##### command_execution_time + +Display the time the previous command took to execute if the time is above +`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be +"human readable", and so scales the units based on the length of execution time. +If you want more precision, just set the +`P9K_COMMAND_EXECUTION_TIME_PRECISION` field. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.| +|`P9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.| + +##### newline + +Puts a newline in your prompt so you can continue using segments on the next +line. This allows you to use segments on both lines, unlike +`P9K_PROMPT_ON_NEWLINE`, which simply separates segments from the +prompt itself. + +This only works on the left side. On the right side it does nothing. + +#### Unit Test Ratios + +The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" +classes vs test classes in your source code. This is just a very simple ratio, +and does not show your code coverage or any sophisticated stats. All this does +is count your source files and test files, and calculate the ratio between them. +Just enough to give you a quick overview about the test situation of the project +you are dealing with. ### tl; dr From 46f2ca74800009a49b009fa8ced768deacc16f93 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 1 Apr 2018 16:42:59 +0200 Subject: [PATCH 41/55] Fix error where Darwin is not recognized This was due to an incomplete rename of "OSX" to "macOS". --- functions/utilities.zsh | 6 +++--- segments/battery.p9k | 2 +- segments/os_icon.p9k | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 646c3bb27..11dfb77c3 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -17,7 +17,7 @@ # description # Determine the OS and version (if applicable). case $(uname) in - Darwin) OS='macOS' ;; + Darwin) OS='OSX' ;; CYGWIN_NT-*) OS='Windows' ;; FreeBSD|OpenBSD|DragonFly) OS='BSD' ;; Linux) @@ -43,7 +43,7 @@ elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then readonly TERMINAL="appleterm" else - if [[ "$OS" == "macOS" ]]; then + if [[ "$OS" == "OSX" ]]; then local termtest=$(ps -o 'command=' -p $(ps -o 'ppid=' -p $$) | tail -1 | awk '{print $NF}') # test if we are in a sudo su - if [[ $termtest == "-" || $termtest == "root" ]]; then @@ -240,7 +240,7 @@ function getRelevantItem() { # `sed` is unfortunately not consistent across OSes when it comes to flags. ## SED_EXTENDED_REGEX_PARAMETER="-r" -if [[ "$OS" == 'macOS' ]]; then +if [[ "$OS" == 'OSX' ]]; then local IS_BSD_SED="$(sed --version &>> /dev/null || echo "BSD sed")" if [[ -n "$IS_BSD_SED" ]]; then SED_EXTENDED_REGEX_PARAMETER="-E" diff --git a/segments/battery.p9k b/segments/battery.p9k index 09995f734..9aeaff990 100644 --- a/segments/battery.p9k +++ b/segments/battery.p9k @@ -38,7 +38,7 @@ prompt_battery() { # Set default values if the user did not configure them setDefault P9K_BATTERY_LOW_THRESHOLD 10 - if [[ $OS =~ macOS && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then + if [[ $OS =~ "OSX" && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then # obtain battery information from system local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" # return if there is no battery on system diff --git a/segments/os_icon.p9k b/segments/os_icon.p9k index d7833231c..353cecb47 100644 --- a/segments/os_icon.p9k +++ b/segments/os_icon.p9k @@ -14,7 +14,7 @@ # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont case "$OS" in - "macOS") + "OSX") #     registerIcon "APPLE_ICON" 'OSX' $'\uE26E' $'\uF179' '\u'$CODEPOINT_OF_AWESOME_APPLE $'\uF179' OS_ICON='APPLE_ICON' From b4af8efdaf0526639aa1023371492f3d049c1055 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 2 Apr 2018 09:15:42 +0400 Subject: [PATCH 42/55] Minor README.md update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa182cbd2..5a7e5295b 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ Customizations available are: |`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `P9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| |`truncate_with_folder_marker`|Search for a file that is specified by `P9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| -For example, if you wanted the truncation behavior of the `fish` shell, which +For example, if you wanted the truncation behavior similar to the `fish` shell, which truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: ```zsh P9K_SHORTEN_DIR_LENGTH=1 From 1923839069513be8f405351c395f19281ed2c032 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 3 Apr 2018 16:24:35 +0400 Subject: [PATCH 43/55] Updated CHANGELOG.md to reflect changes Used version 0.7.0 for the version number as there are numerous major changes in this release. --- CHANGELOG.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8842a3c..13568634b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,50 @@ +## v0.7.0 +- Moved all environment variables from `POWERLEVEL9K_` to `P9K_` +- `utilities.zsh` + - Added OS detection logic to allow use of `$OS` in segments. + - Added OS version detection logic for Linux to allow use of `$OS_ID` in segments. + - Added Terminal detection logic to allow use of `$TERMINAL` in segments. + - Added function `updateEnvironmentVars()` to automatically change user variables for backward compatibility. NOTE: There may be minor issues with arrays, so this still needs review. +- `icons.zsh` + - Only core icons are registered by default. + - Each segment is responsible to register its own icons. +- Moved all segments to their own files under `segments`. + - Segments now use `serializeSegment()` instead of `$1_prompt_segment()`. + - Only segments in use are dynamically loaded (including their icons). + - The autoloader checks if a file exists before calling it to catch any errors. For `custom_prompt` segments, it checks if it is a variable/definition before checking for a file. + - Custom segment files have to be placed in `segments/custom` directory, and have to follow the naming convention. + - Segment file should be named `segment_name.p9k`. + - Segment definition should be `prompt_custom_segment_name()`. +- Moved prompt generators to their own files under `generator`. + - `default.p9k` is the default (current) generator. + - `zsh-async` has been included but is still experimental. To use, set `POWERLEVEL9K_GENERATOR="zsh-async"` in `powerlevel9k.zsh`. +- Segments and generators use the `*.p9k` extention to ensure that they don't conflict with similarly names `*.zsh` scripts. +- Segment updates + - `vi_mode.p9k` + - Rewrote to support both `default` and `zsh-async` generators. + - Added support to change cursor shape. + - To enable cursor shape change, set `POWERLEVEL9K_CURSOR_SHAPE=true`. On supported terminals, cursor shape can be `box` [], `hbar` _ or `vbar` |. + - Changed `zle reset-prompt` to `zle .reset-prompt`. + - `prompt_php_version` - Added support for icon. + - `rspec_stats` / `symfony2_test` - Both segments call `test_stats.p9k` (which also initializes the icon). + - `prompt_java_version` added and `README.md` updated. +- `README.md` + - Added missing items and links to the index. + - Rearranged the content to match the index. +- API created! + - Added `API` folder. This contains all the Markdown documentation generated from the function description comments (using `sh2md`) for all of the `*.p9k` files. +- Internal changes: + - All comments have been updated for uniformity and for API generation. + - iTerm integration added. + - Added `POWERLEVEL9K_PROMPT_SEGMENTS` to allow testing for segment usage in a single variable. + - Replaced `$1_prompt_segment()` with `serializeSegment()` to enable single call from segments irrespective of generator. + - Changed all internal functions to use `camelCase`. Exceptions are listed below: + - prompt functions still use `prompt_x()` so that we can differentiate between internal (core) functionality and segments. + - `prompt_powerlevel9k_setup()`, `prompt_powerlevel9k_teardown()`, and `p9k_preexec()`. + - `default.p9k` + - Added support for bold segments (already in `zsh-async`). + - Added support for the right segment icons to be shown on the left instead (already in `zsh-async`). + ## v0.6.4 - `load` segment now has configurable averages. From 9257a664c6bfc91649d4bf6d385699c98a791557 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 7 Apr 2018 16:39:38 +0400 Subject: [PATCH 44/55] Updated misspelled name for Dominik Ritter --- api/functions/colors.md | 2 +- api/functions/icons.md | 2 +- api/functions/utilities.md | 2 +- api/generator/default.md | 2 +- api/generator/zsh-async.md | 2 +- api/segments/anaconda.md | 2 +- api/segments/aws.md | 2 +- api/segments/aws_eb_env.md | 2 +- api/segments/background_jobs.md | 2 +- api/segments/battery.md | 2 +- api/segments/chruby.md | 2 +- api/segments/command_execution_time.md | 2 +- api/segments/context.md | 2 +- api/segments/date.md | 2 +- api/segments/detect_virt.md | 2 +- api/segments/dir.md | 2 +- api/segments/dir_writable.md | 2 +- api/segments/disk_usage.md | 2 +- api/segments/docker_machine.md | 2 +- api/segments/dropbox.md | 2 +- api/segments/go_version.md | 2 +- api/segments/history.md | 2 +- api/segments/host.md | 2 +- api/segments/icons_test.md | 2 +- api/segments/ip.md | 2 +- api/segments/java_version.md | 2 +- api/segments/kubecontext.md | 2 +- api/segments/load.md | 2 +- api/segments/newline.md | 2 +- api/segments/node_env.md | 2 +- api/segments/node_version.md | 2 +- api/segments/nvm.md | 2 +- api/segments/openfoam.md | 2 +- api/segments/os_icon.md | 2 +- api/segments/php_version.md | 2 +- api/segments/public_ip.md | 2 +- api/segments/pyenv.md | 2 +- api/segments/ram.md | 2 +- api/segments/rbenv.md | 2 +- api/segments/root_indicator.md | 2 +- api/segments/rspec_stats.md | 2 +- api/segments/rust_version.md | 2 +- api/segments/rvm.md | 2 +- api/segments/ssh.md | 2 +- api/segments/status.md | 2 +- api/segments/swap.md | 2 +- api/segments/swift_version.md | 2 +- api/segments/symfony2_tests.md | 2 +- api/segments/symfony2_version.md | 2 +- api/segments/test_stats.md | 2 +- api/segments/time.md | 2 +- api/segments/todo.md | 2 +- api/segments/user.md | 2 +- api/segments/vcs.md | 2 +- api/segments/vi_mode.md | 2 +- api/segments/virtualenv.md | 2 +- api/segments/vpn_ip.md | 2 +- functions/colors.zsh | 2 +- functions/icons.zsh | 2 +- functions/utilities.zsh | 2 +- generator/default.p9k | 2 +- generator/zsh-async.p9k | 2 +- powerlevel9k.zsh-theme | 2 +- segments/anaconda.p9k | 2 +- segments/aws.p9k | 2 +- segments/aws_eb_env.p9k | 2 +- segments/background_jobs.p9k | 2 +- segments/battery.p9k | 2 +- segments/chruby.p9k | 2 +- segments/command_execution_time.p9k | 2 +- segments/context.p9k | 2 +- segments/date.p9k | 2 +- segments/detect_virt.p9k | 2 +- segments/dir.p9k | 2 +- segments/dir_writable.p9k | 2 +- segments/disk_usage.p9k | 2 +- segments/docker_machine.p9k | 2 +- segments/dropbox.p9k | 2 +- segments/go_version.p9k | 2 +- segments/history.p9k | 2 +- segments/host.p9k | 2 +- segments/icons_test.p9k | 2 +- segments/ip.p9k | 2 +- segments/java_version.p9k | 2 +- segments/kubecontext.p9k | 2 +- segments/load.p9k | 2 +- segments/newline.p9k | 2 +- segments/node_env.p9k | 2 +- segments/node_version.p9k | 2 +- segments/nvm.p9k | 2 +- segments/openfoam.p9k | 2 +- segments/os_icon.p9k | 2 +- segments/php_version.p9k | 2 +- segments/public_ip.p9k | 2 +- segments/pyenv.p9k | 2 +- segments/ram.p9k | 2 +- segments/rbenv.p9k | 2 +- segments/root_indicator.p9k | 2 +- segments/rspec_stats.p9k | 2 +- segments/rust_version.p9k | 2 +- segments/rvm.p9k | 2 +- segments/ssh.p9k | 2 +- segments/status.p9k | 2 +- segments/swap.p9k | 2 +- segments/swift_version.p9k | 2 +- segments/symfony2_tests.p9k | 2 +- segments/symfony2_version.p9k | 2 +- segments/test_stats.p9k | 2 +- segments/time.p9k | 2 +- segments/todo.p9k | 2 +- segments/user.p9k | 2 +- segments/vcs.p9k | 2 +- segments/vi_mode.p9k | 2 +- segments/virtualenv.p9k | 2 +- segments/vpn_ip.p9k | 2 +- 115 files changed, 115 insertions(+), 115 deletions(-) diff --git a/api/functions/colors.md b/api/functions/colors.md index 8dbe2aeb0..39d4b77ce 100644 --- a/api/functions/colors.md +++ b/api/functions/colors.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ### File Description diff --git a/api/functions/icons.md b/api/functions/icons.md index f83ab927c..e7d9c3018 100644 --- a/api/functions/icons.md +++ b/api/functions/icons.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ### File Description diff --git a/api/functions/utilities.md b/api/functions/utilities.md index 07b5a8550..2a290033c 100644 --- a/api/functions/utilities.md +++ b/api/functions/utilities.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ### File Description diff --git a/api/generator/default.md b/api/generator/default.md index c06f93e90..162d3ae3a 100644 --- a/api/generator/default.md +++ b/api/generator/default.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ### File Description diff --git a/api/generator/zsh-async.md b/api/generator/zsh-async.md index 963bc4768..4212ac101 100644 --- a/api/generator/zsh-async.md +++ b/api/generator/zsh-async.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) - Christo Kotze (onaforeignshore) diff --git a/api/segments/anaconda.md b/api/segments/anaconda.md index 48f03fa6e..66b599155 100644 --- a/api/segments/anaconda.md +++ b/api/segments/anaconda.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/aws.md b/api/segments/aws.md index 001ef97e9..eee82cb0d 100644 --- a/api/segments/aws.md +++ b/api/segments/aws.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/aws_eb_env.md b/api/segments/aws_eb_env.md index 843f0ba95..d916842d9 100644 --- a/api/segments/aws_eb_env.md +++ b/api/segments/aws_eb_env.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/background_jobs.md b/api/segments/background_jobs.md index d41db7482..8e4452042 100644 --- a/api/segments/background_jobs.md +++ b/api/segments/background_jobs.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/battery.md b/api/segments/battery.md index 5f0e3185e..15ccdab99 100644 --- a/api/segments/battery.md +++ b/api/segments/battery.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/chruby.md b/api/segments/chruby.md index 3abe33a58..df818bccc 100644 --- a/api/segments/chruby.md +++ b/api/segments/chruby.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/command_execution_time.md b/api/segments/command_execution_time.md index d86600a39..ffff262f0 100644 --- a/api/segments/command_execution_time.md +++ b/api/segments/command_execution_time.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/context.md b/api/segments/context.md index c57d718d4..59cda4885 100644 --- a/api/segments/context.md +++ b/api/segments/context.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/date.md b/api/segments/date.md index c98d3fefe..34c98b9ca 100644 --- a/api/segments/date.md +++ b/api/segments/date.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/detect_virt.md b/api/segments/detect_virt.md index b5d9420a3..b5fd119a8 100644 --- a/api/segments/detect_virt.md +++ b/api/segments/detect_virt.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/dir.md b/api/segments/dir.md index f8047eaa0..93e108577 100644 --- a/api/segments/dir.md +++ b/api/segments/dir.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/dir_writable.md b/api/segments/dir_writable.md index 85228104a..23eef7a21 100644 --- a/api/segments/dir_writable.md +++ b/api/segments/dir_writable.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/disk_usage.md b/api/segments/disk_usage.md index 2953c29a9..da225ca73 100644 --- a/api/segments/disk_usage.md +++ b/api/segments/disk_usage.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/docker_machine.md b/api/segments/docker_machine.md index d784f5698..226e54073 100644 --- a/api/segments/docker_machine.md +++ b/api/segments/docker_machine.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/dropbox.md b/api/segments/dropbox.md index d2edb5b0f..607209529 100644 --- a/api/segments/dropbox.md +++ b/api/segments/dropbox.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/go_version.md b/api/segments/go_version.md index 6f2a7b543..e5fdec9f6 100644 --- a/api/segments/go_version.md +++ b/api/segments/go_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/history.md b/api/segments/history.md index 5ed997fcd..80a22441d 100644 --- a/api/segments/history.md +++ b/api/segments/history.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/host.md b/api/segments/host.md index 6eb362207..a4602c194 100644 --- a/api/segments/host.md +++ b/api/segments/host.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/icons_test.md b/api/segments/icons_test.md index d74994a45..ccb051a3a 100644 --- a/api/segments/icons_test.md +++ b/api/segments/icons_test.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/ip.md b/api/segments/ip.md index bb85a7985..30e394e46 100644 --- a/api/segments/ip.md +++ b/api/segments/ip.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/java_version.md b/api/segments/java_version.md index e30c81eed..59da365bd 100644 --- a/api/segments/java_version.md +++ b/api/segments/java_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/kubecontext.md b/api/segments/kubecontext.md index 243cc4b50..25317f9e2 100644 --- a/api/segments/kubecontext.md +++ b/api/segments/kubecontext.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/load.md b/api/segments/load.md index de20cf1da..4b85991f2 100644 --- a/api/segments/load.md +++ b/api/segments/load.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/newline.md b/api/segments/newline.md index 24e911214..3c9a0baef 100644 --- a/api/segments/newline.md +++ b/api/segments/newline.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/node_env.md b/api/segments/node_env.md index 9521775f8..643155061 100644 --- a/api/segments/node_env.md +++ b/api/segments/node_env.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/node_version.md b/api/segments/node_version.md index fdcbc70cb..6812b00c3 100644 --- a/api/segments/node_version.md +++ b/api/segments/node_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/nvm.md b/api/segments/nvm.md index ec3b98341..fe5a64ab4 100644 --- a/api/segments/nvm.md +++ b/api/segments/nvm.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/openfoam.md b/api/segments/openfoam.md index bd550bc63..1d5b8b6b5 100644 --- a/api/segments/openfoam.md +++ b/api/segments/openfoam.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/os_icon.md b/api/segments/os_icon.md index 834d600ac..930ca9017 100644 --- a/api/segments/os_icon.md +++ b/api/segments/os_icon.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/php_version.md b/api/segments/php_version.md index a1821d3f9..c4627fc91 100644 --- a/api/segments/php_version.md +++ b/api/segments/php_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/public_ip.md b/api/segments/public_ip.md index db9ea3f67..69884ed04 100644 --- a/api/segments/public_ip.md +++ b/api/segments/public_ip.md @@ -9,6 +9,6 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) diff --git a/api/segments/pyenv.md b/api/segments/pyenv.md index 6859fe382..ca001d01f 100644 --- a/api/segments/pyenv.md +++ b/api/segments/pyenv.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/ram.md b/api/segments/ram.md index ad6d71227..416e8b66f 100644 --- a/api/segments/ram.md +++ b/api/segments/ram.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/rbenv.md b/api/segments/rbenv.md index 8c28be529..16c335ec4 100644 --- a/api/segments/rbenv.md +++ b/api/segments/rbenv.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/root_indicator.md b/api/segments/root_indicator.md index 9d1c1abca..6c5779d32 100644 --- a/api/segments/root_indicator.md +++ b/api/segments/root_indicator.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/rspec_stats.md b/api/segments/rspec_stats.md index 1e272ba54..eb4675598 100644 --- a/api/segments/rspec_stats.md +++ b/api/segments/rspec_stats.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/rust_version.md b/api/segments/rust_version.md index 21344a8af..49bd96fb4 100644 --- a/api/segments/rust_version.md +++ b/api/segments/rust_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/rvm.md b/api/segments/rvm.md index fd2f6647f..e6d92b273 100644 --- a/api/segments/rvm.md +++ b/api/segments/rvm.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/ssh.md b/api/segments/ssh.md index 18805f332..214d807e2 100644 --- a/api/segments/ssh.md +++ b/api/segments/ssh.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/status.md b/api/segments/status.md index d88642d70..415a16643 100644 --- a/api/segments/status.md +++ b/api/segments/status.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/swap.md b/api/segments/swap.md index 7b1deee94..64ba43630 100644 --- a/api/segments/swap.md +++ b/api/segments/swap.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/swift_version.md b/api/segments/swift_version.md index 2670caaa7..2073ee2b8 100644 --- a/api/segments/swift_version.md +++ b/api/segments/swift_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/symfony2_tests.md b/api/segments/symfony2_tests.md index ad580f736..2b1083f34 100644 --- a/api/segments/symfony2_tests.md +++ b/api/segments/symfony2_tests.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/symfony2_version.md b/api/segments/symfony2_version.md index 9d1258d65..d8675c38d 100644 --- a/api/segments/symfony2_version.md +++ b/api/segments/symfony2_version.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/test_stats.md b/api/segments/test_stats.md index ed05532e6..f89e600a6 100644 --- a/api/segments/test_stats.md +++ b/api/segments/test_stats.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/time.md b/api/segments/time.md index e40c900d9..7168127d8 100644 --- a/api/segments/time.md +++ b/api/segments/time.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/todo.md b/api/segments/todo.md index 2bed80543..885416e67 100644 --- a/api/segments/todo.md +++ b/api/segments/todo.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/user.md b/api/segments/user.md index 34ed01d9f..92f331083 100644 --- a/api/segments/user.md +++ b/api/segments/user.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/vcs.md b/api/segments/vcs.md index 870b72ae0..53f60a41c 100644 --- a/api/segments/vcs.md +++ b/api/segments/vcs.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/vi_mode.md b/api/segments/vi_mode.md index 944b5726c..2ef95b14d 100644 --- a/api/segments/vi_mode.md +++ b/api/segments/vi_mode.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/virtualenv.md b/api/segments/virtualenv.md index 5f8f77cba..1c1e988fd 100644 --- a/api/segments/virtualenv.md +++ b/api/segments/virtualenv.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/api/segments/vpn_ip.md b/api/segments/vpn_ip.md index b8caea10e..aecbfa39f 100644 --- a/api/segments/vpn_ip.md +++ b/api/segments/vpn_ip.md @@ -9,7 +9,7 @@ ### Author(s) - Ben Hilburn (bhilburn) -- Dominic Ritter (dritter) +- Dominik Ritter (dritter) ## Table of Contents diff --git a/functions/colors.zsh b/functions/colors.zsh index 3cd57cb58..b2b55cb62 100755 --- a/functions/colors.zsh +++ b/functions/colors.zsh @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # @info # This file contains some color-functions for powerlevel9k. diff --git a/functions/icons.zsh b/functions/icons.zsh index 5ad122456..ea22a3371 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # @info # This file contains some the core icon definitions and diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 11dfb77c3..cab27ab5f 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # @info # This file contains some utility-functions for diff --git a/generator/default.p9k b/generator/default.p9k index b150d75a2..6d6e85951 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # @info # This file contains the default generator for the powerlevel9k project. diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index 0c8107c0a..a614d9776 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) # Christo Kotze (onaforeignshore) ## # @dependency diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f037ca2ab..1b37e2356 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn -# Dominic Ritter +# Dominik Ritter ## # @info # This theme was inspired by [agnoster's Theme](https://gist.github.com/3712874) diff --git a/segments/anaconda.p9k b/segments/anaconda.p9k index 8611b93a5..06159b3f4 100644 --- a/segments/anaconda.p9k +++ b/segments/anaconda.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/aws.p9k b/segments/aws.p9k index cd9c1342b..0ecbcf0f5 100644 --- a/segments/aws.p9k +++ b/segments/aws.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/aws_eb_env.p9k b/segments/aws_eb_env.p9k index 0fc0fbe7e..12b865d8c 100644 --- a/segments/aws_eb_env.p9k +++ b/segments/aws_eb_env.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/background_jobs.p9k b/segments/background_jobs.p9k index 7cfac6497..06095506f 100644 --- a/segments/background_jobs.p9k +++ b/segments/background_jobs.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # Register icons diff --git a/segments/battery.p9k b/segments/battery.p9k index 9aeaff990..186f819f8 100644 --- a/segments/battery.p9k +++ b/segments/battery.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/chruby.p9k b/segments/chruby.p9k index 681cae620..09a8c3a26 100644 --- a/segments/chruby.p9k +++ b/segments/chruby.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/command_execution_time.p9k b/segments/command_execution_time.p9k index 59cc6e35d..fe550b89c 100644 --- a/segments/command_execution_time.p9k +++ b/segments/command_execution_time.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/context.p9k b/segments/context.p9k index 08642dcc0..4cefd44cb 100644 --- a/segments/context.p9k +++ b/segments/context.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## setDefault P9K_ALWAYS_SHOW_CONTEXT false diff --git a/segments/date.p9k b/segments/date.p9k index 7fe536d93..946110e14 100644 --- a/segments/date.p9k +++ b/segments/date.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/detect_virt.p9k b/segments/detect_virt.p9k index ffe21ab1e..2847a2668 100644 --- a/segments/detect_virt.p9k +++ b/segments/detect_virt.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/dir.p9k b/segments/dir.p9k index e067a7ee2..ee693b36b 100644 --- a/segments/dir.p9k +++ b/segments/dir.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/dir_writable.p9k b/segments/dir_writable.p9k index bdee0fa00..7b97785c3 100644 --- a/segments/dir_writable.p9k +++ b/segments/dir_writable.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/disk_usage.p9k b/segments/disk_usage.p9k index bb2c5e34f..b14edf012 100644 --- a/segments/disk_usage.p9k +++ b/segments/disk_usage.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/docker_machine.p9k b/segments/docker_machine.p9k index 9ee5d7d96..b5f5f4a94 100644 --- a/segments/docker_machine.p9k +++ b/segments/docker_machine.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/dropbox.p9k b/segments/dropbox.p9k index 5bb30c06e..5a7640d40 100644 --- a/segments/dropbox.p9k +++ b/segments/dropbox.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/go_version.p9k b/segments/go_version.p9k index a87b14bdd..3d044e765 100644 --- a/segments/go_version.p9k +++ b/segments/go_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/history.p9k b/segments/history.p9k index 416639d68..41372ff09 100644 --- a/segments/history.p9k +++ b/segments/history.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/host.p9k b/segments/host.p9k index 129741cf3..a9049840d 100644 --- a/segments/host.p9k +++ b/segments/host.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/icons_test.p9k b/segments/icons_test.p9k index add8f4a8f..901fb5da7 100644 --- a/segments/icons_test.p9k +++ b/segments/icons_test.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/ip.p9k b/segments/ip.p9k index b1886bd1d..7a9519c06 100644 --- a/segments/ip.p9k +++ b/segments/ip.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/java_version.p9k b/segments/java_version.p9k index 2c441985b..3dbaa0da9 100644 --- a/segments/java_version.p9k +++ b/segments/java_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/kubecontext.p9k b/segments/kubecontext.p9k index 61edf5b46..4051a183b 100644 --- a/segments/kubecontext.p9k +++ b/segments/kubecontext.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/load.p9k b/segments/load.p9k index f31d5d0a5..5d989d1f3 100644 --- a/segments/load.p9k +++ b/segments/load.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/newline.p9k b/segments/newline.p9k index 2962859e9..a128c8e68 100644 --- a/segments/newline.p9k +++ b/segments/newline.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/node_env.p9k b/segments/node_env.p9k index 9a35bb742..69ff9a331 100644 --- a/segments/node_env.p9k +++ b/segments/node_env.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/node_version.p9k b/segments/node_version.p9k index 0011a7fbd..81456a072 100644 --- a/segments/node_version.p9k +++ b/segments/node_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/nvm.p9k b/segments/nvm.p9k index c4783496e..61895b9e2 100644 --- a/segments/nvm.p9k +++ b/segments/nvm.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/openfoam.p9k b/segments/openfoam.p9k index ede0019bc..051e3e1df 100644 --- a/segments/openfoam.p9k +++ b/segments/openfoam.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/os_icon.p9k b/segments/os_icon.p9k index 353cecb47..b1e589699 100644 --- a/segments/os_icon.p9k +++ b/segments/os_icon.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/php_version.p9k b/segments/php_version.p9k index 375c2e31c..81dec766c 100644 --- a/segments/php_version.p9k +++ b/segments/php_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/public_ip.p9k b/segments/public_ip.p9k index ffc88508e..ad5077af2 100644 --- a/segments/public_ip.p9k +++ b/segments/public_ip.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/pyenv.p9k b/segments/pyenv.p9k index 0c90f9ce6..023711265 100644 --- a/segments/pyenv.p9k +++ b/segments/pyenv.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/ram.p9k b/segments/ram.p9k index 8446eedca..5ba75a420 100644 --- a/segments/ram.p9k +++ b/segments/ram.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/rbenv.p9k b/segments/rbenv.p9k index 00d2166a8..40fb3a23f 100644 --- a/segments/rbenv.p9k +++ b/segments/rbenv.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/root_indicator.p9k b/segments/root_indicator.p9k index badd39042..f47eed905 100644 --- a/segments/root_indicator.p9k +++ b/segments/root_indicator.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/rspec_stats.p9k b/segments/rspec_stats.p9k index eda3f33a7..53881aebd 100644 --- a/segments/rspec_stats.p9k +++ b/segments/rspec_stats.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # Source test stats script & icons diff --git a/segments/rust_version.p9k b/segments/rust_version.p9k index 5a7623565..4eccaafc5 100644 --- a/segments/rust_version.p9k +++ b/segments/rust_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/rvm.p9k b/segments/rvm.p9k index 9de67c2c9..ee9d881c4 100644 --- a/segments/rvm.p9k +++ b/segments/rvm.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/ssh.p9k b/segments/ssh.p9k index 5b9c7d585..7e3fa5942 100644 --- a/segments/ssh.p9k +++ b/segments/ssh.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/status.p9k b/segments/status.p9k index d02fec693..eacf159a0 100644 --- a/segments/status.p9k +++ b/segments/status.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/swap.p9k b/segments/swap.p9k index 6c6e224a2..de32e3d05 100644 --- a/segments/swap.p9k +++ b/segments/swap.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/swift_version.p9k b/segments/swift_version.p9k index 237abb2d5..d71201109 100644 --- a/segments/swift_version.p9k +++ b/segments/swift_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/symfony2_tests.p9k b/segments/symfony2_tests.p9k index 73331ac6a..aa41a5f10 100644 --- a/segments/symfony2_tests.p9k +++ b/segments/symfony2_tests.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## # Source test stats script & icons diff --git a/segments/symfony2_version.p9k b/segments/symfony2_version.p9k index 99197bf33..648e32cce 100644 --- a/segments/symfony2_version.p9k +++ b/segments/symfony2_version.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/test_stats.p9k b/segments/test_stats.p9k index 4d659bed6..c2f2cea6a 100644 --- a/segments/test_stats.p9k +++ b/segments/test_stats.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/time.p9k b/segments/time.p9k index d61cd077d..8aa4a65b5 100644 --- a/segments/time.p9k +++ b/segments/time.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/todo.p9k b/segments/todo.p9k index 51bb0bd8b..37901ce71 100644 --- a/segments/todo.p9k +++ b/segments/todo.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/user.p9k b/segments/user.p9k index 52b1d1771..03c0d3db2 100644 --- a/segments/user.p9k +++ b/segments/user.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/vcs.p9k b/segments/vcs.p9k index e7d4dab36..b0002c474 100644 --- a/segments/vcs.p9k +++ b/segments/vcs.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/vi_mode.p9k b/segments/vi_mode.p9k index 426507754..a9080b9ea 100644 --- a/segments/vi_mode.p9k +++ b/segments/vi_mode.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## setDefault "P9K_VI_INSERT_MODE_STRING" "INSERT" diff --git a/segments/virtualenv.p9k b/segments/virtualenv.p9k index 5d0bd3c61..fe8035860 100644 --- a/segments/virtualenv.p9k +++ b/segments/virtualenv.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ diff --git a/segments/vpn_ip.p9k b/segments/vpn_ip.p9k index b3457e27c..acaa150da 100644 --- a/segments/vpn_ip.p9k +++ b/segments/vpn_ip.p9k @@ -6,7 +6,7 @@ ## # @authors # Ben Hilburn (bhilburn) -# Dominic Ritter (dritter) +# Dominik Ritter (dritter) ## ################################################################ From 7effa89d4eae6d4231bfb4bf52125a29725276c4 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 16 Apr 2018 20:19:59 +0400 Subject: [PATCH 45/55] Merged - Fix wrapper slowness in vcs segment #797 --- functions/vcs.zsh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index a3ae6a07b..9b8b0c1aa 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -25,8 +25,8 @@ function +vi-git-untracked() { FLAGS+='--ignore-submodules=dirty' fi - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ - -n $(git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then + if [[ $(command git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ + -n $(command git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then hook_com[unstaged]+=" $(printIcon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true else @@ -38,16 +38,16 @@ function +vi-git-aheadbehind() { local ahead behind branch_name local -a gitstatus - branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) # for git prior to 1.7 - # ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) - ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) + # ahead=$(command git rev-list origin/${branch_name}..HEAD | wc -l) + ahead=$(command git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) (( ahead )) && gitstatus+=( " $(printIcon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) # for git prior to 1.7 - # behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) - behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) + # behind=$(command git rev-list HEAD..origin/${branch_name} | wc -l) + behind=$(command git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) (( behind )) && gitstatus+=( " $(printIcon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) hook_com[misc]+=${(j::)gitstatus} @@ -57,8 +57,8 @@ function +vi-git-remotebranch() { local remote branch_name # Are we on a remote-tracking branch? - remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} - branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} + branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) hook_com[branch]="$(printIcon 'VCS_BRANCH_ICON')${hook_com[branch]}" # Always show the remote @@ -74,18 +74,18 @@ function +vi-git-tagname() { if [[ "$P9K_VCS_HIDE_TAGS" == "false" ]]; then # If we are on a tag, append the tagname to the current branch string. local tag - tag=$(git describe --tags --exact-match HEAD 2>/dev/null) + tag=$(command git describe --tags --exact-match HEAD 2>/dev/null) if [[ -n "${tag}" ]] ; then # There is a tag that points to our current commit. Need to determine if we # are also on a branch, or are in a DETACHED_HEAD state. - if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then + if [[ -z $(command git symbolic-ref HEAD 2>/dev/null) ]]; then # DETACHED_HEAD state. We want to append the tag name to the commit hash # and print it. Unfortunately, `vcs_info` blows away the hash when a tag # exists, so we have to manually retrieve it and clobber the branch # string. local revision - revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${P9K_VCS_INTERNAL_HASH_LENGTH} HEAD) + revision=$(command git rev-list -n 1 --abbrev-commit --abbrev=${P9K_VCS_INTERNAL_HASH_LENGTH} HEAD) hook_com[branch]="$(printIcon 'VCS_BRANCH_ICON')${revision} $(printIcon 'VCS_TAG_ICON')${tag}" else # We are on both a tag and a branch; print both by appending the tag name. @@ -100,8 +100,8 @@ function +vi-git-tagname() { function +vi-git-stash() { local -a stashes - if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then - stashes=$(git stash list 2>/dev/null | wc -l) + if [[ -s $(command git rev-parse --git-dir)/refs/stash ]] ; then + stashes=$(command git stash list 2>/dev/null | wc -l) hook_com[misc]+=" $(printIcon 'VCS_STASH_ICON')${stashes// /}" fi } @@ -120,7 +120,7 @@ function +vi-hg-bookmarks() { function +vi-vcs-detect-changes() { if [[ "${hook_com[vcs]}" == "git" ]]; then - local remote=$(git ls-remote --get-url 2> /dev/null) + local remote=$(command git ls-remote --get-url 2> /dev/null) if [[ "$remote" =~ "github" ]] then vcs_visual_identifier='VCS_GIT_GITHUB_ICON' elif [[ "$remote" =~ "bitbucket" ]] then From 5cc19c5369bef034af0b3318d0df59e0568476a8 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 16 Apr 2018 20:30:13 +0400 Subject: [PATCH 46/55] Merged - Add vcs branch name truncating. #798 --- README.md | 22 ++++++++++++ functions/vcs.zsh | 15 ++++++++ test/segments/vcs.spec | 80 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/README.md b/README.md index 5a7e5295b..bddd22939 100644 --- a/README.md +++ b/README.md @@ -549,6 +549,28 @@ customization is provided via: |`P9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| |`P9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| +You can limit the branch name to a certain length by truncating long names. +Customizations available are: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`P9K_VCS_SHORTEN_LENGTH`|None|This field determines how many characters to show.| +|`P9K_VCS_SHORTEN_MIN_LENGTH`|None|This field determines minimum branch length. Branch name will be truncated if its length greater than this field.| +|`P9K_VCS_SHORTEN_STRATEGY`|None|This field determines how branch name should be truncated. See the table below for more information.| +|`PK_SHORTEN_DELIMITER`|`...`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.| + +| Strategy Name | Description | +|---------------|-------------| +|`truncate_middle`|Truncates the middle part of a branch. E.g. branch name is `1234-super_super_long_branch_name`, then it will truncated to `1234-..._name`, if `POWERLEVEL9K_VCS_SHORTEN_LENGTH=5` is also set (controls the amount of characters to be left).| +|`truncate_from_right`|Just leaves the beginning of a branch name untouched. E.g. branch name will be truncated like so: `1234-...`. How many characters will be untouched is controlled by `POWERLEVEL9K_VCS_SHORTEN_LENGTH`.| + +For example, if you want to truncate `1234-super_super_long_branch_name` to `1234-..` and don't do it with `development`: +```zsh +POWERLEVEL9K_VCS_SHORTEN_LENGTH=4 +POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11 +POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" +POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".." +``` ###### vcs symbols diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 9b8b0c1aa..1319e1818 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -60,6 +60,21 @@ function +vi-git-remotebranch() { remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) + if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then + set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' + + if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then + case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in + truncate_middle) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")" + ;; + truncate_from_right) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER" + ;; + esac + fi + fi + hook_com[branch]="$(printIcon 'VCS_BRANCH_ICON')${hook_com[branch]}" # Always show the remote #if [[ -n ${remote} ]] ; then diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index 652a9148f..0482890c8 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -78,4 +78,84 @@ function testColorOverridingForUntrackedStateWorks() { unset P9K_VCS_UNTRACKED_BACKGROUND } +function testBranchNameTruncatingShortenLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingMinLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7 + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingShortenStrategy() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle" + + assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + source shunit2/source/2.1/src/shunit2 From 1b63a926ad49996241deb4ad28724ede5859b660 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 16 Apr 2018 20:34:45 +0400 Subject: [PATCH 47/55] Updated test/vcs.spec to use buildLeftPrompt --- test/segments/vcs.spec | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index 0482890c8..fdc943b64 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -90,10 +90,10 @@ function testBranchNameTruncatingShortenLength() { git init 1>/dev/null touch testfile - assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 - assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test @@ -116,11 +116,11 @@ function testBranchNameTruncatingMinLength() { git init 1>/dev/null touch testfile - assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7 - assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test @@ -143,11 +143,11 @@ function testBranchNameTruncatingShortenStrategy() { git init 1>/dev/null touch testfile - assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(buildLeftPrompt)" POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle" - assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test From 2a62bb1ea265217581311edf5cab2f91fb041171 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 16 Apr 2018 20:39:26 +0400 Subject: [PATCH 48/55] README.md - add rvm #799 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bddd22939..65d7369da 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ The available segments are: * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). * [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec. + * `rvm` - Ruby environment information using `$GEM_HOME` and `$MY_RUBY_HOME` (if one is active). * **Rust Segments:** * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** From e4ffa3e8ea65ab67f4ba604f2cfe4dcc79dff81b Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Mon, 16 Apr 2018 20:44:43 +0400 Subject: [PATCH 49/55] Updated functions/vcs.zsh - setDefault --- functions/vcs.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 1319e1818..6853b886a 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -61,7 +61,7 @@ function +vi-git-remotebranch() { branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then - set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' + setDefault POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in From f2c85dd84b080836624a0c169357427e035b3b11 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 18 Apr 2018 18:41:18 +0400 Subject: [PATCH 50/55] functions/vcs.zsh - fixed P9K_ environment vars. --- README.md | 6 ++++++ functions/vcs.zsh | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 65d7369da..07075dd2f 100644 --- a/README.md +++ b/README.md @@ -752,3 +752,9 @@ information!](https://github.com/bhilburn/powerlevel9k/wiki) Project: MIT Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo + +#### zsh-async + +P9k uses the [zsh-async](https://github.com/mafredri/zsh-async) project. It is +located in the `zsh-async/` directory as a subtree, and carries its own +LICENSE` file. It is `Copyright (c) 2015 Mathias Fredriksson `. diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 6853b886a..08376540e 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -60,16 +60,16 @@ function +vi-git-remotebranch() { remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) - if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then - setDefault POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' + if [[ -n "$P9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$P9K_VCS_SHORTEN_MIN_LENGTH" ]]; then + setDefault P9K_VCS_SHORTEN_DELIMITER $'\U2026' - if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then - case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in + if [ ${#hook_com[branch]} -gt $P9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $P9K_VCS_SHORTEN_LENGTH ]; then + case "$P9K_VCS_SHORTEN_STRATEGY" in truncate_middle) - hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")" + hook_com[branch]="$(echo "${branch_name:0:$P9K_VCS_SHORTEN_LENGTH}")$P9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$P9K_VCS_SHORTEN_LENGTH}")" ;; truncate_from_right) - hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER" + hook_com[branch]="$(echo "${branch_name:0:$P9K_VCS_SHORTEN_LENGTH}")$P9K_VCS_SHORTEN_DELIMITER" ;; esac fi From 3ea0c9e91296344fa47804e6b1effe4616a5204e Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Wed, 18 Apr 2018 18:42:44 +0400 Subject: [PATCH 51/55] vcs.spec - Fixed P9K_ environment vars --- test/segments/vcs.spec | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index fdc943b64..2492e2af4 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -79,10 +79,10 @@ function testColorOverridingForUntrackedStateWorks() { } function testBranchNameTruncatingShortenLength() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_SHORTEN_LENGTH=6 - POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 - POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_SHORTEN_LENGTH=6 + P9K_VCS_SHORTEN_MIN_LENGTH=3 + P9K_VCS_SHORTEN_STRATEGY="truncate_from_right" FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER @@ -92,23 +92,23 @@ function testBranchNameTruncatingShortenLength() { assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" - POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + P9K_VCS_SHORTEN_LENGTH=3 assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_SHORTEN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_SHORTEN_LENGTH + unset P9K_VCS_SHORTEN_MIN_LENGTH + unset P9K_VCS_SHORTEN_STRATEGY } function testBranchNameTruncatingMinLength() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 - POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6 - POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_SHORTEN_LENGTH=3 + P9K_VCS_SHORTEN_MIN_LENGTH=6 + P9K_VCS_SHORTEN_STRATEGY="truncate_from_right" FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER @@ -118,24 +118,24 @@ function testBranchNameTruncatingMinLength() { assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" - POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7 + P9K_VCS_SHORTEN_MIN_LENGTH=7 assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_SHORTEN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_SHORTEN_LENGTH + unset P9K_VCS_SHORTEN_MIN_LENGTH + unset P9K_VCS_SHORTEN_STRATEGY } function testBranchNameTruncatingShortenStrategy() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 - POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 - POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + P9K_LEFT_PROMPT_ELEMENTS=(vcs) + P9K_VCS_SHORTEN_LENGTH=3 + P9K_VCS_SHORTEN_MIN_LENGTH=3 + P9K_VCS_SHORTEN_STRATEGY="truncate_from_right" FOLDER=/tmp/powerlevel9k-test/vcs-test mkdir -p $FOLDER @@ -145,17 +145,17 @@ function testBranchNameTruncatingShortenStrategy() { assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(buildLeftPrompt)" - POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle" + P9K_VCS_SHORTEN_STRATEGY="truncate_middle" assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(buildLeftPrompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_SHORTEN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH - unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY + unset P9K_LEFT_PROMPT_ELEMENTS + unset P9K_VCS_SHORTEN_LENGTH + unset P9K_VCS_SHORTEN_MIN_LENGTH + unset P9K_VCS_SHORTEN_STRATEGY } source shunit2/source/2.1/src/shunit2 From e20b9d4c2560fa3a2c0ddf8acd55d83ed92724b3 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 26 Apr 2018 18:15:25 +0400 Subject: [PATCH 52/55] Fixed typo in README.md - p8k_ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07075dd2f..34a6c9a50 100644 --- a/README.md +++ b/README.md @@ -440,7 +440,7 @@ segment will not be displayed. | Variable | Default Value | Description | |----------|---------------|-------------| -|`P9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| +|`P9K_PUBLIC_IP_FILE`|'/tmp/p9k_public_ip'|This is the file your public IP is cached in.| |`P9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| |`P9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| |`P9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| From 617f1c72dcae544d35840f1a0df40ce91c1f3c9d Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Tue, 1 May 2018 17:12:31 +0400 Subject: [PATCH 53/55] Various changes. See description functions/icons.zsh Updated registerIcon to check for icon overrides and use those if found Updated printIcon to now only print the icon Removed get_icon_names Added showDefinedIcons - lists all defined icons alphabetically default.p9k Changed $3PromptSegment to ${ALIGNMENT}PromptSegment Renamed serializeSegment to p9kPrepareSegment zsh-asynv.p9k Removed unneccesary testing in leftPromptSegment and rightPromptSegment Fixed "left" in updateRightPrompt Fixed an issue where invisible segments were adding a space to a prompt segment Renamed serializeSegment to p9kPrepareSegment Commented out the auto-loading of segments in buildLeftPrompt and buildRightPrompt history.p9k Fixed incorrect icon name for segment vcs.p9k Added loads of comments in preparation for streamlining this segment All segments Renamed serializeSegment to p9kPrepareSegment --- CHANGELOG.md | 4 +- api/generator/default.md | 4 +- api/generator/zsh-async.md | 4 +- functions/icons.zsh | 64 ++++++++++------------- generator/default.p9k | 6 +-- generator/zsh-async.p9k | 78 ++++++++++++++--------------- segments/anaconda.p9k | 2 +- segments/aws.p9k | 2 +- segments/aws_eb_env.p9k | 2 +- segments/background_jobs.p9k | 2 +- segments/battery.p9k | 4 +- segments/chruby.p9k | 2 +- segments/command_execution_time.p9k | 2 +- segments/context.p9k | 2 +- segments/date.p9k | 2 +- segments/detect_virt.p9k | 4 +- segments/dir.p9k | 2 +- segments/dir_writable.p9k | 2 +- segments/disk_usage.p9k | 2 +- segments/docker_machine.p9k | 2 +- segments/dropbox.p9k | 2 +- segments/go_version.p9k | 2 +- segments/history.p9k | 6 +-- segments/host.p9k | 2 +- segments/icons_test.p9k | 2 +- segments/ip.p9k | 2 +- segments/java_version.p9k | 2 +- segments/kubecontext.p9k | 2 +- segments/load.p9k | 2 +- segments/node_env.p9k | 2 +- segments/node_version.p9k | 2 +- segments/nvm.p9k | 2 +- segments/openfoam.p9k | 4 +- segments/os_icon.p9k | 2 +- segments/php_version.p9k | 2 +- segments/public_ip.p9k | 2 +- segments/pyenv.p9k | 2 +- segments/ram.p9k | 2 +- segments/rbenv.p9k | 4 +- segments/root_indicator.p9k | 2 +- segments/rust_version.p9k | 2 +- segments/rvm.p9k | 2 +- segments/ssh.p9k | 2 +- segments/status.p9k | 6 +-- segments/swap.p9k | 2 +- segments/swift_version.p9k | 2 +- segments/symfony2_version.p9k | 2 +- segments/test_stats.p9k | 6 +-- segments/time.p9k | 2 +- segments/todo.p9k | 2 +- segments/user.p9k | 2 +- segments/vcs.p9k | 78 ++++++++++++++++++++++++++++- segments/vi_mode.p9k | 2 +- segments/virtualenv.p9k | 2 +- segments/vpn_ip.p9k | 2 +- 55 files changed, 210 insertions(+), 144 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13568634b..74402fad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Only core icons are registered by default. - Each segment is responsible to register its own icons. - Moved all segments to their own files under `segments`. - - Segments now use `serializeSegment()` instead of `$1_prompt_segment()`. + - Segments now use `p9kPrepareSegment()` instead of `$1_prompt_segment()`. - Only segments in use are dynamically loaded (including their icons). - The autoloader checks if a file exists before calling it to catch any errors. For `custom_prompt` segments, it checks if it is a variable/definition before checking for a file. - Custom segment files have to be placed in `segments/custom` directory, and have to follow the naming convention. @@ -37,7 +37,7 @@ - All comments have been updated for uniformity and for API generation. - iTerm integration added. - Added `POWERLEVEL9K_PROMPT_SEGMENTS` to allow testing for segment usage in a single variable. - - Replaced `$1_prompt_segment()` with `serializeSegment()` to enable single call from segments irrespective of generator. + - Replaced `$1_prompt_segment()` with `p9kPrepareSegment()` to enable single call from segments irrespective of generator. - Changed all internal functions to use `camelCase`. Exceptions are listed below: - prompt functions still use `prompt_x()` so that we can differentiate between internal (core) functionality and segments. - `prompt_powerlevel9k_setup()`, `prompt_powerlevel9k_teardown()`, and `p9k_preexec()`. diff --git a/api/generator/default.md b/api/generator/default.md index 162d3ae3a..416140a57 100644 --- a/api/generator/default.md +++ b/api/generator/default.md @@ -21,7 +21,7 @@ - [leftPromptSegment()](#leftPromptSegment) - [leftPromptEnd()](#leftPromptEnd) - [rightPromptSegment()](#rightPromptSegment) -- [serializeSegment()](#serializeSegment) +- [p9kPrepareSegment()](#p9kPrepareSegment) - [prompt_custom()](#prompt_custom) - [buildLeftPrompt()](#buildLeftPrompt) - [buildRightPrompt()](#buildRightPrompt) @@ -67,7 +67,7 @@ - **$7** (string) Visual identifier (must be a key of the icons array) -## serializeSegment() +## p9kPrepareSegment() *This function wraps `leftPromptSegment` and `rightPromptSegment` (for compatibility with the async generator). * #### Arguments diff --git a/api/generator/zsh-async.md b/api/generator/zsh-async.md index 4212ac101..58b2c3b3c 100644 --- a/api/generator/zsh-async.md +++ b/api/generator/zsh-async.md @@ -34,7 +34,7 @@ - [updateRightPrompt()](#updateRightPrompt) - [p9kAsyncCallback()](#p9kAsyncCallback) - [p9kSerializeSegment()](#p9kSerializeSegment) -- [serializeSegment()](#serializeSegment) +- [p9kPrepareSegment()](#p9kPrepareSegment) - [prompt_custom()](#prompt_custom) - [buildLeftPrompt()](#buildLeftPrompt) - [buildRightPrompt()](#buildRightPrompt) @@ -133,7 +133,7 @@ - **$10** (string) Condition - The condition, if the segment should be printed (gets evaluated) -## serializeSegment() +## p9kPrepareSegment() *This function is a wrapper function that starts off the async process and passes the parameters from the segment code to the subshells. * #### Arguments diff --git a/functions/icons.zsh b/functions/icons.zsh index ea22a3371..3762c8ac3 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -9,8 +9,7 @@ # Dominik Ritter (dritter) ## # @info -# This file contains some the core icon definitions and -# icon-functions. +# This file contains the core icon definitions and icon-functions. # # These characters require the Powerline fonts to work properly. If you see # boxes or bizarre characters below, your fonts are not correctly installed. If @@ -22,9 +21,10 @@ typeset -gAH icons ################################################################ # @description -# This function allows a segment to register the icons that it requires. -# These icons may be overriden by the user later. -# Arguments may be a direct call or an array. +# This function allows a segment to register the icons that it +# requires. It will check for icons overriden by the user first +# and if found, will use those instead of the ones defined by +# the segment. ## # @args # $1 string Name of icon @@ -45,13 +45,18 @@ typeset -gAH icons ## registerIcon() { local map - case $P9K_MODE in - 'flat'|'awesome-patched') map=$3 ;; - 'awesome-fontconfig') map=$4 ;; - 'awesome-mapped-fontconfig') map=$5 ;; - 'nerdfont-complete'|'nerdfont-fontconfig') map=$6 ;; - *) map=$2 ;; - esac + local ICON_USER_VARIABLE=P9K_${1} + if defined "$ICON_USER_VARIABLE"; then # check for icon override first + map="${(P)ICON_USER_VARIABLE}" + else # use the icons that are registered by the segment + case $P9K_MODE in + 'flat'|'awesome-patched') map=$3 ;; + 'awesome-fontconfig') map=$4 ;; + 'awesome-mapped-fontconfig') map=$5 ;; + 'nerdfont-complete'|'nerdfont-fontconfig') map=$6 ;; + *) map=$2 ;; + esac + fi icons[$1]=${map} } @@ -173,36 +178,21 @@ esac ################################################################ # @description -# Safety function for printing icons. Prints the named icon, -# or if that icon is undefined, the string name. +# Prints the requested icon. ## # @args # $1 string Name of icon ## function printIcon() { - local icon_name=$1 - local ICON_USER_VARIABLE=P9K_${icon_name} - if defined "$ICON_USER_VARIABLE"; then - echo -n "${(P)ICON_USER_VARIABLE}" - else - echo -n "${icons[$icon_name]}" - fi + echo -n "${icons[$1]}" } -# Get a list of configured icons -# * $1 string - If "original", then the original icons are printed, -# otherwise "printIcon" is used, which takes the users -# overrides into account. -get_icon_names() { - # Iterate over a ordered list of keys of the icons array - for key in ${(@kon)icons}; do - echo -n "P9K_$key: " - if [[ "${1}" == "original" ]]; then - # print the original icons as they are defined in the array above - echo "${icons[$key]}" - else - # print the icons as they are configured by the user - echo "$(printIcon "$key")" - fi - done +################################################################ +# @description +# Print all the configured icons alphabetically as KEY -> VALUE pairs. +## +# @noargs +## +showDefinedIcons() { + for k v in ${(kv)icons}; do; echo "$k -> $v"; done | sort } diff --git a/generator/default.p9k b/generator/default.p9k index 6d6e85951..4684add62 100644 --- a/generator/default.p9k +++ b/generator/default.p9k @@ -233,7 +233,7 @@ rightPromptSegment() { # $9 string Visual identifier (must be a key of the icons array). # $10 string The condition - if the segment should be shown (gets evaluated). ## -serializeSegment() { +p9kPrepareSegment() { local NAME="${1}" local STATE="${2}" local ALIGNMENT="${3}" @@ -302,7 +302,7 @@ serializeSegment() { # if ! ${CONDITION}; then # continue # fi - [[ $CONDITION == true ]] && "$3PromptSegment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" + [[ $CONDITION == true ]] && "${ALIGNMENT}PromptSegment" "${NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" } ################################################################ @@ -330,7 +330,7 @@ prompt_custom() { local segment_content="$(eval ${(P)command})" if [[ -n $segment_content ]]; then - serializeSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + p9kPrepareSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" fi } diff --git a/generator/zsh-async.p9k b/generator/zsh-async.p9k index a614d9776..ee2f9ed73 100644 --- a/generator/zsh-async.p9k +++ b/generator/zsh-async.p9k @@ -56,7 +56,7 @@ leftPromptSegment() { [[ -n "${BD}" ]] && SEGMENT+="${BD}${CONTENT}%b" || SEGMENT+="${CONTENT}" fi # Return the result to the main process, delimited by "·|·" - [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" + echo "${INDEX}·|·${SEGMENT}" } P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=" " @@ -93,7 +93,7 @@ rightPromptSegment() { [[ -n ${VISUAL_IDENTIFIER} ]] && SEGMENT+="${VISUAL_IDENTIFIER}${P9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" fi # Return the result to the main process, delimited by "·|·" - [[ "${INDEX}" != "" ]] && echo "${INDEX}·|·${SEGMENT}" + echo "${INDEX}·|·${SEGMENT}" } ############################################################### @@ -152,7 +152,7 @@ updateLeftPrompt() { # Build the left prompt string LEFT_PROMPT="" for (( i = 1; i <= ${LSEGMENTS}; i++ )); do - if [[ "${P9K_LP_CONTENT[$i]}" != "·" ]]; then + if [[ "${P9K_LP_CONTENT[$i]}" != "" ]]; then LBG=${P9K_LP_BACKGROUND[$i]} LFG=${P9K_LP_FOREGROUND[$i]} if [[ $i != 1 ]]; then # If it is not the first segment... @@ -198,12 +198,12 @@ updateLeftPrompt() { ## updateRightPrompt() { local RBG LAST_RBG RIGHT_PROMPT RSEGMENTS firstSegment=false - # Determine how many segments are visible in the left prompt + # Determine how many segments are visible in the right prompt RSEGMENTS=${#P9K_RP_CONTENT} # Build the left prompt string RIGHT_PROMPT="" for (( i = 1; i <= ${RSEGMENTS}; i++ )); do - if [[ "${P9K_RP_CONTENT[$i]}" != "·" ]]; then + if [[ "${P9K_RP_CONTENT[$i]}" != "" ]]; then RBG=${P9K_RP_BACKGROUND[$i]} RFG=${P9K_RP_FOREGROUND[$i]} # Find previous right segment background @@ -231,7 +231,7 @@ updateRightPrompt() { fi done [[ "${P9K_FANCY_EDGE}" == "true" ]] && RIGHT_PROMPT+="%k%F{$RBG}${_P9K_LEFT_SEGMENT_SEPARATOR}%f" - # Set the left prompt + # Set the right prompt RPROMPT=${RPROMPT_PREFIX}${RIGHT_PROMPT}${RPROMPT_SUFFIX} # About .reset-prompt see: # https://github.com/sorin-ionescu/prezto/issues/1026 @@ -307,7 +307,7 @@ p9kAsyncCallback() { async_job "p9k" rightPromptSegment "${STATEFUL_NAME}" "${INDEX}" "${BACKGROUND}" "${FOREGROUND}" "${BOLD}" "${CONTENT}" "${VISUAL_IDENTIFIER}" fi else # ...otherwise set the prompt content array to "·" (no segemnt) - [[ "${ALIGNMENT}" == "left" ]] && P9K_LP_CONTENT[${INDEX}]="·" || P9K_RP_CONTENT[${INDEX}]="·" + [[ "${ALIGNMENT}" == "left" ]] && P9K_LP_CONTENT[${INDEX}]="" || P9K_RP_CONTENT[${INDEX}]="" fi fi ;; @@ -427,7 +427,7 @@ p9kSerializeSegment() { # @args # $@ misc The parameters passed from the segment code ## -serializeSegment() { +p9kPrepareSegment() { (async_job "p9k" "p9kSerializeSegment" "${@}") } @@ -450,7 +450,7 @@ prompt_custom() { local segment_content="$(eval ${(P)command})" if [[ -n $segment_content ]]; then - serializeSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" + p9kPrepareSegment "${4:u}" "" "$1" $2 $3 $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" fi } @@ -474,26 +474,26 @@ buildLeftPrompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then - if [[ -z "${loadedSegments[(r)$element]}" ]]; then - if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition - loadedSegments+=("$element") - elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists - source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 - loadedSegments+=("$element") - fi - fi - "prompt_custom" "left" "${index}" "${joined}" "${element[8,-1]}" &! + # if [[ -z "${loadedSegments[(r)$element]}" ]]; then + # if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + # loadedSegments+=("$element") + # elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + # source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + # loadedSegments+=("$element") + # fi + # fi + "prompt_custom" "left" "${index}" "${joined}" "${element[8,-1]}" else - if [[ -z "${loadedSegments[(r)$element]}" ]]; then - if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists - source "${p9kDirectory}/segments/${element}.p9k" 2>&1 - loadedSegments+=("$element") - fi - fi + # if [[ -z "${loadedSegments[(r)$element]}" ]]; then + # if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + # source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + # loadedSegments+=("$element") + # fi + # fi # Could we display placeholders? # -> At most it could be static ones, but # e.g. states are the result of calculation.. - "prompt_$element" "left" "${index}" "${joined}" &! + "prompt_$element" "left" "${index}" "${joined}" fi index=$((index + 1)) done @@ -519,22 +519,22 @@ buildRightPrompt() { # Check if it is a custom command, otherwise interpet it as # a prompt. if [[ $element[0,7] =~ "custom_" ]]; then - if [[ -z "${loadedSegments[(r)$element]}" ]]; then - if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition - loadedSegments+=("$element") - elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists - source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 - loadedSegments+=("$element") - fi - fi + # if [[ -z "${loadedSegments[(r)$element]}" ]]; then + # if [[ -n "$P9K_${(U)element}" ]]; then # check if custom segment is a definition + # loadedSegments+=("$element") + # elif [[ -f "${p9kDirectory}/segments/custom/${element}.p9k" ]]; then # check if custom segment file exists + # source "${p9kDirectory}/segments/custom/${element}.p9k" 2>&1 + # loadedSegments+=("$element") + # fi + # fi "prompt_custom" "right" "$index" $joined "${element[8,-1]}" &! else - if [[ -z "${loadedSegments[(r)$element]}" ]]; then - if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists - source "${p9kDirectory}/segments/${element}.p9k" 2>&1 - loadedSegments+=("$element") - fi - fi + # if [[ -z "${loadedSegments[(r)$element]}" ]]; then + # if [[ -f "${p9kDirectory}/segments/${element}.p9k" ]]; then # check if segment file exists + # source "${p9kDirectory}/segments/${element}.p9k" 2>&1 + # loadedSegments+=("$element") + # fi + # fi "prompt_$element" "right" "$index" "${joined}" &! fi index=$((index + 1)) diff --git a/segments/anaconda.p9k b/segments/anaconda.p9k index 06159b3f4..da707dbce 100644 --- a/segments/anaconda.p9k +++ b/segments/anaconda.p9k @@ -35,6 +35,6 @@ prompt_anaconda() { # variant works even if both are set. _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then - serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$P9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$P9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$P9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$P9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' fi } diff --git a/segments/aws.p9k b/segments/aws.p9k index 0ecbcf0f5..d86a6e754 100644 --- a/segments/aws.p9k +++ b/segments/aws.p9k @@ -29,6 +29,6 @@ prompt_aws() { local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" if [[ -n "$aws_profile" ]]; then - serializeSegment "$0" "" $1 "$2" $3 red white "$aws_profile" 'AWS_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 red white "$aws_profile" 'AWS_ICON' fi } diff --git a/segments/aws_eb_env.p9k b/segments/aws_eb_env.p9k index 12b865d8c..8b66284a6 100644 --- a/segments/aws_eb_env.p9k +++ b/segments/aws_eb_env.p9k @@ -29,6 +29,6 @@ prompt_aws_eb_env() { local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') if [[ -n "$eb_env" ]]; then - serializeSegment "$0" "" $1 "$2" $3 black green "$eb_env" 'AWS_EB_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 black green "$eb_env" 'AWS_EB_ICON' fi } diff --git a/segments/background_jobs.p9k b/segments/background_jobs.p9k index 06095506f..8580f0da3 100644 --- a/segments/background_jobs.p9k +++ b/segments/background_jobs.p9k @@ -35,6 +35,6 @@ prompt_background_jobs() { if [[ "$P9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && ([[ "$background_jobs_number" -gt 1 ]] || [[ "$P9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); then background_jobs_number_print="$background_jobs_number" fi - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' fi } diff --git a/segments/battery.p9k b/segments/battery.p9k index 186f819f8..0188cbe79 100644 --- a/segments/battery.p9k +++ b/segments/battery.p9k @@ -129,10 +129,10 @@ prompt_battery() { if [[ -n "$P9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)P9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then local segment=$(( 100.0 / (${#P9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) local offset=$(( ($bat_percent / $segment) + 1 )) - serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${P9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + p9kPrepareSegment "$0" "${(U)current_state}" $1 "$2" $3 "${P9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi else # Draw the prompt_segment - serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + p9kPrepareSegment "$0" "${(U)current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" fi } diff --git a/segments/chruby.p9k b/segments/chruby.p9k index 09a8c3a26..bf178e453 100644 --- a/segments/chruby.p9k +++ b/segments/chruby.p9k @@ -34,6 +34,6 @@ prompt_chruby() { chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" # Don't show anything if the chruby did not change the default ruby if [[ "${chrb_env:-system}" != "system" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' fi } diff --git a/segments/command_execution_time.p9k b/segments/command_execution_time.p9k index fe550b89c..19a82b49f 100644 --- a/segments/command_execution_time.p9k +++ b/segments/command_execution_time.p9k @@ -53,6 +53,6 @@ prompt_command_execution_time() { fi if (( _P9K_COMMAND_DURATION >= P9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - serializeSegment "$0" "" $1 "$2" $3 "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "red" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' fi } diff --git a/segments/context.p9k b/segments/context.p9k index 4cefd44cb..5b48f7c1f 100644 --- a/segments/context.p9k +++ b/segments/context.p9k @@ -57,5 +57,5 @@ prompt_context() { current_state="SUDO" fi - serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" + p9kPrepareSegment "$0" "${(U)current_state}" $1 "$2" $3 "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" } diff --git a/segments/date.p9k b/segments/date.p9k index 946110e14..b0403ff23 100644 --- a/segments/date.p9k +++ b/segments/date.p9k @@ -28,5 +28,5 @@ registerIcon "DATE_ICON" '' $'\uE184' $'\uF073 ' $'\uF073 ' $'\uF073 ' prompt_date() { setDefault P9K_DATE_FORMAT "%D{%d.%m.%y}" - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_DATE_FORMAT" "DATE_ICON" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_DATE_FORMAT" "DATE_ICON" } diff --git a/segments/detect_virt.p9k b/segments/detect_virt.p9k index 2847a2668..f85222c49 100644 --- a/segments/detect_virt.p9k +++ b/segments/detect_virt.p9k @@ -26,11 +26,11 @@ prompt_detect_virt() { if [[ "$virt" == "none" ]]; then if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then virt="chroot" - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" else ; fi else - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "$virt" fi } diff --git a/segments/dir.p9k b/segments/dir.p9k index ee693b36b..d5ef46f48 100644 --- a/segments/dir.p9k +++ b/segments/dir.p9k @@ -280,5 +280,5 @@ prompt_dir() { current_path=${current_path:s/~/$P9K_HOME_FOLDER_ABBREVIATION} fi - serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" + p9kPrepareSegment "$0" "${(U)current_state}" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" } diff --git a/segments/dir_writable.p9k b/segments/dir_writable.p9k index 7b97785c3..e722eaba6 100644 --- a/segments/dir_writable.p9k +++ b/segments/dir_writable.p9k @@ -27,6 +27,6 @@ registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWE ## prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then - serializeSegment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' + p9kPrepareSegment "$0" "FORBIDDEN" $1 "$2" $3 "red" "yellow1" "" 'LOCK_ICON' fi } diff --git a/segments/disk_usage.p9k b/segments/disk_usage.p9k index b14edf012..f4386e44f 100644 --- a/segments/disk_usage.p9k +++ b/segments/disk_usage.p9k @@ -63,6 +63,6 @@ prompt_disk_usage() { # Draw the prompt_segment if [[ -n $disk_usage ]]; then - serializeSegment "$0" "${(U)current_state}" $1 "$2" $3 "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' + p9kPrepareSegment "$0" "${(U)current_state}" $1 "$2" $3 "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' fi } diff --git a/segments/docker_machine.p9k b/segments/docker_machine.p9k index b5f5f4a94..3d816084f 100644 --- a/segments/docker_machine.p9k +++ b/segments/docker_machine.p9k @@ -29,6 +29,6 @@ prompt_docker_machine() { local docker_machine="$DOCKER_MACHINE_NAME" if [[ -n "$docker_machine" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' fi } diff --git a/segments/dropbox.p9k b/segments/dropbox.p9k index 5a7640d40..1a8759939 100644 --- a/segments/dropbox.p9k +++ b/segments/dropbox.p9k @@ -36,7 +36,7 @@ prompt_dropbox() { dropbox_status="" fi - serializeSegment "$0" "" $1 "$2" $3 "white" "blue" "$dropbox_status" "DROPBOX_ICON" + p9kPrepareSegment "$0" "" $1 "$2" $3 "white" "blue" "$dropbox_status" "DROPBOX_ICON" fi } diff --git a/segments/go_version.p9k b/segments/go_version.p9k index 3d044e765..cb0c48798 100644 --- a/segments/go_version.p9k +++ b/segments/go_version.p9k @@ -32,6 +32,6 @@ prompt_go_version() { go_path=$(go env GOPATH 2>/dev/null) if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "green" "grey93" "$go_version" "GO_ICON" + p9kPrepareSegment "$0" "" $1 "$2" $3 "green" "grey93" "$go_version" "GO_ICON" fi } diff --git a/segments/history.p9k b/segments/history.p9k index 41372ff09..5a8b626a6 100644 --- a/segments/history.p9k +++ b/segments/history.p9k @@ -13,8 +13,8 @@ # Register segment icon # Parameters: # name_of_icon Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont -#    -registerIcon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' +#    +registerIcon "HISTORY_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' ################################################################ # @description @@ -26,5 +26,5 @@ registerIcon "VCS_UNTRACKED_ICON" '' '' $'\uE29A' $'\uE29A' $'\uE29A' # $3 boolean Whether the segment should be joined ## prompt_history() { - serializeSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" '%h' 'HISTORY_ICON' } diff --git a/segments/host.p9k b/segments/host.p9k index a9049840d..43089ed31 100644 --- a/segments/host.p9k +++ b/segments/host.p9k @@ -48,5 +48,5 @@ prompt_host() { "VISUAL_IDENTIFIER" "HOST_ICON" ) fi - serializeSegment "$0" "${(U)host_state[STATE]}" $1 "$2" $3 "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" + p9kPrepareSegment "$0" "${(U)host_state[STATE]}" $1 "$2" $3 "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" } diff --git a/segments/icons_test.p9k b/segments/icons_test.p9k index 901fb5da7..0506aaf3e 100644 --- a/segments/icons_test.p9k +++ b/segments/icons_test.p9k @@ -24,6 +24,6 @@ prompt_icons_test() { # the next color has enough contrast to read. local random_color=$((RANDOM % 8)) local next_color=$((random_color+1)) - serializeSegment "$0" "" $1 "$2" $3 "$random_color" "$next_color" "$key" "$key" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$random_color" "$next_color" "$key" "$key" done } diff --git a/segments/ip.p9k b/segments/ip.p9k index 7a9519c06..92d8d46d7 100644 --- a/segments/ip.p9k +++ b/segments/ip.p9k @@ -52,5 +52,5 @@ prompt_ip() { fi fi - serializeSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' } diff --git a/segments/java_version.p9k b/segments/java_version.p9k index 3dbaa0da9..05f5b97f8 100644 --- a/segments/java_version.p9k +++ b/segments/java_version.p9k @@ -29,6 +29,6 @@ prompt_java_version() { local java_version java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) if [[ -n "$java_version" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "red" "white" "${java_version}" 'JAVA_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "red" "white" "${java_version}" 'JAVA_ICON' fi } diff --git a/segments/kubecontext.p9k b/segments/kubecontext.p9k index 4051a183b..b3c832118 100644 --- a/segments/kubecontext.p9k +++ b/segments/kubecontext.p9k @@ -46,6 +46,6 @@ prompt_kubecontext() { k8s_final_text="$cur_ctx/$cur_namespace" fi - serializeSegment "$0" "" $1 "$2" $3 "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + p9kPrepareSegment "$0" "" $1 "$2" $3 "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" fi } diff --git a/segments/load.p9k b/segments/load.p9k index 5d989d1f3..e4bf1e7aa 100644 --- a/segments/load.p9k +++ b/segments/load.p9k @@ -77,5 +77,5 @@ prompt_load() { current_state="normal" fi - serializeSegment "$0" "${current_state}" $1 "$2" $3 "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' + p9kPrepareSegment "$0" "${current_state}" $1 "$2" $3 "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' } diff --git a/segments/node_env.p9k b/segments/node_env.p9k index 69ff9a331..bbdc913dd 100644 --- a/segments/node_env.p9k +++ b/segments/node_env.p9k @@ -29,6 +29,6 @@ prompt_node_env() { local node_env_path="$NODE_VIRTUAL_ENV" if [[ -n "$node_env_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then local info="$(node -v)[$(basename "$node_env_path")]" - serializeSegment "$0" "" $1 "$2" $3 "black" "green" "$info" 'NODE_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "black" "green" "$info" 'NODE_ICON' fi } diff --git a/segments/node_version.p9k b/segments/node_version.p9k index 81456a072..fbcf18b79 100644 --- a/segments/node_version.p9k +++ b/segments/node_version.p9k @@ -29,5 +29,5 @@ prompt_node_version() { local node_version=$(node -v 2>/dev/null) [[ -z "${node_version}" ]] && return - serializeSegment "$0" "" $1 "$2" $3 "green" "white" "${node_version:1}" 'NODE_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "green" "white" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/nvm.p9k b/segments/nvm.p9k index 61895b9e2..8c9e16bdd 100644 --- a/segments/nvm.p9k +++ b/segments/nvm.p9k @@ -38,5 +38,5 @@ prompt_nvm() { nvm_default=$(nvm_version default) [[ "$node_version" =~ "$nvm_default" ]] && return - serializeSegment "$0" "" $1 "$2" $3 "magenta" "black" "${node_version:1}" 'NODE_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "magenta" "black" "${node_version:1}" 'NODE_ICON' } diff --git a/segments/openfoam.p9k b/segments/openfoam.p9k index 051e3e1df..a8a927fac 100644 --- a/segments/openfoam.p9k +++ b/segments/openfoam.p9k @@ -22,8 +22,8 @@ prompt_openfoam() { local wm_project_version="$WM_PROJECT_VERSION" local wm_fork="$WM_FORK" if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then - serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + p9kPrepareSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then - serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + p9kPrepareSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" fi } diff --git a/segments/os_icon.p9k b/segments/os_icon.p9k index b1e589699..d0df89c5e 100644 --- a/segments/os_icon.p9k +++ b/segments/os_icon.p9k @@ -139,5 +139,5 @@ esac # otherwise just uses the Tux icon. ## prompt_os_icon() { - serializeSegment "$0" "" $1 "$2" $3 "black" "white" $(printIcon "$OS_ICON") + p9kPrepareSegment "$0" "" $1 "$2" $3 "black" "white" $(printIcon "$OS_ICON") } diff --git a/segments/php_version.p9k b/segments/php_version.p9k index 81dec766c..b387a3fe9 100644 --- a/segments/php_version.p9k +++ b/segments/php_version.p9k @@ -30,6 +30,6 @@ prompt_php_version() { php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") if [[ -n "$php_version" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "${php_version}" 'PHP_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "fuchsia" "grey93" "${php_version}" 'PHP_ICON' fi } diff --git a/segments/public_ip.p9k b/segments/public_ip.p9k index ad5077af2..cbbefe0c2 100644 --- a/segments/public_ip.p9k +++ b/segments/public_ip.p9k @@ -94,6 +94,6 @@ prompt_public_ip() { break done fi - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" "$icon" fi } diff --git a/segments/pyenv.p9k b/segments/pyenv.p9k index 023711265..6c976b4b4 100644 --- a/segments/pyenv.p9k +++ b/segments/pyenv.p9k @@ -30,6 +30,6 @@ registerIcon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' ## prompt_pyenv() { if [[ -n "$PYENV_VERSION" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' fi } diff --git a/segments/ram.p9k b/segments/ram.p9k index 5ba75a420..c9c79d30a 100644 --- a/segments/ram.p9k +++ b/segments/ram.p9k @@ -44,5 +44,5 @@ prompt_ram() { fi fi - serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } diff --git a/segments/rbenv.p9k b/segments/rbenv.p9k index 40fb3a23f..ae46c83d2 100644 --- a/segments/rbenv.p9k +++ b/segments/rbenv.p9k @@ -33,8 +33,8 @@ prompt_rbenv() { # Don't show anything if the current Ruby is the same as the global Ruby # unless `P9K_RBENV_ALWAYS` is set. - if [[ $P9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then - serializeSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + if [[ $P9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]]; then + p9kPrepareSegment "$0" "" $1 "$2" $3 "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi fi } diff --git a/segments/root_indicator.p9k b/segments/root_indicator.p9k index f47eed905..65b685fcc 100644 --- a/segments/root_indicator.p9k +++ b/segments/root_indicator.p9k @@ -27,6 +27,6 @@ registerIcon "ROOT_ICON" $'\u26A1' $'\uE801' $'\uF201' '\u'$CODEPOINT_OF_OCT ## prompt_root_indicator() { if [[ "$UID" -eq 0 ]]; then - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' fi } diff --git a/segments/rust_version.p9k b/segments/rust_version.p9k index 4eccaafc5..1e266147a 100644 --- a/segments/rust_version.p9k +++ b/segments/rust_version.p9k @@ -30,6 +30,6 @@ prompt_rust_version() { rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') if [[ -n "$rust_version" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' fi } diff --git a/segments/rvm.p9k b/segments/rvm.p9k index ee9d881c4..05f3c8348 100644 --- a/segments/rvm.p9k +++ b/segments/rvm.p9k @@ -29,6 +29,6 @@ prompt_rvm() { local version_and_gemset=${rvm_env_string/ruby-} if [[ -n "$version_and_gemset" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' fi } diff --git a/segments/ssh.p9k b/segments/ssh.p9k index 7e3fa5942..75767ad2e 100644 --- a/segments/ssh.p9k +++ b/segments/ssh.p9k @@ -27,6 +27,6 @@ registerIcon "SSH_ICON" '(ssh)' '(ssh)' '(ssh)' '(ssh)' $'\uF489' ## prompt_ssh() { if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' fi } diff --git a/segments/status.p9k b/segments/status.p9k index eacf159a0..a4d8073a3 100644 --- a/segments/status.p9k +++ b/segments/status.p9k @@ -83,11 +83,11 @@ prompt_status() { if (( ec_sum > 0 )); then if [[ "$P9K_STATUS_CROSS" == false && "$P9K_STATUS_VERBOSE" == true ]]; then - serializeSegment "$0" "ERROR" $1 "$2" $3 "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + p9kPrepareSegment "$0" "ERROR" $1 "$2" $3 "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' else - serializeSegment "$0" "ERROR" $1 "$2" $3 "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + p9kPrepareSegment "$0" "ERROR" $1 "$2" $3 "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' fi elif [[ "$P9K_STATUS_OK" == true ]] && [[ "$P9K_STATUS_VERBOSE" == true || "$P9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then - serializeSegment "$0" "OK" $1 "$2" $3 "$DEFAULT_COLOR" "green" "" 'OK_ICON' + p9kPrepareSegment "$0" "OK" $1 "$2" $3 "$DEFAULT_COLOR" "green" "" 'OK_ICON' fi } diff --git a/segments/swap.p9k b/segments/swap.p9k index de32e3d05..fe98694b2 100644 --- a/segments/swap.p9k +++ b/segments/swap.p9k @@ -46,5 +46,5 @@ prompt_swap() { base='K' fi - serializeSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' } diff --git a/segments/swift_version.p9k b/segments/swift_version.p9k index d71201109..9d4e64b26 100644 --- a/segments/swift_version.p9k +++ b/segments/swift_version.p9k @@ -30,7 +30,7 @@ prompt_swift_version() { local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) [[ -z "${swift_version}" ]] && return - serializeSegment "$0" "" $1 "$2" $3 "magenta" "white" "${swift_version}" 'SWIFT_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "magenta" "white" "${swift_version}" 'SWIFT_ICON' } # diff --git a/segments/symfony2_version.p9k b/segments/symfony2_version.p9k index 648e32cce..dd6fd067d 100644 --- a/segments/symfony2_version.p9k +++ b/segments/symfony2_version.p9k @@ -30,6 +30,6 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - serializeSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "grey35" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } diff --git a/segments/test_stats.p9k b/segments/test_stats.p9k index c2f2cea6a..4231abf5d 100644 --- a/segments/test_stats.p9k +++ b/segments/test_stats.p9k @@ -41,7 +41,7 @@ build_test_stats() { typeset -F 2 ratio local ratio=$(( (tests_amount/code_amount) * 100 )) - (( ratio >= 75 )) && serializeSegment "$1" "GOOD" "$2" $3 $4 "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio >= 50 && ratio < 75 )) && serializeSegment "$1" "AVG" "$2" $3 $4 "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio < 50 )) && serializeSegment "$1" "BAD" "$2" $3 $4 "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 75 )) && p9kPrepareSegment "$1" "GOOD" "$2" $3 $4 "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && p9kPrepareSegment "$1" "AVG" "$2" $3 $4 "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && p9kPrepareSegment "$1" "BAD" "$2" $3 $4 "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" } diff --git a/segments/time.p9k b/segments/time.p9k index 8aa4a65b5..6a681a4ad 100644 --- a/segments/time.p9k +++ b/segments/time.p9k @@ -28,5 +28,5 @@ registerIcon "TIME_ICON" '' $'\uE12E' $'\uF017 ' $'\uF017 ' $'\uF017 ' prompt_time() { setDefault P9K_TIME_FORMAT "%D{%H:%M:%S}" - serializeSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_TIME_FORMAT" "TIME_ICON" + p9kPrepareSegment "$0" "" $1 "$2" $3 "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$P9K_TIME_FORMAT" "TIME_ICON" } diff --git a/segments/todo.p9k b/segments/todo.p9k index 37901ce71..751b10f2a 100644 --- a/segments/todo.p9k +++ b/segments/todo.p9k @@ -29,7 +29,7 @@ prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') if [[ "$count" = <-> ]]; then - serializeSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "grey50" "$DEFAULT_COLOR" "$count" 'TODO_ICON' fi fi } diff --git a/segments/user.p9k b/segments/user.p9k index 03c0d3db2..150c97d99 100644 --- a/segments/user.p9k +++ b/segments/user.p9k @@ -61,6 +61,6 @@ prompt_user() { "VISUAL_IDENTIFIER" "USER_ICON" ) fi - serializeSegment "$0" ${(U)user_state[STATE]} $1 "$2" $3 "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + p9kPrepareSegment "$0" ${(U)user_state[STATE]} $1 "$2" $3 "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" fi } diff --git a/segments/vcs.p9k b/segments/vcs.p9k index b0002c474..6be43a660 100644 --- a/segments/vcs.p9k +++ b/segments/vcs.p9k @@ -9,6 +9,63 @@ # Dominik Ritter (dritter) ## +################################################################ +# From: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information +# +# formats & actionformats +# ----------------------- +# In normal formats and actionformats the following replacements are done: +# +# %s The VCS in use (git, hg, svn, etc.). +# %b Information about the current branch. +# %a An identifier that describes the action. Only makes sense in actionformats. +# %i The current revision number or identifier. For hg the hgrevformat style may be used to customize the output. +# %c The string from the stagedstr style if there are staged changes in the repository. +# %u The string from the unstagedstr style if there are unstaged changes in the repository. +# %R The base directory of the repository. +# %r The repository name. If %R is /foo/bar/repoXY, %r is repoXY. +# %S A subdirectory within a repository. If $PWD is /foo/bar/repoXY/beer/tasty, %S is beer/tasty. +# %m A "misc" replacement. It is at the discretion of the backend to decide what this replacement expands to. +# The hg and git backends use this expando to display patch information. hg sources patch information from the mq extensions; git from in-progress rebase and cherry-pick operations and from the stgit extension. The patch-format and nopatch-format styles control the generated string. The former is used when at least one patch from the patch queue has been applied, and the latter otherwise. +# The hg backend displays bookmark information in this expando (in addition to mq information). See the get-mq and get-bookmarks styles. Both of these styles may be enabled at the same time. If both are enabled, both resulting strings will be shown separated by a semicolon (that cannot currently be customized). +# The quilt ‘standalone’ backend sets this expando to the same value as the %Q expando. +# %Q Quilt series information. When quilt is used (either in ‘addon’ mode or as a ‘standalone’ backend), this expando is set to quilt series’ patch-format string. The set-patch-format hook and nopatch-format style are honoured. +# +# In branchformat these replacements are done: +# +# %b The branch name. +# %r The current revision number or the hgrevformat style for hg. +# +# In hgrevformat these replacements are done: +# +# %r The current local revision number. +# %h The current global revision identifier. +# +# In patch-format and nopatch-format these replacements are done: +# +# %p The name of the top-most applied patch (applied-string). +# %u The number of unapplied patches (unapplied-string). +# %n The number of applied patches. +# %c The number of unapplied patches. +# %a The number of all patches. +# %g The names of active mq guards (hg backend). +# %G The number of active mq guards (hg backend). +# +# Not all VCS backends have to support all replacements. For nvcsformats no replacements are performed at all, it is just a string. +# +# set-message +# ----------- +# Called each time before a ‘vcs_info_msg_N_’ message is set. It takes two arguments; the first being the ‘N’ in the message variable name, the second is the currently configured formats or actionformats. +# There are a number of ‘hook_com’ keys, that are used here: ‘action’, ‘branch’, ‘base’, ‘base-name’, ‘subdir’, ‘staged’, ‘unstaged’, ‘revision’, ‘misc’, ‘vcs’ and one ‘miscN’ entry for each backend-specific data field (N starting at zero). They are set to the values figured out so far by vcs_info and any change will be used directly when the actual replacement is done. +# Since this hook is triggered multiple times (once for each configured formats or actionformats), each of the ‘hook_com’ keys mentioned above (except for the miscN entries) has an ‘_orig’ counterpart, so even if you changed a value to your liking you can still get the original value in the next run. Changing the ‘_orig’ values is probably not a good idea. +# If ret is set to non-zero, the string in ${hook_com[message]} will be used unchanged as the message by vcs_info. +# +# Oddities +# -------- +# If you want to use the %b (bold off) prompt expansion in formats, which expands %b itself, use %%b. That will cause the vcs_info expansion to replace %%b with %b, so that zsh’s prompt expansion mechanism can handle it. Similarly, to hand down %b from branchformat, use %%%%b. Sorry for this inconvenience, but it cannot be easily avoided. Luckily we do not clash with a lot of prompt expansions and this only needs to be done for those. +################################################################ + + ################################################################ # Register segment icon # Parameters: @@ -102,17 +159,28 @@ p9k_vcs_init() { VCS_CHANGESET_PREFIX="$(printIcon 'VCS_COMMIT_ICON')%0.$P9K_VCS_INTERNAL_HASH_LENGTH""i " fi + # Load supported version control backends zstyle ':vcs_info:*' enable git hg svn + + # If enabled, this style causes the %c and %u format escapes to show when the working directory has uncommitted changes. The strings displayed by these escapes can be controlled via the stagedstr and unstagedstr styles. The only backends that currently support this option are git, hg, and bzr (the latter two only support unstaged). zstyle ':vcs_info:*' check-for-changes true + # A list of formats, used when actionformats is not used (which is most of the time). VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m" zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" + # A list of formats, used if there is a special action going on in your current repository; like an interactive rebase or a merge conflict. zstyle ':vcs_info:*' actionformats "%b %F{${P9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" + # This string will be used in the %c escape if there are staged changes in the repository. zstyle ':vcs_info:*' stagedstr " $(printIcon 'VCS_STAGED_ICON')" + + # This string will be used in the %u escape if there are unstaged changes in the repository. zstyle ':vcs_info:*' unstagedstr " $(printIcon 'VCS_UNSTAGED_ICON')" + # Hooks are places in vcs_info where you can run your own code. That code can communicate with the code that called it and through that, change the system’s behaviour. + # For configuration, hooks change the style context: + # :vcs_info:vcs-string+hook-name:user-context:repo-root-name defined P9K_VCS_GIT_HOOKS || P9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) zstyle ':vcs_info:git*+set-message:*' hooks $P9K_VCS_GIT_HOOKS defined P9K_VCS_HG_HOOKS || P9K_VCS_HG_HOOKS=(vcs-detect-changes) @@ -122,8 +190,16 @@ p9k_vcs_init() { # For Hg, only show the branch name zstyle ':vcs_info:hg*:*' branchformat "$(printIcon 'VCS_BRANCH_ICON')%b" + + # look for a Mercurial Queue (mq) patch directory. Information will be available via the ‘%m’ replacement. + zstyle ':vcs_info:hg:*' get-mq true + # The `get-revision` function must be turned on for dirty-check to work for Hg + # The revision of a repository’s work tree (currently for the git and hg backends, where this kind of information is not always vital). For git, the hash value of the currently checked out commit is available via the %i expansion. With hg, the local revision number and the corresponding global hash are available via %i. zstyle ':vcs_info:hg*:*' get-revision true + + # If set to true, the hg backend will try to get a list of current bookmarks. They will be available via the ‘%m’ replacement. + # The default is to generate a comma-separated list of all bookmark names that refer to the currently checked out revision. If a bookmark is active, its name is suffixed an asterisk and placed first in the list. zstyle ':vcs_info:hg*:*' get-bookmarks true zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks @@ -168,8 +244,8 @@ prompt_vcs() { current_state='clean' fi fi - serializeSegment $0 ${(U)current_state} $1 "$2" $3 "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi + p9kPrepareSegment $0 ${(U)current_state} $1 "$2" $3 "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" "[[ -n '$vcs_info_msg_0_' ]]" } p9k_vcs_init diff --git a/segments/vi_mode.p9k b/segments/vi_mode.p9k index a9080b9ea..a1af043b0 100644 --- a/segments/vi_mode.p9k +++ b/segments/vi_mode.p9k @@ -57,7 +57,7 @@ prompt_vi_mode() { vi_mode="${P9K_VI_INSERT_MODE_STRING}" ;; esac - serializeSegment "$0" "${current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${vi_states[$current_state]}" "${vi_mode}" '' + p9kPrepareSegment "$0" "${current_state}" $1 "$2" $3 "${DEFAULT_COLOR}" "${vi_states[$current_state]}" "${vi_mode}" '' } ############################################################### diff --git a/segments/virtualenv.p9k b/segments/virtualenv.p9k index fe8035860..bbc86ea0d 100644 --- a/segments/virtualenv.p9k +++ b/segments/virtualenv.p9k @@ -31,6 +31,6 @@ registerIcon "PYTHON_ICON" '' $'\ue63c' $'\ue63c' $'\U1F40D' $'\UE73C ' prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - serializeSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' fi } diff --git a/segments/vpn_ip.p9k b/segments/vpn_ip.p9k index acaa150da..fa7bfb167 100644 --- a/segments/vpn_ip.p9k +++ b/segments/vpn_ip.p9k @@ -30,6 +30,6 @@ prompt_vpn_ip() { for vpn_iface in $(/sbin/ifconfig | grep -e ^"$P9K_VPN_IP_INTERFACE" | cut -d":" -f1) do ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) - serializeSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + p9kPrepareSegment "$0" "" $1 "$2" $3 "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' done } From ed890e7613f51b4be07d5ec2857418b14ac53c35 Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Thu, 3 May 2018 16:06:21 +0400 Subject: [PATCH 54/55] Removed obsolete line from powerlevel9k.spec --- test/powerlevel9k.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 0878cfd2c..ee5195bcf 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -86,7 +86,6 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { # Re-Source the icons, as the P9K_MODE is directly # evaluated there. source functions/icons.zsh - source segments/core/dir.p9k cd /tmp From 894fa6a6d12828c9369dadb02d8a7d266fde622a Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Fri, 4 May 2018 14:20:19 +0400 Subject: [PATCH 55/55] Updated incon functions, See details below functions/icons.zsh - changed core icon definitions to use registerIcon() segments/vcs.p9k - moved icon override for P9K_HIDE_BRANCH_ICON to this file instead of in icons.zsh powerlevel9k.zsh-theme - changed the sourcing order of icons and utilities so that defined() is available to registerIcon() --- functions/icons.zsh | 132 +++++++++++------------------------------ powerlevel9k.zsh-theme | 8 +-- segments/vcs.p9k | 5 +- 3 files changed, 42 insertions(+), 103 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 3762c8ac3..11b6d0e51 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -15,10 +15,27 @@ # boxes or bizarre characters below, your fonts are not correctly installed. If # you do not want to install a special font, you can set `P9K_MODE` to # `compatible`. This shows all icons in regular symbols. +# +# For specific fonts configurations, please refer to: +# - [Awesome-Patched Font](https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched) +# - [fontconfig with awesome-font](https://github.com/gabrielelana/awesome-terminal-fonts) +# - [mapped fontconfig with awesome-font](https://github.com/gabrielelana/awesome-terminal-fonts) and don't forget +# to source the font maps in your startup script +# - [nerd-font patched (complete)](https://github.com/ryanoasis/nerd-fonts) and the [cheat sheet](http://nerdfonts.com/#cheat-sheet) +# - [Powerline-Patched Font](https://github.com/Lokaltog/powerline-fonts) ## +# Set the right locale to protect special characters +local LC_ALL="" LC_CTYPE="en_US.UTF-8" typeset -gAH icons +if [[ P9K_MODE == "awesome-mapped-fontconfig" && -z "$AWESOME_GLYPHS_LOADED" ]]; then + echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded. + Source a font mapping in your shell config, per the Awesome-Font docs + (https://github.com/gabrielelana/awesome-terminal-fonts), + or use a different Powerlevel9k font configuration."; +fi + ################################################################ # @description # This function allows a segment to register the icons that it @@ -43,7 +60,7 @@ typeset -gAH icons # @example # registerIcon "LOCK_ICON" $'\UE0A2' $'\UE138' $'\UF023' '\u'$CODEPOINT_OF_AWESOME_LOCK $'\UF023' ## -registerIcon() { +function registerIcon() { local map local ICON_USER_VARIABLE=P9K_${1} if defined "$ICON_USER_VARIABLE"; then # check for icon override first @@ -60,100 +77,22 @@ registerIcon() { icons[$1]=${map} } -# Initialize the icon list according to the user's `P9K_MODE`. -typeset -gAH icons -case $P9K_MODE in - 'flat'|'awesome-patched') - # Awesome-Patched Font required! See: - # https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - ) - ;; - 'awesome-fontconfig') - # fontconfig with awesome-font required! See - # https://github.com/gabrielelana/awesome-terminal-fonts - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - ) - ;; - 'awesome-mapped-fontconfig') - # mapped fontconfig with awesome-font required! See - # https://github.com/gabrielelana/awesome-terminal-fonts - # don't forget to source the font maps in your startup script - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - - if [ -z "$AWESOME_GLYPHS_LOADED" ]; then - echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded. - Source a font mapping in your shell config, per the Awesome-Font docs - (https://github.com/gabrielelana/awesome-terminal-fonts), - Or use a different Powerlevel9k font configuration."; - fi - - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - ) - ;; - 'nerdfont-complete'|'nerdfont-fontconfig') - # nerd-font patched (complete) font required! See - # https://github.com/ryanoasis/nerd-fonts - # http://nerdfonts.com/#cheat-sheet - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - ) - ;; - *) - # Powerline-Patched Font required! - # See https://github.com/Lokaltog/powerline-fonts - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - ) - ;; -esac +#      +registerIcon "LEFT_SEGMENT_SEPARATOR" $'\uE0B0' $'\uE0B0' $'\uE0B0' $'\uE0B0' $'\uE0B0' +#      +registerIcon "RIGHT_SEGMENT_SEPARATOR" $'\uE0B2' $'\uE0B2' $'\uE0B2' $'\uE0B2' $'\uE0B2' +# Whitespace Whitespace Whitespace Whitespace Whitespace +registerIcon "LEFT_SEGMENT_END_SEPARATOR" ' ' ' ' ' ' ' ' ' ' +#      +registerIcon "LEFT_SUBSEGMENT_SEPARATOR" $'\uE0B1' $'\uE0B1' $'\uE0B1' $'\uE0B1' $'\uE0B1' +#      +registerIcon "RIGHT_SUBSEGMENT_SEPARATOR" $'\uE0B3' $'\uE0B3' $'\uE0B3' $'\uE0B3' $'\uE0B3' +# ╭─ ╭─ ╭─ ╭─ ╭─ +registerIcon "MULTILINE_FIRST_PROMPT_PREFIX" $'\u256D'$'\U2500' $'\u256D'$'\U2500' $'\u256D'$'\U2500' $'\u256D'$'\U2500' $'\u256D'$'\U2500' +# ├─ ├─ ├─ ├─ ├─ +registerIcon "MULTILINE_NEWLINE_PROMPT_PREFIX" $'\u251C'$'\U2500' $'\u251C'$'\U2500' $'\u251C'$'\U2500' $'\u251C'$'\U2500' $'\u251C'$'\U2500' +# ╰─ ╰─ ╰─ ╰─ ╰─ +registerIcon "MULTILINE_LAST_PROMPT_PREFIX" $'\u2570'$'\U2500 ' $'\u2570'$'\U2500 ' $'\u2570'$'\U2500 ' $'\u2570'$'\U2500 ' $'\u2570'$'\U2500 ' # Override the above icon settings with any user-defined variables. case $P9K_MODE in @@ -173,9 +112,6 @@ case $P9K_MODE in ;; esac -# Hide branch icon if user wants it hidden -[[ "$P9K_HIDE_BRANCH_ICON" == true ]] && icons[VCS_BRANCH_ICON]='' - ################################################################ # @description # Prints the requested icon. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1b37e2356..b235b5222 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -47,16 +47,16 @@ else fi ################################################################ -# Source icon functions +# Source utility functions ################################################################ -source "${p9kDirectory}/functions/icons.zsh" +source "${p9kDirectory}/functions/utilities.zsh" ################################################################ -# Source utility functions +# Source icon functions ################################################################ -source "${p9kDirectory}/functions/utilities.zsh" +source "${p9kDirectory}/functions/icons.zsh" ################################################################ # Source color functions diff --git a/segments/vcs.p9k b/segments/vcs.p9k index 6be43a660..93711ac76 100644 --- a/segments/vcs.p9k +++ b/segments/vcs.p9k @@ -89,7 +89,10 @@ registerIcon "VCS_BOOKMARK_ICON" $'\u263F' $'\uE87B' $'\uF27B' '\u'$CODEPOIN #     registerIcon "VCS_COMMIT_ICON" '' $'\uE821 ' $'\uF221 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' $'\uE729 ' -if [[ "$P9K_HIDE_BRANCH_ICON" != true ]]; then +# Hide branch icon if user wants it hidden +if [[ "$P9K_HIDE_BRANCH_ICON" == true ]]; then + icons[VCS_BRANCH_ICON]='' +else if [[ $P9K_MODE != 'compatible' ]]; then #      registerIcon "VCS_BRANCH_ICON" $'\uE0A0 ' $'\uE220 ' $'\uF126 ' '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' $'\uF126 '