1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-23 15:41:57 +00:00

Merge pull request #717 from onaforeignshore/date_segment

Added `prompt_date` and fixed segment comments
This commit is contained in:
Ben Hilburn 2018-01-24 14:21:01 -05:00 committed by GitHub
commit 8090d13962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 109 additions and 28 deletions

View file

@ -88,6 +88,7 @@ The segments that are currently available are:
* [`background_jobs`](#background_jobs) - Indicator for background jobs. * [`background_jobs`](#background_jobs) - Indicator for background jobs.
* [`battery`](#battery) - Current battery status. * [`battery`](#battery) - Current battery status.
* [`context`](#context) - Your username and host, conditionalized based on $USER and SSH status. * [`context`](#context) - Your username and host, conditionalized based on $USER and SSH status.
* [`date`](#date) - System date.
* [`dir`](#dir) - Your current working directory. * [`dir`](#dir) - Your current working directory.
* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder. * `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder.
* [`disk_usage`](#disk_usage) - Disk usage of your current partition. * [`disk_usage`](#disk_usage) - Disk usage of your current partition.
@ -337,6 +338,14 @@ end of the hostname.
|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the 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.| |`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.|
##### date
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.|
##### dir ##### dir
The `dir` segment shows the current working directory. When using the "Awesome The `dir` segment shows the current working directory. When using the "Awesome
@ -391,7 +400,7 @@ The `truncate_with_package_name` strategy gives your directory path relative to
} }
``` ```
the path shown would be `my-cool-project`. If you navigate to `$HOME/projects/my-project/src`, then the path shown would be `my-cool-project/src`. Please note that this currently looks for `.git` directory to determine the root of the project. The path shown would be `my-cool-project`. If you navigate to `$HOME/projects/my-project/src`, then the path shown would be `my-cool-project/src`. Please note that this currently looks for `.git` directory to determine the root of the project.
If you want to customize the directory separator, you could set: If you want to customize the directory separator, you could set:
```zsh ```zsh

View file

@ -88,6 +88,8 @@ case $POWERLEVEL9K_MODE in
VPN_ICON '(vpn)' VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈ KUBERNETES_ICON $'\U2388' # ⎈
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uE184' # 
TIME_ICON $'\uE12E' # 
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -160,6 +162,8 @@ case $POWERLEVEL9K_MODE in
VPN_ICON $'\uF023' VPN_ICON $'\uF023'
KUBERNETES_ICON $'\U2388' # ⎈ KUBERNETES_ICON $'\U2388' # ⎈
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' # 
) )
;; ;;
'awesome-mapped-fontconfig') 'awesome-mapped-fontconfig')
@ -237,6 +241,8 @@ case $POWERLEVEL9K_MODE in
VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK
KUBERNETES_ICON $'\U2388' # ⎈ KUBERNETES_ICON $'\U2388' # ⎈
DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX # 
DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' # 
) )
;; ;;
'nerdfont-complete'|'nerdfont-fontconfig') 'nerdfont-complete'|'nerdfont-fontconfig')
@ -309,6 +315,8 @@ case $POWERLEVEL9K_MODE in
VPN_ICON '(vpn)' VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈ KUBERNETES_ICON $'\U2388' # ⎈
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' # 
) )
;; ;;
*) *)
@ -381,6 +389,8 @@ case $POWERLEVEL9K_MODE in
VPN_ICON '(vpn)' VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈ KUBERNETES_ICON $'\U2388' # ⎈
DROPBOX_ICON 'Dropbox' DROPBOX_ICON 'Dropbox'
DATE_ICON ''
TIME_ICON ''
) )
;; ;;
esac esac

View file

@ -17,7 +17,7 @@
################################################################ ################################################################
## Turn on for Debugging ## Turn on for Debugging
#PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k ' #PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k '
#zstyle ':vcs_info:*+*:*' debug true #zstyle ':vcs_info:*+*:*' debug true
#set -o xtrace #set -o xtrace
@ -273,6 +273,7 @@ right_prompt_segment() {
# right-left but reads the opposite, this isn't necessary for the other side. # right-left but reads the opposite, this isn't necessary for the other side.
CURRENT_BG='NONE' CURRENT_BG='NONE'
################################################################
# Anaconda Environment # Anaconda Environment
prompt_anaconda() { prompt_anaconda() {
# Depending on the conda version, either might be set. This # Depending on the conda version, either might be set. This
@ -286,6 +287,7 @@ prompt_anaconda() {
fi fi
} }
################################################################
# AWS Profile # AWS Profile
prompt_aws() { prompt_aws() {
local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}"
@ -295,6 +297,7 @@ prompt_aws() {
fi fi
} }
################################################################
# Current Elastic Beanstalk environment # Current Elastic Beanstalk environment
prompt_aws_eb_env() { prompt_aws_eb_env() {
local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}')
@ -304,6 +307,7 @@ prompt_aws_eb_env() {
fi fi
} }
################################################################
# Segment to indicate background jobs with an icon. # Segment to indicate background jobs with an icon.
set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true
set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false
@ -322,6 +326,7 @@ prompt_background_jobs() {
fi fi
} }
################################################################
# A newline in your prompt, so you can segments on multiple lines. # A newline in your prompt, so you can segments on multiple lines.
prompt_newline() { prompt_newline() {
local lws newline local lws newline
@ -339,6 +344,7 @@ prompt_newline() {
POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws
} }
################################################################
# Segment that indicates usage level of current partition. # Segment that indicates usage level of current partition.
set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false
set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90
@ -381,6 +387,8 @@ prompt_disk_usage() {
fi fi
} }
################################################################
# Segment that displays the battery status in levels and colors
prompt_battery() { prompt_battery() {
# The battery can have four different states - default to 'unknown'. # The battery can have four different states - default to 'unknown'.
local current_state='unknown' local current_state='unknown'
@ -491,6 +499,7 @@ prompt_battery() {
fi fi
} }
################################################################
# Public IP segment # Public IP segment
# Parameters: # Parameters:
# * $1 Alignment: string - left|right # * $1 Alignment: string - left|right
@ -570,6 +579,7 @@ prompt_public_ip() {
fi fi
} }
################################################################
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
# Note that if $DEFAULT_USER is not set, this prompt segment will always print # 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_CONTEXT false
@ -658,6 +668,7 @@ prompt_host() {
"$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" "$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 'custom` prompt provides a way for users to invoke commands and display
# the output in a segment. # the output in a segment.
prompt_custom() { prompt_custom() {
@ -669,6 +680,7 @@ prompt_custom() {
fi fi
} }
################################################################
# Display the duration the command needed to run. # Display the duration the command needed to run.
prompt_command_execution_time() { prompt_command_execution_time() {
set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3
@ -702,6 +714,7 @@ prompt_command_execution_time() {
fi fi
} }
################################################################
# Dir: current working directory # Dir: current working directory
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
@ -860,6 +873,7 @@ prompt_dir() {
"$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}"
} }
################################################################
# Docker machine # Docker machine
prompt_docker_machine() { prompt_docker_machine() {
local docker_machine="$DOCKER_MACHINE_NAME" local docker_machine="$DOCKER_MACHINE_NAME"
@ -869,6 +883,7 @@ prompt_docker_machine() {
fi fi
} }
################################################################
# GO prompt # GO prompt
prompt_go_version() { prompt_go_version() {
local go_version local go_version
@ -881,11 +896,13 @@ prompt_go_version() {
fi fi
} }
################################################################
# Command number (in local history) # Command number (in local history)
prompt_history() { prompt_history() {
"$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h' "$1_prompt_segment" "$0" "$2" "grey50" "$DEFAULT_COLOR" '%h'
} }
################################################################
# Detection for virtualization (systemd based systems only) # Detection for virtualization (systemd based systems only)
prompt_detect_virt() { prompt_detect_virt() {
if ! command -v systemd-detect-virt > /dev/null; then if ! command -v systemd-detect-virt > /dev/null; then
@ -904,7 +921,8 @@ prompt_detect_virt() {
fi fi
} }
################################################################
# Test icons
prompt_icons_test() { prompt_icons_test() {
for key in ${(@k)icons}; do for key in ${(@k)icons}; do
# The lower color spectrum in ZSH makes big steps. Choosing # The lower color spectrum in ZSH makes big steps. Choosing
@ -915,6 +933,8 @@ prompt_icons_test() {
done done
} }
################################################################
# Segment to display the current IP address
prompt_ip() { prompt_ip() {
if [[ "$OS" == "OSX" ]]; then if [[ "$OS" == "OSX" ]]; then
if defined POWERLEVEL9K_IP_INTERFACE; then if defined POWERLEVEL9K_IP_INTERFACE; then
@ -945,6 +965,8 @@ prompt_ip() {
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' "$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" set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun"
# prompt if vpn active # prompt if vpn active
prompt_vpn_ip() { prompt_vpn_ip() {
@ -955,6 +977,8 @@ prompt_vpn_ip() {
done done
} }
################################################################
# Segment to display load
set_default POWERLEVEL9K_LOAD_WHICH 5 set_default POWERLEVEL9K_LOAD_WHICH 5
prompt_load() { prompt_load() {
# The load segment can have three different states # The load segment can have three different states
@ -1010,8 +1034,8 @@ prompt_load() {
"$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON' "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON'
} }
################################################################
# Node version # Segment to diplay Node version
prompt_node_version() { prompt_node_version() {
local node_version=$(node -v 2>/dev/null) local node_version=$(node -v 2>/dev/null)
[[ -z "${node_version}" ]] && return [[ -z "${node_version}" ]] && return
@ -1019,7 +1043,8 @@ prompt_node_version() {
"$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON' "$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON'
} }
# Node version from NVM ################################################################
# Segment to display Node version from NVM
# Only prints the segment if different than the default value # Only prints the segment if different than the default value
prompt_nvm() { prompt_nvm() {
local node_version nvm_default local node_version nvm_default
@ -1034,7 +1059,8 @@ prompt_nvm() {
$1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON'
} }
# NodeEnv Prompt ################################################################
# Segment to display NodeEnv
prompt_nodeenv() { prompt_nodeenv() {
local nodeenv_path="$NODE_VIRTUAL_ENV" local nodeenv_path="$NODE_VIRTUAL_ENV"
if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then
@ -1043,12 +1069,14 @@ prompt_nodeenv() {
fi fi
} }
# print a little OS icon ################################################################
# Segment to print a little OS icon
prompt_os_icon() { prompt_os_icon() {
"$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON"
} }
# print PHP version number ################################################################
# Segment to display PHP version number
prompt_php_version() { prompt_php_version() {
local php_version local php_version
php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*")
@ -1058,7 +1086,8 @@ prompt_php_version() {
fi fi
} }
# Show free RAM and used Swap ################################################################
# Segment to display free RAM and used Swap
prompt_ram() { prompt_ram() {
local base='' local base=''
local ramfree=0 local ramfree=0
@ -1081,7 +1110,8 @@ prompt_ram() {
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
} }
# rbenv information ################################################################
# Segment to display rbenv information
set_default POWERLEVEL9K_RBENV_ALWAYS false set_default POWERLEVEL9K_RBENV_ALWAYS false
prompt_rbenv() { prompt_rbenv() {
if which rbenv 2>/dev/null >&2; then if which rbenv 2>/dev/null >&2; then
@ -1096,7 +1126,8 @@ prompt_rbenv() {
fi fi
} }
# chruby information ################################################################
# Segment to display chruby information
# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH # see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH
prompt_chruby() { prompt_chruby() {
local chruby_env local chruby_env
@ -1107,14 +1138,16 @@ prompt_chruby() {
fi fi
} }
# Print an icon if user is root. ################################################################
# Segment to print an icon if user is root.
prompt_root_indicator() { prompt_root_indicator() {
if [[ "$UID" -eq 0 ]]; then if [[ "$UID" -eq 0 ]]; then
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON'
fi fi
} }
# Print Rust version number ################################################################
# Segment to display Rust version number
prompt_rust_version() { prompt_rust_version() {
local rust_version local rust_version
rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$')
@ -1123,7 +1156,9 @@ prompt_rust_version() {
"$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON'
fi fi
} }
# RSpec test ratio
################################################################
# Segment to display RSpec test ratio
prompt_rspec_stats() { prompt_rspec_stats() {
if [[ (-d app && -d spec) ]]; then if [[ (-d app && -d spec) ]]; then
local code_amount tests_amount local code_amount tests_amount
@ -1134,7 +1169,8 @@ prompt_rspec_stats() {
fi fi
} }
# Ruby Version Manager information ################################################################
# Segment to display Ruby Version Manager information
prompt_rvm() { prompt_rvm() {
local version_and_gemset=${rvm_env_string/ruby-} local version_and_gemset=${rvm_env_string/ruby-}
@ -1143,12 +1179,15 @@ prompt_rvm() {
fi fi
} }
################################################################
# Segment to display SSH icon when connected
prompt_ssh() { prompt_ssh() {
if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON'
fi fi
} }
################################################################
# Status: When an error occur, return the error code, or a cross icon if option is set # 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 # Display an ok icon when no error occur, or hide the segment if option is set to false
# #
@ -1204,6 +1243,8 @@ prompt_status() {
fi fi
} }
################################################################
# Segment to display Swap information
prompt_swap() { prompt_swap() {
local swap_used=0 local swap_used=0
local base='' local base=''
@ -1228,6 +1269,7 @@ prompt_swap() {
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON'
} }
################################################################
# Symfony2-PHPUnit test ratio # Symfony2-PHPUnit test ratio
prompt_symfony2_tests() { prompt_symfony2_tests() {
if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then
@ -1239,7 +1281,8 @@ prompt_symfony2_tests() {
fi fi
} }
# Symfony2-Version ################################################################
# Segment to display Symfony2-Version
prompt_symfony2_version() { prompt_symfony2_version() {
if [[ -f app/bootstrap.php.cache ]]; then if [[ -f app/bootstrap.php.cache ]]; then
local symfony2_version local symfony2_version
@ -1248,6 +1291,7 @@ prompt_symfony2_version() {
fi fi
} }
################################################################
# Show a ratio of tests vs code # Show a ratio of tests vs code
build_test_stats() { build_test_stats() {
local code_amount="$4" local code_amount="$4"
@ -1263,16 +1307,23 @@ build_test_stats() {
(( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6"
} }
################################################################
# System time # System time
prompt_time() { prompt_time() {
local time_format="%D{%H:%M:%S}" set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}"
if [[ -n "$POWERLEVEL9K_TIME_FORMAT" ]]; then
time_format="$POWERLEVEL9K_TIME_FORMAT"
fi
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$time_format" "$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 # todo.sh: shows the number of tasks in your todo.sh file
prompt_todo() { prompt_todo() {
if $(hash todo.sh 2>&-); then if $(hash todo.sh 2>&-); then
@ -1283,6 +1334,7 @@ prompt_todo() {
fi fi
} }
################################################################
# VCS segment: shows the state of your repository, if you are in a folder under # VCS segment: shows the state of your repository, if you are in a folder under
# version control # version control
set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red"
@ -1348,6 +1400,8 @@ powerlevel9k_vcs_init() {
fi fi
} }
################################################################
# Segment to show VCS information
prompt_vcs() { prompt_vcs() {
VCS_WORKDIR_DIRTY=false VCS_WORKDIR_DIRTY=false
VCS_WORKDIR_HALF_DIRTY=false VCS_WORKDIR_HALF_DIRTY=false
@ -1373,6 +1427,7 @@ prompt_vcs() {
fi fi
} }
################################################################
# Vi Mode: show editing mode (NORMAL|INSERT) # Vi Mode: show editing mode (NORMAL|INSERT)
set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT"
set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL"
@ -1387,6 +1442,7 @@ prompt_vi_mode() {
esac esac
} }
################################################################
# Virtualenv: current working virtualenv # Virtualenv: current working virtualenv
# More information on virtualenv (Python): # More information on virtualenv (Python):
# https://virtualenv.pypa.io/en/latest/ # https://virtualenv.pypa.io/en/latest/
@ -1397,6 +1453,7 @@ prompt_virtualenv() {
fi fi
} }
################################################################
# pyenv: current active python version (with restrictions) # pyenv: current active python version (with restrictions)
# https://github.com/pyenv/pyenv#choosing-the-python-version # https://github.com/pyenv/pyenv#choosing-the-python-version
prompt_pyenv() { prompt_pyenv() {
@ -1405,17 +1462,20 @@ prompt_pyenv() {
fi fi
} }
################################################################
# Display openfoam information
prompt_openfoam() { prompt_openfoam() {
local wm_project_version="$WM_PROJECT_VERSION" local wm_project_version="$WM_PROJECT_VERSION"
local wm_fork="$WM_FORK" local wm_fork="$WM_FORK"
if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")"
elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")"
fi fi
} }
# Swift version ################################################################
# Segment to display Swift version
prompt_swift_version() { prompt_swift_version() {
# Get the first number as this is probably the "main" version number.. # 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) local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1)
@ -1424,6 +1484,7 @@ prompt_swift_version() {
"$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' "$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 # dir_writable: Display information about the user's permission to write in the current directory
prompt_dir_writable() { prompt_dir_writable() {
if [[ ! -w "$PWD" ]]; then if [[ ! -w "$PWD" ]]; then
@ -1431,6 +1492,7 @@ prompt_dir_writable() {
fi fi
} }
################################################################
# Kubernetes Current Context/Namespace # Kubernetes Current Context/Namespace
prompt_kubecontext() { prompt_kubecontext() {
local kubectl_version="$(kubectl version --client 2>/dev/null)" local kubectl_version="$(kubectl version --client 2>/dev/null)"
@ -1457,6 +1519,7 @@ prompt_kubecontext() {
fi fi
} }
################################################################
# Dropbox status # Dropbox status
prompt_dropbox() { prompt_dropbox() {
# The first column is just the directory, so cut it # The first column is just the directory, so cut it
@ -1474,7 +1537,6 @@ prompt_dropbox() {
} }
################################################################ ################################################################
# Prompt processing and drawing # Prompt processing and drawing
################################################################ ################################################################