~yerinalexey/dotfiles

ref: 8579758ddf3d8383f2ea9cad38fab11934bc456e dotfiles/zsh/p10k.zsh -rw-r--r-- 4.8 KiB
8579758dAlexey Yerin scripts/xdg-open: fix terminal command for foot 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
## Powerlevel10k configuration

# Temporarily change options.
'builtin' 'local' '-a' 'p10k_config_opts'
[[ ! -o 'aliases'         ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob'         ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'

() {
	emulate -L zsh

	# Unset all configuration options.
	unset -m 'POWERLEVEL9K_*|DEFAULT_USER'

	# Zsh >= 5.1 is required.
	autoload -Uz is-at-least && is-at-least 5.1 || return

	# Prompt colors
	local grey='242'
	local red='#FF5C57'
	local yellow='#F3F99D'
	local blue='#57C7FF'
	local green='#6CBD68'
	local magenta='#FF6AC1'
	local cyan='#9AEDFE'
	local white='#F1F1F0'

	# Left prompt segments
	typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
		# =========================[ Line #1 ]=========================
		dir                       # current directory
		vcs                       # git status
		command_execution_time    # previous command duration
		prompt_char               # prompt symbol
	)

	# Disable right prompt
	typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()

	# Basic style options that define the overall prompt look.
	typeset -g POWERLEVEL9K_BACKGROUND=                           # transparent background
	typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
	typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
	typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR=       # no end-of-line symbol
	typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=          # no segment icons

	# Do not add an empty line before prompt
	typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false

	# Magenta prompt symbol if the last command succeeded.
	typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=$magenta
	# Red prompt symbol if the last command failed.
	typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=$red
	# Default prompt symbol.
	typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='$'
	# Prompt symbol in Vi mode.
	typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION=':'
	typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION=':'
	typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true

	# --- Current directory module ---
	typeset -g POWERLEVEL9K_DIR_FOREGROUND=$blue

	# Shorten directory
	typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=240
	typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
	typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=5

	# --- Time module ---
	typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=$yellow

	# Show previous command duration only if it's >= 5s
	typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5
	# Don't show fractional seconds. Thus, 7s rather than 7.3s
	typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
	# Format: took 1d 2h 3m 4s
	typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
	typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='took '

	# --- VCS module ---
	typeset -g POWERLEVEL9K_VCS_FOREGROUND=$grey

	# Disable async loading indicator
	typeset -g POWERLEVEL9K_VCS_LOADING_TEXT=

	# Don't wait for Git status
	typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0

	# Show changes, tag, untracked files and how many commits local branch is ahead/behind a remote
	typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-tagname git-untracked git-aheadbehind)

	# Icons
	typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=''     # Current branch
	typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@'    # Detached HEAD
	typeset -g POWERLEVEL9K_VCS_STAGED_ICON='+'    # Changed files count
	typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' # Untracked files count
	typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON='*'  # Unstaged files count

	# --- Misc ---
	# Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
	# when accepting a command line. Supported values:
	#
	#   - off:      Don't change prompt when accepting a command line.
	#   - always:   Trim down prompt when accepting a command line.
	#   - same-dir: Trim down prompt when accepting a command line unless this is the first command
	#               typed after changing current working directory.
	typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always

	# Enable instant prompt
	typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet

	# Disable hot reload
	typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true

	# If p10k is already loaded, reload configuration.
	# This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
	(( ! $+functions[p10k] )) || p10k reload
}

# Tell `p10k configure` which file it should overwrite.
typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}

(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'